#10113 - Phil Hale - Wed Aug 27, 2003 10:58 am
I'm have problems displaying sprites. Ever another sprite is displayed correctly. Sprites 0, 2, 4, and 6 work fine, and sprites 1, 3, and 5 do not, plus there is a 'artifact' in the top left of the screen. I have initialised the sprites to an off screen position so I have no idea why the artifact appears.
Heres the code (I have been following gbajunkies tutorials so thats where most of the code is from):
The first sprite is 8x8 and the rest are 32x8. I have swapped TALL and WIDE in sprite.h so they are the correct way round.
Can anyone tell me what I have done wrong??
Heres the code (I have been following gbajunkies tutorials so thats where most of the code is from):
Code: |
#include "sprite.h"
#include "gba.h" #include "dispcnt.h" #include "sprites\palette.h" #include "sprites\ball.h" #include "sprites\bat.h" #include "sprites\block1.h" #include "sprites\block2.h" #include "sprites\block3.h" #include "sprites\block4.h" #include "sprites\block5.h" int main() { u16 loop; u16* temp; SetMode(MODE_1 | OBJ_ENABLE | OBJ_MAP_1D); for(loop = 0; loop < 256; loop++) OBJPaletteMem[loop] = palette[loop]; InitializeSprites(); sprites[0].attribute0 = COLOR_256 | SQUARE | 142; sprites[0].attribute1 = SIZE_8 | 11; sprites[0].attribute2 = 0; for(loop = 0; loop < 32; loop++) { OAMData[loop] = ballData[loop]; } sprites[1].attribute0 = COLOR_256 | WIDE | 147; sprites[1].attribute1 = SIZE_16 | 107; sprites[1].attribute2 = 2; for(loop = 32; loop < 160; loop++) { OAMData[loop] = batData[loop-32]; } sprites[2].attribute0 = COLOR_256 | WIDE | 35; sprites[2].attribute1 = SIZE_16 | 12; sprites[2].attribute2 = 10; for(loop = 160; loop < 288 ; loop++) { OAMData[loop] = block1Data[loop-160]; } sprites[3].attribute0 = COLOR_256 | WIDE | 35; sprites[3].attribute1 = SIZE_16 | 56; sprites[3].attribute2 = 18; for(loop = 288; loop < 416 ; loop++) { OAMData[loop] = block2Data[loop-288]; } sprites[4].attribute0 = COLOR_256 | WIDE | 35; sprites[4].attribute1 = SIZE_16 | 102; sprites[4].attribute2 = 26; for(loop = 416; loop < 544 ; loop++) { OAMData[loop] = block3Data[loop-416]; } sprites[5].attribute0 = COLOR_256 | WIDE | 35; sprites[5].attribute1 = SIZE_16 | 147; sprites[5].attribute2 = 34; for(loop = 544; loop < 672 ; loop++) { OAMData[loop] = block4Data[loop-544]; } sprites[6].attribute0 = COLOR_256 | WIDE | 35; sprites[6].attribute1 = SIZE_16 | 192; sprites[6].attribute2 = 42; for(loop = 672; loop < 800 ; loop++) { OAMData[loop] = block5Data[loop-672]; } while(1) //the main game loop { WaitForVsync(); CopyOAM(); } } |
The first sprite is 8x8 and the rest are 32x8. I have swapped TALL and WIDE in sprite.h so they are the correct way round.
Can anyone tell me what I have done wrong??