Sorry for my insistence guys, I know that I'm bothering so much, and that this is my third post this week! :C I would like you tell me if is best that I don't ask so much...
Well... I put images of my error in this post and this is my code:
Thanks!
]]>Why do you initialise sourceX at 32?
I don't think the sprite sheet width is an exact multiple of 32.
I don't know, in the tutorial that i've saw the code is like this...
I tried changing the values but nothing... What could be? Someone know how i could do a RPG player?
Thanks : )
]]>The original example must have used a character of width 32, so sourceX=32 picks the "middle" column, where the character has both feet on floor.
Try using the attached image, I re-aligned your character, individual sprites are now 39x48. It's a GIF, I couldn't find a good program for 32bit PNG at the moment - I hope it will load OK on OSX.
Also, change the 3 following places in your code:
int dir = DOWN, sourceX = 32, sourceY = 0;
--> int dir = DOWN, sourceX = 39, sourceY = 0;
sourceX = 32;
--> sourceX = 39;
al_draw_bitmap_region(player, sourceX, sourceY * al_get_bitmap_height(player) / 4, 32, 32, x, y, NULL);
--> al_draw_bitmap_region(player, sourceX, sourceY * al_get_bitmap_height(player) / 4, 39, 48, x, y, NULL);
It works, but, when i move to the RIGHT the animation go UP, when I move DOWN, the animation go to the LEFT, when I move UP, the animation go DOWN and when I move to RIGHT the animation go up, do you know what could be?
Thanks
The original example must also have the sprites ordered differently...
At the beginning of your program, change the order in the enum to:
enum direction { DOWN, LEFT, RIGHT, UP };
Oh man, thank you very much!
]]>