Help => General => Topic started by: bryce910 on February 26, 2015, 07:24:17 am
Title: Rotate Sprite and Move at Angle!
Post by: bryce910 on February 26, 2015, 07:24:17 am
Hello everyone!
I am currently rotating a sprite by using:
sprite.rotate(1);
basically it is slowly rotating the sprite which works perfect. What I am not able to quite figure out is when I shoot a bullet from my sprite... for example which is located at a 37* angle how would I go about getting the bullet to move in the same angle the sprite is rotated to? :-\
Thanks and hopefully I made that clear and understandable! Bryce910
Title: Re: Rotate Sprite and Move at Angle!
Post by: Laurent on February 26, 2015, 07:49:16 am
Basic trigonometry:
x += cos(angle) * speed; y += sin(angle) * speed;
Title: Re: Rotate Sprite and Move at Angle!
Post by: bryce910 on February 26, 2015, 08:54:29 am
Okay thank you! I never understood basic geometry! I will need to do some research it looks like! :P
Title: Re: Rotate Sprite and Move at Angle!
Post by: StormWingDelta on February 26, 2015, 04:53:02 pm
Yep making games takes a lot of math. I've met people who wanted to avoid using any kind of math in games before and found it rather funny.
In any event here's a few sites to get you started: