Robin wrote:Plus relying on exactly the right position measured in pixels. It's incredibly easy to mess up and even if you don't, a bug somewhere else in your game could break your game because of it. (If you assume the player will never reach pixel 392, because at pixel 391, you turn them around, you still have a problem if due to some bug you suddenly move two pixels instead of one or something. If you had checked for >= 391 rather than == 391, it wouldn't have been a problem.)
No, no.. I think I didn't explained well.
What I mean is that if the game character amount of movement depends on the computer speed, then the character will move different amount of distances in different computers.
Lets say, we create a game like Quake, where we can jump over pits full of magma.
Now, we implemented a movement based on dt, like posX = posX + speed * dt.
When the player dt is high, his movement amount will be bigger, so for example, he may be moving 7 game meter per key press instead the supposed 5 or 3 or 1 or whatever the game is designed originally.
If he needs to jump over a pit of lava that starts at meter 10 and ends and meter 15, then he can't jump over it because he either steps in meter 7 and jumps to meter 14 falling to the lava, or he walks directly into the lava.
So basically, if the amount moved depends on dt, then pressing the key the same amount of seconds will result in DIFFERENT distances moved.
And this doesn't affect only the amount of movement. This affects the collisions because some objects that may be in the path blocking the movement, if the object is at meter 10, but the player moves 7 meters each step, then the player may never get closer than 3 meters away from that object (10 - 7) because if he moves beyond meter 7, he would be trespassing the wall, so basically, the collision is happening where it is not supposed to happen.
And this never happens when using love.keypressed. Even when low dt, if I press the key during 2 seconds I will move always the same distance if my dt is 1000 or 0.0001.