gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Beginners > Problem with sprites

#22704 - Becks7 - Sun Jun 27, 2004 3:08 pm

what can cause the 2nd sprite not to be displayed correctly ?
here is the screenshot
http://upload.keekles.com/upload/scr1.jpg
and here is the texture file
http://upload.keekles.com/upload/scr2.jpg

#22705 - Becks7 - Sun Jun 27, 2004 3:10 pm

the 1st sprite is animated

#22706 - alek - Sun Jun 27, 2004 5:00 pm

It will be alot easier to help you if you post some code.

#22707 - Becks7 - Sun Jun 27, 2004 5:23 pm

int main()
{

........

InitializeSprites(); //set all sprites off screen (stops artifact)

sprites[0].attribute0 = COLOR_256 | SQUARE | green.y; //setup sprite info, 256 colour, shape and y-coord
sprites[0].attribute1 = SIZE_16 | green.x; //size 16x16 and x-coord
sprites[0].attribute2 = 0; //pointer to tile where sprite starts

for(loop = 0; loop < 1024; loop++) //load 1st sprite image data
{
OAMData[loop] = GREENData[loop];
}

green.activeFrame = 0; //set the initial active frame markers
green.spriteFrame[0] = 0; //set the frame markers
green.spriteFrame[1] = 8;
green.spriteFrame[2] = 16;
green.spriteFrame[3] = 24;
green.spriteFrame[4] = 32;
green.spriteFrame[5] = 40;
green.spriteFrame[6] = 48;
green.spriteFrame[7] = 56;



sprites[1].attribute0 = COLOR_256 | SQUARE | block.y;//setup sprite info, 256 colour, shape and y-coord
sprites[1].attribute1 = SIZE_16 | block.x; //size 16x16 and x-coord
sprites[1].attribute2 = 64; //pointer to tile where sprite starts

for(loop = 1024; loop < 1152; loop++) //load 1st sprite image data
{
OAMData[loop] = BLOCKData[loop-128];
}

...........

}

#22709 - alek - Sun Jun 27, 2004 6:15 pm

Are you sure that the loop-128 index is correct when you load the block sprite data?

A little tip: when you post code use the Code button.
Ex

Text...
Code:

for(loop = 1024; loop < 1152; loop++) //load 1st sprite image data
{
OAMData[loop] = BLOCKData[loop-128];
}

Text...

#22742 - Becks7 - Mon Jun 28, 2004 4:06 pm

is this the only place where the problem could be ?

#22743 - Becks7 - Mon Jun 28, 2004 4:08 pm

cause i think it is correct

#22744 - poslundc - Mon Jun 28, 2004 4:13 pm

There is a high probability this is where the problem stems from. Where is BLOCKData defined? Try rewriting the code using GREENData instead.

But sure, the problem could lie elsewhere. We've only got a snippet of your code.

Dan.

#22745 - alek - Mon Jun 28, 2004 4:21 pm

It looks to me like you just copied that bit from gbajunkie's tutorial(I could be wrong). Is your data setup up the same way as in his tutrial?

#22746 - Wriggler - Mon Jun 28, 2004 4:21 pm

Yeah it looks to me (as someone who is learning this exact thing right now!) that your "loop-128" index should be "loop-1024". That's assuming the BLOCKData stuff you want starts at the array index 0. Otherwise you are starting your image at index 896, which probably isn't right...

Ben

#22791 - Becks7 - Tue Jun 29, 2004 5:38 pm

yes, its from the gbajunkie tutorials but i have rewritten it acording to my game
i will try changing "loop-128" to "loop-1024"

#22862 - Becks7 - Wed Jun 30, 2004 4:50 pm

but, i dont think this would help, because i have eight character images above the block image

#22864 - poslundc - Wed Jun 30, 2004 5:15 pm

Like I said in my earlier post, it will depend largely on what BLOCKData is defined as. I don't know why you don't use GREENData instead.

Dan.

#23068 - Becks7 - Sat Jul 03, 2004 9:32 am

GREENData is the green character (1st sprite)
BLOCKData is the block (2nd sprite)
the 2nd one is not displayed correctly as you can see from the pics

#23074 - poslundc - Sat Jul 03, 2004 1:40 pm

I meant in the code, not in your design. Of course everything works the way you want it to in your head.

Dan.

#23172 - Becks7 - Tue Jul 06, 2004 1:52 pm

Wriggler wrote:
Yeah it looks to me (as someone who is learning this exact thing right now!) that your "loop-128" index should be "loop-1024". That's assuming the BLOCKData stuff you want starts at the array index 0. Otherwise you are starting your image at index 896, which probably isn't right...

Ben


yes, you were right
i couldnt notice that
thank you very much

#23242 - Wriggler - Thu Jul 08, 2004 10:31 am

Becks7 wrote:
yes, you were right
i couldnt notice that
thank you very much


Great, glad I could help!

Ben