Steering Movement Help

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Joelrodiel
Prole
Posts: 27
Joined: Wed Apr 20, 2016 3:40 am

Steering Movement Help

Post 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.
Attachments
demo.love
(3.67 KiB) Downloaded 127 times
BetonineAntis
Prole
Posts: 1
Joined: Fri Aug 11, 2017 12:18 pm
Location: Lithuania

Re: Steering Movement Help

Post 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 :)
Attachments
demo.love
(3.95 KiB) Downloaded 135 times
User avatar
Joelrodiel
Prole
Posts: 27
Joined: Wed Apr 20, 2016 3:40 am

Re: Steering Movement Help

Post 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!!
sphyrth
Party member
Posts: 260
Joined: Mon Jul 07, 2014 11:04 am
Contact:

Re: Steering Movement Help

Post by sphyrth »

This demo got me interested out pseudo-3d stuff.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 4 guests