#171827 - Drovor - Sun Dec 27, 2009 7:41 pm
I'm trying to use sprites, but they seem to be getting flipped. I have no idea why, since I'm creating them all in exactly the same way except for a random x/y location.
It looks like this:
http://www.flickr.com/photos/39069226@N03/4218913811/
The code I use to set the OAM attributes looks like this (spriteEntry is a reference to oam->oamBuffer[index]):
Afterwards the OAM copy is copied in:
Any help would be greatly appreciated, I'm tempted to "fix" this by flipping my "D" and "S" images horizontally and making a new ball sprite (currently borrowed from the examples) which has horizontal and vertical symmetry!
Last edited by Drovor on Sun Dec 27, 2009 9:18 pm; edited 1 time in total
It looks like this:
http://www.flickr.com/photos/39069226@N03/4218913811/
The code I use to set the OAM attributes looks like this (spriteEntry is a reference to oam->oamBuffer[index]):
Code: |
void game_state::initializeSprites() { int i; // Sprite initialisation for(i = 0; i < 256; i++) SPRITE_PALETTE[i] = ball.palette[i]; for(i = 0; i< 32*16; i++) SPRITE_GFX[i] = ball.image.data16[i]; for(i = 0; i < SPRITE_COUNT; i++) { /* Info */ spriteInfo[i].oamId = i; spriteInfo[i].width = 8; spriteInfo[i].height = 8; spriteInfo[i].angle = 0; spriteInfo[i].entry = spriteEntry[i]; /* attribute[0] */ spriteEntry[i]->y = rand() % 192; spriteEntry[i]->isRotateScale = false; spriteEntry[i]->isSizeDouble = false; spriteEntry[i]->blendMode = OBJMODE_NORMAL; spriteEntry[i]->isMosaic = false; spriteEntry[i]->colorMode = OBJCOLOR_256; spriteEntry[i]->shape = OBJSHAPE_SQUARE; /* attribute[1] */ spriteEntry[i]->x = rand() % 256; spriteEntry[i]->rotationIndex = spriteInfo[i].oamId; spriteEntry[i]->size = OBJSIZE_8; /* attribute[2] */ spriteEntry[i]->gfxIndex = 0; // All use the same one. spriteEntry[i]->priority = OBJPRIORITY_0; // spriteEntry[i]->palette = N/A, only one 256 palette } } |
Afterwards the OAM copy is copied in:
Code: |
DC_FlushAll(); dmaCopyHalfWords(SPRITE_DMA_CHANNEL, oam->oamBuffer, OAM, SPRITE_COUNT * sizeof(SpriteEntry)); |
Any help would be greatly appreciated, I'm tempted to "fix" this by flipping my "D" and "S" images horizontally and making a new ball sprite (currently borrowed from the examples) which has horizontal and vertical symmetry!
Last edited by Drovor on Sun Dec 27, 2009 9:18 pm; edited 1 time in total