Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local _fps = 30
- gameTime = 0
- simulatedTime = 0
- timeSlice = 1 / _fps
- function love.load()
- end
- function love.update(dt)
- gameTime = gameTime + dt
- -- this will update "one frame too many"
- -- if simulated time is at 3 * timeSlice and game time is at 3.1 * timeSlice, the game
- -- will do one more update, resulting in simulatedTime == 4 * timeSlice
- -- we're in the future now. We'll use interpolation to render objects between their last position
- -- and they're current position, letting us render the world as it should be at this time
- -- this is similar to doing an in-between animation frame between two key animation frames
- while(simulatedTime < gameTime) do
- simulatedTime = simulatedTime + timeSlice
- -- update game world and entities
- end
- end
- function love.draw()
- end
Advertisement
Add Comment
Please, Sign In to add comment