As most of us, I control nearly all of my images on my game screen via float*delta to get nice, smooth movement. I’ve ran into a rather awkward problem though. Slick2D’s TiledMap class demands a int value to render the actual tiled map. That’s fine and dandy, I just pass the valued cased with (int).
Well, that works great for moving up/down/left/right, but the problem is, when moving diagonally in any direction you get this very slight “zigzag” effect. It’s extremely subtle, hardly noticeable at all and quite frankly I may be the only one who ever notices it. But it’s there, and I assume it’s from the float values being rounded to an int when passed to the TiledMap class to render the map. When moving up, down, left or right it’s completely invisible. But diagonally you can tell that the movement is moving like this:
http://sixtygig.com/junk/post1.png
What I want, is this:
http://sixtygig.com/junk/post2.png
… and, I’m unsure how to solve the problem. I attempted to simply edit the slick source code to be able to pass a float to it instead, but the problem is the tiled class propagates the “need” for an int all the way deep into other classes I should not be messing with, I ended up changing about 6 or 7 different class files from int to floats before I started hitting walls of code where I’d have to reprogram some core slick methods and realized it probably wasn’t a good idea. So, I’m looking for alternative solutions.
One solution I could come up with in theory is to “magically” run both playerX and Y at the absolute exact same time, I believe the problem would go away.
But, I’m pretty sure that can’t be done, so… Any advice?
if(canMoveNorthEast){
this.canMoveReset();
playerX += 0.1f * delta;
playerY -= 0.1f * delta;
input.clearKeyPressedRecord();
return;
}