Page 1 of 1

Steering Movement Help

Posted: Sun Sep 24, 2017 2:38 am
by Joelrodiel
Hi, I started playing around with this concept called sprite stacking, and its of a car, and I wanted to implement movement. I didnt want regular movement, I wanted to implement steering movement. After alot of trial and error and alot of ghetto code I figured I should ask because there must be an easier way.

So I would really appreciate if someone could point me in the right direction please (or steer me in the right direction).

Heres the demo just in case you want to check how it could be implemented.

Re: Steering Movement Help

Posted: Sun Sep 24, 2017 8:57 pm
by BetonineAntis
Hey, basically what you need are these two lines:

Code: Select all

player_x = player_x + math.cos(player_r) * speed * dt
player_y = player_y + math.sin(player_r) * speed * dt
If you are not familiar with trigonometry, I suggest googling about how sin/cos (atan2 might also help you in the future) works.
I'm attaching your modified demo, feel free to ask if something is not clear there - i was too lazy to write comments :)

Re: Steering Movement Help

Posted: Sun Sep 24, 2017 11:12 pm
by Joelrodiel
BetonineAntis wrote: Sun Sep 24, 2017 8:57 pm Hey, basically what you need are these two lines:

Code: Select all

player_x = player_x + math.cos(player_r) * speed * dt
player_y = player_y + math.sin(player_r) * speed * dt
If you are not familiar with trigonometry, I suggest googling about how sin/cos (atan2 might also help you in the future) works.
I'm attaching your modified demo, feel free to ask if something is not clear there - i was too lazy to write comments :)
Thank you so much that's exactly what I needed!!

Re: Steering Movement Help

Posted: Mon Sep 25, 2017 2:23 am
by sphyrth
This demo got me interested out pseudo-3d stuff.