#4144 - phr0zn - Thu Mar 20, 2003 8:36 pm
I am having trouble loading a third sprite in my Pong Demo. I load the first two sprites perfectly, but the thrid sprite loads as the top half of the "paddle" sprite. The paddle is 16x32, and the ball is 16x16. What is happening is the ball is loading as the first 16x16 of the paddle sprite (both located in the same header file). I believe the issue lies in the last loop of my code, but I cannot figure out what is going wrong. Thanks.
Also, for future reference, how do I load more sprites than 2 or 3? Is there some easy way to figure out the palette memory loop? I was able to figure out that for 16x32 it is 0->256, and 16x16 is 0->128 in the loop, but how do I load more than that?
Thanks.
[/code]
_________________
http://cerberus.promodtecnologies.com
Also, for future reference, how do I load more sprites than 2 or 3? Is there some easy way to figure out the palette memory loop? I was able to figure out that for 16x32 it is 0->256, and 16x16 is 0->128 in the loop, but how do I load more than that?
Thanks.
Code: |
void SetupSprites() { u16 loop; for(loop = 0; loop < 256; loop++) //load the palette into memory OBJPaletteMem[loop] = palette[loop]; InitializeSprites(); //set all sprites off screen (stops artifact) sprites[0].attribute0 = COLOR_256 | BIT15 | player.y_pos; //setup sprite info, 256 colour, shape and y-coord sprites[0].attribute1 = BIT15 | player.x_pos; //size 16x16 and x-coord sprites[0].attribute2 = 0; //pointer to tile where sprite starts for(loop = 0; loop < 256; loop++) //load sprite image data { OAMData[loop] = paddleData[loop]; } sprites[1].attribute0 = COLOR_256 | BIT15 | computer.y_pos; //setup sprite info, 256 colour, shape and y-coord sprites[1].attribute1 = BIT15 | computer.x_pos; //size 16x16 and x-coord sprites[1].attribute2 = 0; sprites[2].attribute0 = COLOR_256 | SQUARE | pongball.y_pos; //setup sprite info, 256 colour, shape and y-coord sprites[2].attribute1 = SIZE_16 | pongball.x_pos; //size 16x16 and x-coord sprites[2].attribute2 = 8; for(loop = 256; loop < 384; loop++) //load sprite image data { OAMData[loop] = pongballData[loop-128]; } } |
_________________
http://cerberus.promodtecnologies.com