GLBasic forum

Main forum => GLBasic - en => Topic started by: MrPlow on 2012-Aug-28

Title: movement / sprite rotation
Post by: MrPlow on 2012-Aug-28
Hi

I have a rotating sprite and want to move it forward in the direction relative to the rotation of the sprite

So if it is pointing downleft have the acceleration begin from there...

Also want to accelerate the sprite slowly.

Is there an easy way to do this without mind-numbing math?
Title: Re: movement / sprite rotation
Post by: MrPlow on 2012-Aug-28
Okay I think I have the movement sorted...

Just need a acceleration method...

Code (glbasic) Select
myship.x =myship.x - (COS(myship.ang) * 2)
myship.y = myship.y + (SIN(myship.ang) * 2)


Where ang = rotosprite value...
:good:
Title: Re: movement / sprite rotation
Post by: kanonet on 2012-Aug-28
Yeah thats the way to do it. in this calculation '2' is the speed of the spritemovement, if you want to move your sprite faster, just replace the '2' with your speed.
Title: Re: movement / sprite rotation
Post by: MrPlow on 2012-Aug-28
I managed to get a nice acceleration routine done...thnks!!!

Speeds up and slows down gradually...wow - eureka moment!  :booze:
Title: Re: movement / sprite rotation
Post by: matchy on 2012-Aug-29
Code (glbasic) Select

DEC myship.x, COS(myship.angle) * myship.speed
INC myship.y, SIN(myship.angle) * myship.speed