Game Development Reference
In-Depth Information
4. Between the staring point (-240,0) and the irst waypoint (-190,0), the enemy
sprite will have moved 50 pixels. Let's say we want to move 10 pixels per second.
That means the sprite should move to its new posiion in 5 seconds.
5. The difference between the first (-190,0) and the second (-190,125) waypoint is 125.
So according to the same formula, the sprite should move along this segment of the
path in 12.5 seconds.
6. Coninue calculaing the glide speeds like this for the other blocks. These are the
numbers I came up with: 5, 12.5, 17, 26.5, 15.5, 14, and 10.5, but remember that
yours may be different.
You can use the formula new position - old position / 10
= result to figure out the numbers you need to use.
7. To finish of, delete the clone when it reaches the end of the path.
Test your script and see the enemies moving along the path. You might noice they are very
slow and bunched together because they don't travel enough distances between spawns.
Let's ix that by adding a variable speed muliplier. Not only can we easily tweak the speed
of the sprites, but we can also use this later to have other enemy sprites move at different
speeds, as shown in the following steps:
1. Create a variable and make sure it is for this sprite only.
2. Name it multiplier_R . The R stands for red, the color of this enemy.
3. Place set <muliplier_R> to … at the start of the <green lag> script.
4. Fill in 0.3 as a number for the basic enemy.
5. Take the speed numbers you illed in previously and muliply them with
the muliplier.
6.
Use a ...*... operator block.
7.
Place the muliplier_R variable in one slot.
8.
Type the correct number in the other slot.
 
Search WWH ::




Custom Search