Realistic space flight

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.
pedrosgali
Party member
Posts: 107
Joined: Wed Oct 15, 2014 5:00 pm
Location: Yorkshire, England

Re: Realistic space flight

Post by pedrosgali »

Hey, you have an acceleration stat. Are you setting it to 0?
Basically you can express all travel in 3 vectors:

location, velocity and acceleration, every tick add acceleration to velocity then add velocity to location THEN set acceleration to 0 so it doesn't go crazy on you.

So your keyboard controls affect the acceleration each tick which gets added to velocity, your current directional speed, which gets added to your location then the acceleration gets set to 0 so it doesn't get re-added next tick.

I used a vector based system as it is easier to read IMO. I learned about it here. http://natureofcode.com/ Chapter 1 and 2 should really help you.

Code: Select all

if not wearTheseGlasses() then
  chewing_on_trashcan = true
end
User avatar
Beelz
Party member
Posts: 234
Joined: Thu Sep 24, 2015 1:05 pm
Location: New York, USA
Contact:

Re: Realistic space flight

Post by Beelz »

pedrosgali wrote:Hey, you have an acceleration stat. Are you setting it to 0?
The way I did it acceleration is a static value. In the update, velocity values are changed depending on input and drag. Then in draw:

Code: Select all

   spaceship.posX = spaceship.posX + spaceship.velX * dt
   spaceship.posY = spaceship.posY + spaceship.velY * dt

Code: Select all

if self:hasBeer() then self:drink()
else self:getBeer() end
GitHub -- Website
Post Reply

Who is online

Users browsing this forum: Google [Bot], Odod5000 and 8 guests