How i can create an animated sprite of grid based RPG game in love2d?
Posted: Mon Sep 05, 2016 10:40 am
I explain the question: I am creating a game of Pokemon and i want to create the character style movement that it has.
The quads of the map tileset are 32x32, and the quads of the character tileset are 32x48 . Therefore, to move it you need to add the X or Y character 32 pixels. So far easy but things get complicated when we want to animate the sprite character. In this case we have to Professor Oak. His tileset shows how should have 4 frames for the 4 basic moves up, down, left and right.
About this problem, I decided to program it like this: every 8 pixel motion wasd, using love.keyboard.isDown, show the corresponding frame of each of their movements. The problem is shown. Each time you press one of these keys, only makes the movement of 8 pixels, and stays in the next frame. That is, to do the entire route of a quad, is tightened 4 times the same key. The question is how to make the movement of 8 pixels 4 times consecutively, so that the user cannot press any key till the movement of 32 pixels is completed, avoiding multiple errors of choice wrong frame, and preventing not grid movement. I tried to do with "for" loops, but does not draw correctly in love.draw () function, its logical.
I pass the script of the exactly problem:
I hope that there are any function I can use to do this in an optimized way. If it does not work because of the way it is programmed, I can change it.
Greetings.
Sorry for my horrible english. The names of some functions are in spanish, sorry for that.
The quads of the map tileset are 32x32, and the quads of the character tileset are 32x48 . Therefore, to move it you need to add the X or Y character 32 pixels. So far easy but things get complicated when we want to animate the sprite character. In this case we have to Professor Oak. His tileset shows how should have 4 frames for the 4 basic moves up, down, left and right.
About this problem, I decided to program it like this: every 8 pixel motion wasd, using love.keyboard.isDown, show the corresponding frame of each of their movements. The problem is shown. Each time you press one of these keys, only makes the movement of 8 pixels, and stays in the next frame. That is, to do the entire route of a quad, is tightened 4 times the same key. The question is how to make the movement of 8 pixels 4 times consecutively, so that the user cannot press any key till the movement of 32 pixels is completed, avoiding multiple errors of choice wrong frame, and preventing not grid movement. I tried to do with "for" loops, but does not draw correctly in love.draw () function, its logical.
I pass the script of the exactly problem:
I hope that there are any function I can use to do this in an optimized way. If it does not work because of the way it is programmed, I can change it.
Greetings.
Sorry for my horrible english. The names of some functions are in spanish, sorry for that.