The Daily Click ::. Forums ::. Klik Coding Help ::. 360 degree bullet movement
 

Post Reply  Post Oekaki 
 

Posted By Message

Muz



Registered
  14/02/2002
Points
  6499

VIP MemberI'm on a BoatI am an April FoolHonored Admin Alumnus
25th July, 2006 at 03:04:53 -

I have this idea of calculating a bullet's movement by taking the simple formula of:
Set X to SPD*cos(angle)
Set Y to SPD*sin(angle)

..where angle is the angle in 360 degrees and SPD is the bullet's speed/loops.

Now the problem with this is that:
1. I don't know how to get the angle the shooter is facing
2. At higher speeds, the bullet might actually pass over the target. E.g. at speed 10 pix/loop, the bullet will be jumping 10 pixels in a straight shot.
3. A bunch of people shooting around would lead to a lot of trigonometric calculations. Just 5 people shooting 3 bullets a second would mean 15 per loop/second! Now if I did 10 loops, there'd easily be 300 trigonometric calculations per second! I'm not sure the rate of work a comp could handle.

 
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.

Image

Klikmaster

Master of all things Klik

Registered
  08/07/2002
Points
  2599

Has Donated, Thank You!You've Been Circy'd!VIP MemberPS3 Owner
25th July, 2006 at 07:03:52 -

1. I always used angle calculator in MMF1.5, not sure bout MMF2, I could never get it to work properly using ATan.
2. Call a loop, say Xloop, speed number of times, and on the loop move it 1 pixel, thus you have the same effect, but you can test the collisions on the loop (ie. every pixel)
3.I guess you'll have to test it out and see what the performance is like.

 
n/a

Werbad



Registered
  18/09/2002
Points
  235
25th July, 2006 at 07:18:11 -

A computer is built to handle big and complex mathemetial functions, so i don't think there will be any problem with 300 calculations/s... I have mae way more complex things without loosing framerates or whatever.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click