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.
Realistic space flight
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Party member
- Posts: 107
- Joined: Wed Oct 15, 2014 5:00 pm
- Location: Yorkshire, England
Re: Realistic space flight
Code: Select all
if not wearTheseGlasses() then
chewing_on_trashcan = true
end
Re: Realistic space flight
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:pedrosgali wrote:Hey, you have an acceleration stat. Are you setting it to 0?
Code: Select all
spaceship.posX = spaceship.posX + spaceship.velX * dt
spaceship.posY = spaceship.posY + spaceship.velY * dt
Who is online
Users browsing this forum: Google [Bot], Odod5000 and 8 guests