Difference in gameplay on actual device, same fps

I'm developing a game, source can be found here:

The problem I'm facing is that the gameplay on the actual device is completely different from the simulator, even though the fps are the same (not during screen recording though)
This is on the simulator:

gameplaySimulator

This is with screen recording (sorry for the converted gif, it's crappy but you get the point, speed is half what is normally)
ezgif-3-bd2006038b

As you can also see, the circle sizes get screwed up at the end.

It looks like the playdate.getElapsedTime() is behaving differently on simulator than on device. Does anybody have any idea what's going on?
I have absolutely no idea even how to debug this, as I can't even find proper info on how to properly debug with the physical device.

p.s. I would love to have some more experienced coder on this project, as you can see the idea is kinda neat and it really fits the console, but I think I lack a bit of the chops to pull off the physics correctly. Do get in contact if you would like to make this go further!

4 Likes

Looks like a fun idea!
Your GitHub repo seems to be private so I can’t look at it. My guess is that part of your code is frame-dependent and part time-dependent and the device isn’t running at a consistent framerate.

Fixed the visibility! Sorry (;
I... don't think this is the case?
I mean, all calculations are time dependent, but you make a good point. I can't find anything obvious though.

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
4 Likes

This is a really cool game. I like it!

Ah, it makes a lot of sense. Thanks! It would have taken a mountain of time to figure out without you :heart:

And thank you! I was waiting for my actual device to expand it and polish it, hopefully I’ll be able to make it a full fledged game in the next months.
Again, if somebody is in the mood for lending a hand… (;

Ok, this fixed the random circle sizes and a lot of the jagginess of the position.
But it didn't solve the molasses speed compared to the emulator.
Controls are responsive, it's just that it looks like elapsed time works at, eyeballing it, about 1/10th of the actual speed?
so game speed and events happen at 1/10th of speed I expect.

it took me a while to realise what the problem is here.

you currently have the time reset at the end of your loop and the assign at the beginning, which is timing how long it takes for the update loop to reset, rather than what you want to be doing which is timing how long it takes to do the stuff in the loop.

you need to do as nic did in his example.

  elapsedTime = playdate.getElapsedTime()
  playdate.resetElapsedTime()

this simple change fixes your game and it runs the same on device and simulator.

it's smooth! i am sure you are still working on the gameplay so i will save my comments until you have done more.

ps: have you ever seen the Circle game MaBoShi? Here's the DS version and Wii version. IMHO it's one of the greatest games of all time, and i think you could create something like that? you already have most of the code done! Let me know your thoughts!

1 Like

Nic even got that and fixed in his snippet of code! Whops!
I didn’t notice it, I just fixed the code by hand not just copying it (;
Thank you so much!
I hope I can get this further soon!

1 Like

too late but i filed a PR on your repo: https://github.com/Amidee89/One-Way-Out/pull/1

feel free to ignore it!

I will absolutely merge it! :heart:

2 Likes

Not a helpful reply but one just to say I love this idea and can't wait to see how it develops!