|
Want to thank me for making this book available for free? Just buy Special Edition Using Macromedia Director MX
Advanced Lingo For Games
| |
| Game Overview
In "Space Rocks," you pilot a small ship in a field of large objects. If one of the objects hits your ship, you die. However, you can avoid the objects in two ways: you can blast them with your gun, or you can fly away. Figure 11.1 shows a game in progress. The game started with four big rocks, but one was blasted into two medium-sized rocks by the player. The ship still remains in the middle of the screen because the player has not yet applied any thrust.
Figure 11.1
Space Rocks game in progress.
Ship MovementThe player's ship starts out in the middle of the screen. The player can rotate it in any direction. This determines both the ship's aim, and its direction of movement. The player moves by firing the ship's thrusters. When this happens, the ship gains momentum in the direction in which the ship is pointed. The player can also fire a bullet in the direction that the ship is pointing. There are only a limited number of bullets that can appear at any given time, usually five. Rock MovementRocks, like the player's ship, have both a direction and a speed. Unlike the player's ship, the rocks start off moving at the beginning of the level, and they don't stop unless they are hit by a player's bullet. They do not change direction or speed, unless they are hit, in which case the big rock ceases to exist and two new rocks, with new directions and speeds are created to replace it We use the term momentum to describe the case where an object on the screen is constantly moving. To easily handle momentum, we will break it into two components: horizontal momentum and vertical momentum. Combined, they can make the object move in any direction in the computer screen's two dimensions. Breaking RocksInstead of just disappearing, as our sprite invaders did in the previous chapter, the rocks break into two smaller pieces when they are hit. The rocks start off as "big" size rocks, and then break into two "medium" rocks. When a "medium" rock is hit, it breaks into two "small" rocks. Finally, when a "small" rock is hit, it disintegrates. We will do this by getting rid of the large rock, and placing two smaller rocks at the same location. These new rocks will have a random direction. Screen WrapThe screen is a finite space. However, the rocks need to keep moving in the same direction. So what happens when a rock moves off the screen? Although it breaks the "outer space" metaphor a bit, we take the rock and place it on the other side of the screen. It still retains the same speed and direction. It just appears to have "wrapped" around to the other side. This "wrap" happens for both the horizontal and vertical edges of the screen. The same idea is applied to the player's ship, but not the bullets the player fires. Wrapping is achieved by simply adding or subtracting vertical and horizontal values. For instance, if the screen is 500 pixels wide, and a rock moves to a horizontal position of 505, we simply subtract 500 and place the rock at a horizontal position of 5. Limited AmmunitionThe player cannot be allowed to let loose an endless stream of bullets because it would make the game too easy. Instead, there should be a limit to the number of bullets allowed on the screen at one time. In addition, the bullets should be spaced apart in time a bit. Because we are using a bank of bullet sprites, we just need to limit this bank to five sprites. In the Score position that would contain the sixth sprite, we place no sprite at all. This way, when the fifth bullet sprite asks the sixth bullet sprite to fire, the message just gets ignored. In the example movie on the CD-ROM, we only allow five bullets on the screen at one time. Not only does this allow us to predict how many sprites are necessary, but it makes the game more difficult for the player. LevelsLike the game in Chapter 10, "Sprite Invaders," this game has levels of increasing difficulty. Each level is a separate frame. The frame behavior sets the number of rocks and the speed of the rocks higher for each level. Special EffectsWe have established that we will need at least three rock graphics: large, medium, and small. However, we will actually have two variations of each type. This makes the game screen look a little less uniform. After all, rocks are not supposed to be all the same. In addition, we will put a spin on the rocks. It is unlikely that rocks in space will maintain the same orientation as they fly by, so a little spin makes them look more realistic. The spin is created by changing the rotation property of the sprites. Sounds for this game include rock explosions and the ship firing. We can also have one for the ship explosion. | |