#50335 - justinGBA - Mon Aug 08, 2005 8:30 am
I just got done with getting backgrounds to work now i have some questions about sprites..
In a tiled background you just point you control register to a CharBaseBlock and a ScreenBaseBlock that has the data you would like to use. Now with sprites, i know there is an OAM entry but how do i tell it what tile to use..? Especially if i have multiple tiles of different sizes? I loaded in an image with 3 32x32 sprites arranged vertiacally then used gfx2GBA to output the image into an array, and in atribute3 of OAM to get it to display right i had to pass 0, 32, or 64 to atribute3.
So i have a bunch of sprites that are different sizes, do i just toss them all in one sprite sheet? If so what order. and how do i index the tiles?
#50339 - Zapf_Bandit - Mon Aug 08, 2005 9:12 am
I personally make different images for each possible width 8,16,32 and 64 and then pack them on top of each other. Keep in mind that if you are only displaying one of these pictures at a time (e.g. an animated sprite) it can be a lot better to keep the same sprite address (attr3) and simply copy different sprite parts to the corresponding memory. Here is an example that shows the way I generally setup my sprite info (16 colour example). In this case there are multiple 64x32 sprite images stacked on top of each other...
// Sprite Information
enum {
BP_SEL,
BP_LEVEL
};
const unsigned BM_SEL = 0;
const unsigned BM_LEVEL = BM_SEL +1;
const unsigned BS_SEL = 1*(4*4);
const unsigned BS_LEVEL = 1*(8*4); // frames*(width*height)
const unsigned BD_SEL = 0;
const unsigned BD_LEVEL = BD_SEL + BS_SEL;
..............
OAM[4*BM_LEVEL + kSpriteY] = ATTR0_COLOR_16 | ATTR0_WIDE;
OAM[4*BM_LEVEL + kSpriteX] = ATTR1_SIZE_64;
OAM[4*BM_LEVEL + kSpriteSrc] = BD_LEVEL | ATTR2_PALETTE(BP_LEVEL);
..............
swiFastCopy( (void*)((u32)levels_gfx + 32*BS_LEVEL*difficulty),
(void*)((u32)SPRITE_GFX + 32*BD_LEVEL),
16*BS_LEVEL);
#50348 - justinGBA - Mon Aug 08, 2005 3:35 pm
Well thats fine and dandy for displaying one sprite, right?
But i will be displaying the player sprite, 32x32, and a bunch of enemy sprites 16x16 and there firepower is 8x8. how can i get all this on the scren at once, since you only have one chunk of memory for sprite tiles, and you can't tell oam what chunk to use for each sprite can you?
#50352 - poslundc - Mon Aug 08, 2005 3:57 pm
justinGBA wrote: |
how can i get all this on the scren at once, since you only have one chunk of memory for sprite tiles, and you can't tell oam what chunk to use for each sprite can you? |
Attribute 2
Dan.
#50360 - justinGBA - Mon Aug 08, 2005 6:39 pm
OK, i some what understand that idea... My question is, is how do i arrange my sprites in the bitmap before converting them. or does it matter? Right now i put them into one vertical strip, 32px X 32px wide. So now i have some sprites that are 16px x 16px wide, do i put them side by side under the 32px X 32px sprites? forming another 32x32 block vertically made up og 16 x 16 blocks?
does that feel right?
#50370 - poslundc - Mon Aug 08, 2005 10:46 pm
That would depend entirely on your converter. I wrote my own, so I can't tell you anything about the one you're using.
Dan.
#50409 - justinGBA - Tue Aug 09, 2005 10:22 am
gfx2gba, i worked it out. Got some sweet sprites on the screen of different sizes. thanks