#38124 - demitri - Tue Mar 22, 2005 2:06 pm
Hey everybody,
I've searched the forum for a similar problem and cannot find an answer. Maybe you guys can help me out.
Here's my problem:
I'm and trying to display a sprite which is WIDE SIZE_32. for the first tile in the set i can display it fine. however, if i try and display the next tile in the set, it diplays as a 32X64 instead of a 16X32. it changes automatically and i cannot figure out why.
any help you can give is appreciated.
thanks,
Demitri
#38126 - Lord Graga - Tue Mar 22, 2005 3:42 pm
Your #defines are fucked up. Get some other ones. Read Cowbite or GBATEK for the real bits.
#38128 - demitri - Tue Mar 22, 2005 4:15 pm
I don't think it's my define's
Because I can display the sprites properly if i do not set the Rotation Flag. it's only after i set the flag that the sprites change size. I can View the sprites in VBA OEM viewer and the first tile has the correct dimensions, but the others do not.
-Demitri
#38133 - DiscoStew - Tue Mar 22, 2005 6:40 pm
demitri wrote: |
I can View the sprites in VBA OEM viewer and the first tile has the correct dimensions, but the others do not. |
First tile? You mean the upper-left tile that is being displayed in the sprite? Of course it would show correctly, whether you are in 1D or 2D sprite mode, cause that is the way the GBA operates. If it isn't your defines, then maybe it could be more likely how you are setting the attributes for the sprites. If you say you are setting the Rotation Flag on, are you preserving what was originally in that attribute? If not, then everything for that attribute gets erased, and only the Rotation Flag is set.
Perhaps a little code would brighten things up for us who are trying to help you fix the problem. Sometimes words cannot totally describe what is happening in your program.
_________________
DS - It's all about DiscoStew
#38134 - demitri - Tue Mar 22, 2005 6:56 pm
alrighty, Here's my Initsprite function which dictates all the attributes of any given sprite.
Code: |
void InitSprite(int num, int x, int y, int type, int size,int tileIndex, int needRotScale, int sdouble)
{
unsigned int sprite_size =0;
mysprites[num].alive = 1;
mysprites[num].size = size;
mysprites[num].x = x;
mysprites[num].y = y;
mysprites[num].rotate = ROTATION_FLAG;
mysprites[num].scale = 1 << 8;
mysprites[num].angle = 0;
switch (size)
{
case 8: sprite_size = SIZE_8; break;
case 16: sprite_size = SIZE_16; break;
case 32: sprite_size = SIZE_32; break;
case 64: sprite_size = SIZE_64; break;
}
sprites[num].attribute2 = (tileIndex +512 );
if( needRotScale == 1 && sdouble == 1)
{
sprites[num].attribute0 = y | COLOR_256 | type | SIZE_DOUBLE | ROTATION_FLAG;
sprites[num].attribute1 = x | sprite_size | ROTDATA(tileIndex + 512 + num);
}else if(needRotScale ==1 && sdouble == 0){
sprites[num].attribute0 = y | COLOR_256 | type| ROTATION_FLAG;
sprites[num].attribute1 = x | sprite_size | ROTDATA(tileIndex + 512 + num);
}else if(needRotScale == 0)
{
sprites[num].attribute0 = y | COLOR_256 | type;
sprites[num].attribute1 = x | sprite_size;
}
}
|
I have used rotating sprites in other parts of my code, which work fine. but those items are 32 & 64 pixel squares. It is only in my current section whereby i'm trying to used WIDE/TALL 32 sized scaled sprites that i run into problems.
Thanks
-Demitri
#38136 - DiscoStew - Tue Mar 22, 2005 8:46 pm
Code: |
ROTDATA(tileIndex + 512 + num); |
EEEEKKKKKKK!!!!!! I believe that may be your problem.
The ROTDATA macro is meant for specifying which of the 32 slots of rotation data would be used on this sprite, not the tile index that is used in Attribute2. In order to take advantage of Sprite Rotation, you'll need to know how it is set up, and how the GBA processes it. I recommend looking through Cearn's tutorials found here. If the tutorial gets confusing (as it had for me the first time), just download the source code for the app, and take a look at it. If you know how a matrix works, then you should have no problem using it.
_________________
DS - It's all about DiscoStew
#38185 - demitri - Wed Mar 23, 2005 7:35 pm
hahah... nice eeekk... anyways,
I fixed the crazy (512 + tileIndex _ num) thing, and it's now works beautifully! Thanks sooooo much. I swear i saw something similar to it done elsewhere... but regardless, i won't blame anyone else for what is obviously an oversight on my behalf. So thanks for your help!
-Demitri.