#22660 - Wriggler - Sat Jun 26, 2004 3:20 pm
Hi guys,
I'm trying to combine a couple of tutorials really. The first showed me how sprites worked, but it used Mode 1. As I haven't really figured out the tile modes yet, I thought it would be cool to use this new fangled sprite stuff in Mode 4. So I grabbed my previous code from the Mode 4 tutorial, and tried combining the two.
I've gotten as far as the background being shown, but the sprites do not appear. Looking through the debug options in the emulator, the sprites have loaded correctly they are just not actually appearing. I suspect this is a problem with the drawing priority of the background and the sprites.
Of course, here is the code. I've only included the main() function, but if anything else is needed then please let me know!
Can anyone help me out with this? Thanks in advance, I'm sure it's a simple problem but I'm not sure how to go about fixing it.
Cheers,
Ben
Last edited by Wriggler on Sat Jun 26, 2004 4:17 pm; edited 1 time in total
I'm trying to combine a couple of tutorials really. The first showed me how sprites worked, but it used Mode 1. As I haven't really figured out the tile modes yet, I thought it would be cool to use this new fangled sprite stuff in Mode 4. So I grabbed my previous code from the Mode 4 tutorial, and tried combining the two.
I've gotten as far as the background being shown, but the sprites do not appear. Looking through the debug options in the emulator, the sprites have loaded correctly they are just not actually appearing. I suspect this is a problem with the drawing priority of the background and the sprites.
Of course, here is the code. I've only included the main() function, but if anything else is needed then please let me know!
Code: |
//Entry point int main() { //Variable declarations u16 loop; u16 x = 50; u16 y = 50; u16 x2 = 150; u16 y2 = 50; //set mode 1 and enable sprites and 1d mapping SetMode(MODE_4 | BG2_ENABLE | OBJ_ENABLE | OBJ_MAP_1D); //Load screen palette and background data for (loop = 0; loop < 256; loop++) { BGPaletteMem[loop]=bgPalette[loop]; } for (loop = 0; loop < (120*160); loop++) { VideoBuffer[loop] = bgData[loop] ; } //load the sprite palette into memory for(loop = 0; loop < 256; loop++) { OBJPaletteMem[loop] = ballPalette[loop]; } InitializeSprites(); sprites[0].attribute0 = COLOR_256 | SQUARE | y; //setup sprite info, 256 colour, shape and y-coord sprites[0].attribute1 = SIZE_16 | x; //size 16x16 and x-coord sprites[0].attribute2 = 0; //pointer to tile where sprite starts for(loop = 0; loop < 128; loop++) { //load sprite image data OAMData[loop] = ballData[loop]; } //2nd sprite sprites[1].attribute0 = COLOR_256 | SQUARE | y2; sprites[1].attribute1 = SIZE_16 | x2; sprites[1].attribute2 = 8; for(loop=128; loop < 256; loop++) { OAMData[loop] = ballData[loop-128]; } //Game loop while(1) { WaitForVsync(); CopyOAM(); } return 0; } |
Can anyone help me out with this? Thanks in advance, I'm sure it's a simple problem but I'm not sure how to go about fixing it.
Cheers,
Ben
Last edited by Wriggler on Sat Jun 26, 2004 4:17 pm; edited 1 time in total