Computer Science Canada shooting |
Author: | metachief [ Sat Apr 26, 2008 11:53 am ] |
Post subject: | shooting |
What is the format for making something shoot bullets? How would I use arrays for this one (if I do need to use them) It would be nice to if someone could give me the layout of the program that would for example make a box shoot little dots. |
Author: | Sean [ Sat Apr 26, 2008 11:55 am ] |
Post subject: | RE:shooting |
Pretty simple, you draw your gun and then use a for loop to move the bullet in a certain direction. |
Author: | metachief [ Sat Apr 26, 2008 5:09 pm ] |
Post subject: | RE:shooting |
i mean multiple bullets..how do yoiu make many bullets shoot |
Author: | Sean [ Sat Apr 26, 2008 5:26 pm ] |
Post subject: | RE:shooting |
Draw numerous bullets, or continuous dots coming from it. |
Author: | CodeMonkey2000 [ Sat Apr 26, 2008 9:46 pm ] |
Post subject: | Re: RE:shooting |
Sean @ Sat Apr 26, 2008 11:55 am wrote: Pretty simple, you draw your gun and then use a for loop to move the bullet in a certain direction.
No no no, do not use a for loop. Instead remember the bullet's angle and velocity. Using basic trig you make the bullet travel in that angle at that velocity each frame. For efficiency have velX and velY (x and y components of the velocity in relation to the angle) precomputed and just add this to you x and y coordinates. Having types will be useful. Make a type called bullet. It should store the x and ycoordinate and the xVel and yVel. Then you can make a flexible array of bullets. |