#9422 - iuiz - Mon Aug 04, 2003 2:33 pm
Hiho,
i found the following Code, for moving Sprites:
I think it is realy Popular. But isn't it faster to move a Sprite this way:
The first one is from GbaJunkie, the other uses code from the tutorial, too, so I hope that there is no problem in understanding the Code.
Cu,
iuiz
i found the following Code, for moving Sprites:
Code: |
void moveSprite(OAMEntry* sp, int x, int y){
//moving the sprite sp->attribute1 = sp->attribute1 & 0xFE00; //clear the old x value sp->attribute1 = sp->attribute1 | x; //new value sp->attribute0 = sp->attribute0 & 0xFF00; //clear the old y value sp->attribute0 = sp->attribute0 | y; //new value } |
I think it is realy Popular. But isn't it faster to move a Sprite this way:
Code: |
void GetInput() { if(!(*KEYS & KEY_UP)) { pacman.y--; sprites[pacman.OAMSpriteNum].attribute0 = COLOR_256 | SQUARE | pacman.y; } if(!(*KEYS & KEY_LEFT)) { pacman.x--; sprites[pacman.OAMSpriteNum].attribute1 = SIZE_16 | pacman.x; [...and so on] |
The first one is from GbaJunkie, the other uses code from the tutorial, too, so I hope that there is no problem in understanding the Code.
Cu,
iuiz