Collision with ground failing when window moved or resized

Hello guys. Finally back, since a long time away for lack of time. But let’s go straight to business.

It’s easier to show my problem in video, so please watch (physics debug is enabled to better understanding).

I made a simple platform game and set it all based upon the platform tutorial. I got to get everything to work, as you can see in the video, but when I move the window or resize it, something happens and the collisions fail. The tile collisions are based in tileset (static) and player is kinetic. Is there any way to fix this? Is this a bug or something expected?

The engine gets paused when resizing the window, meaning that on the next frame dt will be way bigger than normal. If you’re multiplying your player’s speed by dt then they’ll move so far in a single frame that they completely skip over the ground’s collision object. One simple way to fix this is to skip an update if dt gets too big:

function update(self, dt)
    if dt > 1 then
    -- update code here

I did try and didn’t work =(
In fact, I found out it is worse than I thought. I dont need to resize or move the window. Just by clicking in the window title bar for a time (let’s say, for 500ms to 1s) is enough for my “player” to fall down, even if the window stays with same dimensions and same position. I dont know what to do. It’s as if the ground vanishes for the time I am clicking in the window title.

I had this problem with one of my platformer games a while back.

Here’s the stuff I did:

  1. I added in an event listener for when the window is resized or minimized, I force the game to be paused when this happens. Here’s the API around that.
    API reference (window)

  2. I also switched from update to fixed_update for physics calculations

Hope this helps!


What is the minimum set up needed to make this happen?
In debug, a dynamic collision object falling onto a static collision object works with no issues. What needs to be changed or added to this to break it?

I just tried with the “official” platform example (the one with the alien character) and same thing happens, altough looks like there is some sort of correction (maybe in code) but when you just move the window around, you see the glitch and, if you do it enough, eventually the “player” will fall or get through a wall, as we can see in the attached video.

I gotta say, it’s kinda frustrating. I was just looking at something like @gameoffate2018 proposed, to pause the game when the window is resized, but I didn’t see in the “window” api reference any resource to detect when the window is moved or dragged, not even coordinates (top, left).

Maybe the developers should include those functions as well as fix the source problem of this post, wich I consider is a bug.

Open game.project, scroll to Physics and check Use Fixed Timestep and then move all update logic from update(self, dt) to fixed_update(self, dt)