Troubles with sprites (new version SGDK)
Moderator: Stef
Troubles with sprites (new version SGDK)
Compile by SGDK 1.12
SPR_init(300);
Compile by SGDK 1.2
SPR_init(80, 640, 640); or SPR_init(80, 320, 320); or SPR_init(80, 0, 0); or SPR_init(32, 0, 0); .... etc. :
what am I doing wrong
SPR_init(300);
Compile by SGDK 1.2
SPR_init(80, 640, 640); or SPR_init(80, 320, 320); or SPR_init(80, 0, 0); or SPR_init(32, 0, 0); .... etc. :
what am I doing wrong
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: Troubles with sprites (new version SGDK)
I think you are hitting the 16 hard sprites limit of the new SGDK 1.2, previous allowed 20 VDP sprites by meta sprite, now you are limited to 16 max. It was necessary for some internals tweaks. Honestly I was thinking nobody will use a so large sprite :-p
I guess you need to split in 2 now :-/
I guess you need to split in 2 now :-/
Re: Troubles with sprites (new version SGDK)
before:
ufo.png 176*64
--
SPRITE ufo "ufo.png" 22 8 -1
after:
ufo1.png 88*64
ufo2.png 88*64
--
SPRITE ufo1 "ufo1.png" 11 8 -1
SPRITE ufo2 "ufo2.png" 11 8 -1
may be necessary to split in 4 ?... Very inconveniently turns out. Сumbersome.
ufo.png 176*64
--
SPRITE ufo "ufo.png" 22 8 -1
after:
ufo1.png 88*64
ufo2.png 88*64
--
SPRITE ufo1 "ufo1.png" 11 8 -1
SPRITE ufo2 "ufo2.png" 11 8 -1
may be necessary to split in 4 ?... Very inconveniently turns out. Сumbersome.
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: Troubles with sprites (new version SGDK)
It turns out that your original sprite still fit in the limit : 176*64 could be done in 6*2 = 12 sprites of 32x32 pixels.
So you're below the 16 sprites limit. Are you doing something special with that sprite ??
Can you provide me a simple sample test which replicate the problem ? that would help me in solving this issue
So you're below the 16 sprites limit. Are you doing something special with that sprite ??
Can you provide me a simple sample test which replicate the problem ? that would help me in solving this issue
Re: Troubles with sprites (new version SGDK)
Just adding to scene and changing coordinates.Stef wrote: Are you doing something special with that sprite ??
Code: Select all
int main()
{
SYS_disableInts();
VDP_setScreenWidth320();
VDP_setScreenHeight240();
// JOY_setEventHandler(joyEvent);
zastavka();
init_game();
SYS_enableInts();
while(TRUE)
{
// handleInput();
u32 current = getTimer(0, FALSE);
u32 elapsed = current - previous;
previous = current;
lag += elapsed;
while (lag >= 2000)
{
update_game();
lag -= 2000;
}
SPR_update(sprites, 80);
VDP_waitVSync();
}
return 0;
}
Code: Select all
void init_game()
{
// VDP_resetSprites();
ind = TILE_USERINDEX;
VDP_setVerticalScroll(PLAN_A,0);
VDP_setVerticalScroll(PLAN_B,0);
VDP_clearPlan (PLAN_A,1);
VDP_clearPlan (PLAN_B,1);
SPR_init(16, 0, 0);
VDP_setPalette(PAL0, sky.palette->data);
VDP_setPalette(PAL1, ufo.palette->data);
VDP_setPalette(PAL2, city.palette->data);
VDP_waitVSync();
VDP_drawImageEx(PLAN_B, &sky, TILE_ATTR_FULL(PAL0, FALSE, FALSE, FALSE, ind),0, 0, FALSE, TRUE);
ind += sky.tileset->numTile;
VDP_drawImageEx(PLAN_B, &water, TILE_ATTR_FULL(PAL0, TRUE, FALSE, FALSE, ind),0, 22, FALSE, TRUE);
ind += water.tileset->numTile;
VDP_drawImageEx(PLAN_A, &city, TILE_ATTR_FULL(PAL2, TRUE, FALSE, FALSE, ind),0, 0, FALSE, TRUE);
ind += city.tileset->numTile;
sprites[0] = SPR_addSprite( &ufo , 350, 0, TILE_ATTR(PAL1, FALSE, FALSE, FALSE));
sprites[50] = SPR_addSprite( &plant , 0, 0, TILE_ATTR(PAL1, FALSE, FALSE, FALSE));
// sprites[51] = SPR_addSprite( &plant , 350, 0, TILE_ATTR(PAL1, FALSE, FALSE, TRUE));
// sprites[52] =SPR_addSprite( &plant , 350, 0, TILE_ATTR(PAL1, FALSE, FALSE, TRUE));
u16 i;
for(i=1; i<30; i++)
{
if(i%2==0)sprites[i]=SPR_addSprite( &seed , 350, 0, TILE_ATTR(PAL1, FALSE, FALSE, FALSE));
else sprites[i]=SPR_addSprite( &seed , 350, 0, TILE_ATTR(PAL2, FALSE, FALSE, FALSE));
}
for(i=0; i<32; i++)
{
seedposx[i]=random()%1000;
seedposy[i]=100;
seedposdy[i]=random()%2+1;
}
SND_startPlay_PCM(ME, sizeof(ME), SOUND_RATE_22050, SOUND_PAN_CENTER , 0);
startTimer(0);
previous = getTimer(0, 0);
}
Code: Select all
u32 previous ;
u32 lag = 0;
int planty=400;
int planty1=520;
int planty2=480;
int ufoy=320;
int ufox=650;
u16 state=0;
int mayatnikdx=1;
int mayatnik2=1;
u16 timer;
int seedposx[32];
int seedposy[32];
int seedposdy[32];
void update_game()
{
if(state==0)
{
VDP_setPalette(PAL0, sky.palette->data);
VDP_setPalette(PAL1, ufo.palette->data);
VDP_setPalette(PAL2, city.palette->data);
mayatnikdx+=8;
SPR_setPosition(sprites[0],ufox/2, ufoy/8+(cosFix16(mayatnikdx)>>4));
ufox=ufox-1;
// ufoy=ufoy-1;
if(ufox/2<80)
{
state=1;
timer=400;
}
}
if(state==1)
{
if(timer>0)timer--;
else
{
state=2;
timer=800;
}
u16 i;
for(i=1; i<30; i++)
{
mayatnik2++;
SPR_setPosition(sprites[i], 155+(cosFix16((mayatnik2>>1)+seedposx[i])>>1),seedposy[i] );
seedposy[i]+=seedposdy[i];
if(seedposy[i]>190)
{
seedposy[i]=80;
seedposdy[i]=random()%2+1;
}
}
mayatnikdx+=8;
SPR_setPosition(sprites[0], ufox/2+(sinFix16(mayatnikdx)>>4), ufoy/8+(cosFix16(mayatnikdx)>>4));
}
if(state==2)
{
u16 i;
for(i=1; i<30; i++)
{
if(seedposy[i]<200)
{
mayatnik2++;
seedposy[i]+=seedposdy[i];
SPR_setPosition(sprites[i], 155+(cosFix16((mayatnik2>>1)+seedposx[i])>>1),seedposy[i] );
}
}
mayatnikdx+=8;
SPR_setPosition(sprites[0], ufox/2, ufoy/8+(cosFix16(mayatnikdx)>>4));
ufoy-=2;
ufox--;
if(planty/2>52)
{
planty--;
SPR_setPosition(sprites[50], 110+random()%3, planty/2);
}
if(planty1/2>80)
{
planty1--;
SPR_setPosition(sprites[51], 30+random()%3, planty1/2);
}
if(planty2/2>70)
{
planty2--;
SPR_setPosition(sprites[52], 230+random()%3, planty2/2);
}
if(timer>0)timer--;
else
{
state=3;
VDP_resetSprites();
VDP_clearPlan (PLAN_A,1);
VDP_clearPlan (PLAN_B,1);
VDP_setScrollingMode(HSCROLL_PLANE, VSCROLL_PLANE);
ind = TILE_USERINDEX;
VDP_setPalette(PAL0, mask.palette->data);
VDP_setPalette(PAL1, earth1.palette->data);
VDP_drawImageEx(PLAN_A, &mask, TILE_ATTR_FULL(PAL0, FALSE, FALSE, FALSE, ind),2, 8, FALSE, TRUE);
ind += mask.tileset->numTile;
VDP_drawImageEx(PLAN_B, &earth1, TILE_ATTR_FULL(PAL1, FALSE, FALSE, FALSE, ind),2, 8, FALSE, TRUE);
ind += earth1.tileset->numTile;
}
}
if(state==3)
{
}
if(state<=2) wave_effect();
}
Re: Troubles with sprites (new version SGDK)
Hi Alko,
Nice to see another demoscene dude around here
Maybe you could share the whole archive of your demo (even privately).
It's not like someone is going to steal your source code
Nice to see another demoscene dude around here
Can you check if this function is still asking parameters this way ?SPR_update(sprites, 80);
Maybe you could share the whole archive of your demo (even privately).
It's not like someone is going to steal your source code
640 polygons are enough for everyone.
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: Troubles with sprites (new version SGDK)
Oh sorry i forgot to reply to your last post Alko, in fact i missed it... As astrofa said, the API changed a bit and SPR_update() doesn't take any parameter now. Still that shouldn't be the problem here, I will try to replicate your issue.
Re: Troubles with sprites (new version SGDK)
Reading your code, I realized one thing. There is an issue in the new version of sgdk, Stef will look at it.
The sprite engine have some problems when you use meta-sprite outside of the screen.
you init your sprite at 350.
So, you can add this :
I think it will solve your problem.
you can see here :
viewtopic.php?f=19&t=2457
The sprite engine have some problems when you use meta-sprite outside of the screen.
you init your sprite at 350.
So, you can add this :
Code: Select all
sprites[0] = SPR_addSprite( &ufo , 350, 0, TILE_ATTR(PAL1, FALSE, FALSE, FALSE));
SPR_setVisibility( sprites[0], AUTO_FAST);
you can see here :
viewtopic.php?f=19&t=2457
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: Troubles with sprites (new version SGDK)
Fixed in my WIP, i plan to do a quick release soon, hoping it will the issue alko experienced here.
Re: Troubles with sprites (new version SGDK)
I'm also ajusting to the changes in the sprite engine. I still have some things to fix with the code I've got ,
mostly "incompatible types in assignment" errors and some declaration errors.
I still have a lot to learn when it comes to programming but it helps that I'm really interested in the Mega Drive/Genesis.
It compels me to learn more and adapt. I'm focused on it since it's my only console ,I only have it and the PC.
I'm a very good artist so I prefer to get the graphics working first. But now its been a bit of a while since I worked on this code
so it would be great to have some pointers on how to work with it. I know about the documentation but I'm not sure about some
of the numbers like with the SPR_init() function which numbers would be appropriate there.
mostly "incompatible types in assignment" errors and some declaration errors.
I still have a lot to learn when it comes to programming but it helps that I'm really interested in the Mega Drive/Genesis.
It compels me to learn more and adapt. I'm focused on it since it's my only console ,I only have it and the PC.
I'm a very good artist so I prefer to get the graphics working first. But now its been a bit of a while since I worked on this code
so it would be great to have some pointers on how to work with it. I know about the documentation but I'm not sure about some
of the numbers like with the SPR_init() function which numbers would be appropriate there.
Re: Troubles with sprites (new version SGDK)
Ok. Today I will share sourceastrofra wrote: Maybe you could share the whole archive of your demo (even privately).
Re: Troubles with sprites (new version SGDK)
gooddub wrote: I think it will solve your problem.
I check out this method later.
Re: Troubles with sprites (new version SGDK)
I keep getting incompatible types in assignment errors when using SPR_addSprite on the latest version of SGDK.
Can someone help fix that?
Can someone help fix that?
Re: Troubles with sprites (new version SGDK)
Post code and error log?
Maybe confusing Sprite with SpriteDefinition or need to pass a reference like &mySpriteDef.
Maybe confusing Sprite with SpriteDefinition or need to pass a reference like &mySpriteDef.