#90336 - Chucky - Thu Jun 29, 2006 7:31 pm
PART I:
Hello, I am using a method to animate this sprite I have that seems kind of easy and works really well (it just checks if the position of the sprite is divisible by 5 (in terms of X coordinate) and if it is, loads another drawing of the sprite, giving it the feeling that the guy is running (i know it's not good to use the % function but it seems to run very well... my other option was to check if the Xcoordinate was an even number and load the other animation this way, but I feel this was animating too fast).
what this will do is if i hit RIGHT (code not shown) the attr1 OBJ_HFLIP is not in there (therefore he will be facing RIGHT), it also checks if his x coordinate is divisible by 5, and if it is, will load the 2nd animation (as you see i did not have to declare the Sprite[1] info, I just use Sprite[0] and the other stored info on the second sprite (and OBJ_HFLIP) so instead of using 4 different sprites, I am only using Sprite[0]. So when i hit LEFT it does use the OBJ_HFLIP to make it seem like he has turned.
I just thought I would show this to get some feedback, if this is a good way to do the animation of him just running or if there is a nicer way (such as checking if his xcoordinate is even or odd, which i found to be kind of fast).
PART 2:
So, then I moved on to jumping animation, what I'm doing basically is taking the top left coordinate of my sprite (at 108) and I have a loop setup for the yvector array, so that it adds that value to the coordinate (no fancy equation just a simple jump motion will suffice). Here is the relevant code:
so basically what it does is update ymain_00 (this is the location on the Y axis of the sprite) by adding those values to it... the problem is, it is doing it really fast and either my code is garbage OR it's doing it properly but so fast that I can't detect the motion.
I am wondering what is a good way to allow the game to understand that I need just this part slowed down? Would it make sense to increase the yvector array to go from {-1,-2,..*max*..,1,0}? or is there a fancier way that may end up making the rest of my life easier (later on when I start doing better things)
Thanks again in advance!
Hello, I am using a method to animate this sprite I have that seems kind of easy and works really well (it just checks if the position of the sprite is divisible by 5 (in terms of X coordinate) and if it is, loads another drawing of the sprite, giving it the feeling that the guy is running (i know it's not good to use the % function but it seems to run very well... my other option was to check if the Xcoordinate was an even number and load the other animation this way, but I feel this was animating too fast).
Code: |
memcpy( (u16 *)0x06014000, &main_00Data, sizeof(main_00Data) ); //guy going RIGHT (1st animation)
memcpy( (u16 *)0x06014400, &main_01Data, sizeof(main_01Data) ); //guy going RIGHT (2nd animation) (512+32) Sprite[0].attr0 = OBJ_256_COLOR | OBJ_SQUARE | 108; Sprite[0].attr1 = OBJ_SIZE(2) | 40; //OBJ_SIZE(2) means 32x32 (it knows it has to be square because of OBJ_SQUARE in attr0) Sprite[0].attr2 = 512; //.................. if(KeyDown(KEY_LEFT) && xmain_00 > xMin) { if((xmain_00 % 5 ) == 0) {Sprite[0].attr1 = OBJ_HFLIP | OBJ_SIZE(2); Sprite[0].attr2 = 512;} // else {Sprite[0].attr1 = OBJ_HFLIP | OBJ_SIZE(2); Sprite[0].attr2=512+32;} // xmain_00--;xmain_00--; } |
what this will do is if i hit RIGHT (code not shown) the attr1 OBJ_HFLIP is not in there (therefore he will be facing RIGHT), it also checks if his x coordinate is divisible by 5, and if it is, will load the 2nd animation (as you see i did not have to declare the Sprite[1] info, I just use Sprite[0] and the other stored info on the second sprite (and OBJ_HFLIP) so instead of using 4 different sprites, I am only using Sprite[0]. So when i hit LEFT it does use the OBJ_HFLIP to make it seem like he has turned.
I just thought I would show this to get some feedback, if this is a good way to do the animation of him just running or if there is a nicer way (such as checking if his xcoordinate is even or odd, which i found to be kind of fast).
PART 2:
So, then I moved on to jumping animation, what I'm doing basically is taking the top left coordinate of my sprite (at 108) and I have a loop setup for the yvector array, so that it adds that value to the coordinate (no fancy equation just a simple jump motion will suffice). Here is the relevant code:
Code: |
u16 yvector[6] = {-15,-30,-39,-30,-15,0};
u8 j_height = 40; //........................ if(KeyDown(KEY_A) && ymain_00 > (yMax - j_height)) { u16 i; for(i = 0; i < 6 ; i++) {ymain_00 = yMax + yvector[i];} } |
so basically what it does is update ymain_00 (this is the location on the Y axis of the sprite) by adding those values to it... the problem is, it is doing it really fast and either my code is garbage OR it's doing it properly but so fast that I can't detect the motion.
I am wondering what is a good way to allow the game to understand that I need just this part slowed down? Would it make sense to increase the yvector array to go from {-1,-2,..*max*..,1,0}? or is there a fancier way that may end up making the rest of my life easier (later on when I start doing better things)
Thanks again in advance!