Difference in gameplay on actual device, same fps

The issue is how you use playdate.getElapsedTime()
During an update, each time you call it in your code, it is slightly different because time has passed compared to the previous call. Since the code run slower on the console, it makes bigger differences.

The trick is to calculate in your update how much time has passed since the previous update and to use the same value during the whole update.

deltaTime = 0

function playdate.update()
	deltaTime = playdate.getElapsedTime()
	playdate.resetElapsedTime()

	if(not startedUp) then
		gameOver()
		startedUp = true
	end
	
	gfx.clear()
	playdate.drawFPS(0,0)
	playdate.timer.updateTimers()
	collidedThisFrame = ""
	collisionRelocationMagnitude = 0
	previousPlayerPosition = playerPosition:copy()
	checkCommands()
	updateCircles()
	debugMovePlayerWithbuttons()
	checkCrank()
	drawCircles()
	updatePlayerPosition()
	updatePlayerSpeed()
	drawPlayer()
	checkScore()
end
function updatePlayerPosition()
   playerPosition.y +=  playerSpeed.y * deltaTime
   playerPosition.x += playerSpeed.x * deltaTime
   -- ...
end
6 Likes