Sprite::Sprite()
Code: Select all
Sprite::Sprite ( string name, u8 screen, SpriteSize size, u8 prior, u16 xPos, u16 yPos, u8 width, u8 height )
{
this->screen = screen;
setupSprite(name);
assignId();
sprite = &oamMain.oamMemory[spriteId]; //sprite is a spriteEntry pointer, oamMemory is a pointer to
assignPalette();
sprite->x = xPos;
sprite->y = yPos;
sprite->palette = palId;
this->size = size;
this->height = height;
this->width = width;
this->priority = prior;
//oamAllocateGfx returns a u16 pointer gfxindex is just a u16 need to make conversion
if(screen == 0)
{
gfxPtr = oamAllocateGfx ( &oamMain, size, SpriteColorFormat_256Color );
}
else
{
gfxPtr = oamAllocateGfx ( &oamSub, size, SpriteColorFormat_256Color );
}
oamSet(&oamMain, spriteId, sprite->x, sprite->y, 0, palId, size, SpriteColorFormat_256Color, gfxPtr, -1, false, false, false, false, false);
dmaCopy(spriteTiles, gfxPtr, width*height);
}
Inside of our second class "Inventory"
Code: Select all
spriteR1C1 = new Sprite("invR1C1", 0, SpriteSize_64x64, 0, 0, 100, 64, 64);
spriteR1C2 = new Sprite("invR1C2", 0, SpriteSize_64x64, 0, 64, 100, 64, 64) ;
spriteR1C3 = new Sprite("invR1C3", 0, SpriteSize_64x64, 0, 128, 100, 64, 64);
// Breaks here after the third sprite is created
spriteR1C4 = new Sprite("invR1C4", 0, SpriteSize_64x64, 0, 192, 100, 64, 64);
spriteR2C4 = new Sprite("invR2C4", 0, SpriteSize_64x64, 0, 192, 164, 64, 64);
Code: Select all
s1 s2 s3 s4 s5
0
0 1
0 1 2
0 3 2 3
0 4 2 4 4
Our Questions and concerns:
- What does oamSet() do, and can we have the code for it? We would like to see what it does so we can possibly know what we can do differently.
- We are confused as to how the spriteIDs are being changed. This is causing us difficulty because our collision algorithm is being affected by it implicitly. We are testing the wrong sprites because due to the ID changing, our SpriteEntry* pointers are being altered in a strange way.
Oddly enough, the sprites do appear on the screen correctly...
Any help and input is greatly appreciated.