Hey there. I'm trying to start my second game using Lua and I decided to make a lunar lander game. It's going alright so far, but the main area I'm having trouble with is getting a correct force applied to my ship depending on its angle. Can anyone point me in the right direction as to what I could (or should) be using.
I'm using body:getAngle to get the angle of the ship and I'm just multiplying that by 70 to get a decent x value for the force I want to apply (probably not the best way to go about it ). I can't seem to find any way to turn the angle into a proper y value though.
Bring on the math, and thanks in advance for any help.
Last edited by Freonce on Thu Aug 19, 2010 8:19 pm, edited 1 time in total.
Well I think you can use tangent to get the slope. Don't ask me; I'm not a trig expert. I'm still not sure how you would change a slope into proper x and y values though.
you should play Astropatrolonium. Its a great game. http://love2d.org/forums/viewtopic.php?f=5&t=1716
Then look at its code where it says
----ship movement physik----
in function love.update(dt)
then a few lines down you find:
Awesome!
Thanks for all the replies. I think that little snippet of code is just want I need. I was trying to use math.atan2 for some reason... I'll be sure to read those links as well. Understanding the why is a key part to learning all this, and having it stick.