sprite animation goes wrong!
Posted: Wed Feb 11, 2009 8:48 pm
hello everyone
yeah i know i post a lot, but i can't get this work. i'm now threee days stuck and it isn't going right. the problem: every time my sprite animation has to restart i get garbage on the screen
my code:
yeah i know i post a lot, but i can't get this work. i'm now threee days stuck and it isn't going right. the problem: every time my sprite animation has to restart i get garbage on the screen
my code:
Code: Select all
#include <nds.h>
#include "test.h"
#include "sprite.h"
s32 teller; // a counter
u16* gfx2;
u8* frame_gfx;
int frame;
void animateMan()
{
frame = (teller / 8);
u8* offset = frame_gfx + frame * 512;
dmaCopy(offset, gfx2, 512);
X_SetSprite(1, 1, 1, 1, 1);
}
void initMan()
{
gfx2 = oamAllocateGfx(&oamMain, SpriteSize_32x32, SpriteColorFormat_16Color);
frame_gfx = (u8*)testTiles;
}
int main(int argc, char **argv){
videoSetMode(MODE_0_2D);
vramSetBankA(VRAM_A_MAIN_SPRITE);
oamInit(&oamMain, SpriteMapping_1D_32, false);
X_LoadpalSprite(testPal, testPalLen, 1, 16, 1); // load the pallette
initMan();
while(1) {
// counter one up
if(teller==80){ teller = 0; animateMan(); }
if(teller!=80){ teller++; animateMan(); oamUpdate(&oamMain);}
X_VBL(); // instead of swi_waitvbl
}
return 0;
}