Game Development Reference
In-Depth Information
Now that you've found out the bullet's velocity, the next thing you need to do is find out what its
starting position on the stage should be. This is just a slight modification to the same calculations that
you used to find the position of the wand. That's because you want the bullets to appear in exactly the
same spot on the stage as the wand.
The values for the bullet's starting t and u position are stored in the ^qhhap[Op]npT and the
^qhhap[Op]npU variables. The only difference between these calculations and the ones you used to set
the position of the wand is that you need to add the t and u position of the lh]uan object into the
mix. They represent the center of the imaginary circle that you're describing with these calculations.
(The s]j` is a subobject of the lh]uan and shares the same center t and u position as the lh]uan
object, so you didn't need to specify this extra information when you calculated its position.)
You can now use all this information, the bullet's start position and velocity, to create the bullet:
r]n^qhhap6>qhhap9jas>qhhap$^qhhap[Rt(^qhhap[Ru(^qhhap[Op]npT( ±
You can see that all the variables you've just created are arguments used to create the bullet. But
there's an odd one out: op]n.
I created this player control system so that the player has the choice of firing three types of bullets:
stars, circles, or squares. You can see this in effect by changing the previous directive so it looks like
r]n^qhhap6>qhhap9jas>qhhap$^qhhap[Rt(^qhhap[Ru(^qhhap[Op]npT( ±
^qhhap[Op]npU( _en_ha %7
If you save the Lh]uan*]o file and test the project with this change, you'll see something like
Figure 10-14. Button Fairy can now fire blue circles.
Figure 10-14. Change “star” to “circle” to make Button
Fairy fire blue circles.
Search Nedrilad ::

Custom Search