I'm creating a pokemon game from 0 and I want to create the character movement style that it has.
The tiles of the map tiles are 32x32, and those of the 32x48 character. Therefore, to move it you need to add 32 pixels to the X or Y of the character. So far easy, but things get complicated when we want to animate the sprite of the character. In this case we have Professor Oak. His tileset shows us how it should have 4 frames for the 4 basic movements, up, down, left and right.
Before this problem, I decided to program it in such a way that every 8 pixels of motion wasd, using love.keyboard.isDown
, will show the corresponding frame of each of its movements. The problem comes to light. Each time you press one of those keys, it only makes the movement of 8 pixels, and stays in the next frame. That is to say, to make the tour of a whole square, you have to press 4 times the same key.
The issue is that the movement of 8 pixels 4 times in a row, without the user can press any key until the movement of 32 pixels is completed, avoiding multiple errors of choice of incorrect frame, and preventing movement not typecast .
I tried to do it with loops for
, but it does not draw well in the function love.draw()
, logical thing the truth.
I pass the whole code for one drive: link
I hope there is some love function that I can use to do this in an optimized way. If it does not work because of the way it is programmed, I am open to modifications.