Page 1 of 2

about sprites

Posted: Sun Nov 06, 2016 5:09 pm
by alko
SGDK previous version.
How to clear all sprites ?
And second question - Is possible to shift all sprites simultaneously? Or need to change coordinates of each sprite one by one ?

Re: about sprites

Posted: Mon Nov 07, 2016 9:43 am
by Stef
If you are using the embedded sprite engine, just call SPR_clear() to quickly hide all sprite (calling back SPR_update display them again).
You can also use the lower level method VDP_clearSprites() then VDP_updateSprites(1, ..) to hide displayed sprites.
There is no way to add global sprite shift, you indeed need to move all sprite.

Re: about sprites

Posted: Mon Nov 07, 2016 8:24 pm
by alko
Stef wrote:If you are using the embedded sprite engine, just call SPR_clear() to quickly hide all sprite (calling back SPR_update display them again).

sprites remain unchanged.

Re: about sprites

Posted: Mon Nov 07, 2016 9:06 pm
by Stef
Are you using last SGDK ? I just tested ad it works for me.

Re: about sprites

Posted: Tue Nov 08, 2016 7:16 am
by alko
alko wrote:SGDK previous version.

Re: about sprites

Posted: Tue Nov 08, 2016 4:46 pm
by Stef
Oh i missed it... so then i'm almost certain it was a bug in the previous version unfortunately :-/
Good reasons to stay on previous version ?

Re: about sprites

Posted: Tue Nov 08, 2016 5:46 pm
by alko
Stef wrote:Good reasons to stay on previous version ?
The project is already rather large.
I can not upgrade it for the new version.

Re: about sprites

Posted: Tue Nov 08, 2016 8:49 pm
by Stef
Maybe you can try to just upgrade the sprite.c / sprite.h files if they don't conflict with others.

Re: about sprites

Posted: Sun Nov 13, 2016 4:58 pm
by alko
I must rebuild rescomp?

Image

Re: about sprites

Posted: Sun Nov 13, 2016 9:53 pm
by Stef
You were using version SGDK 1.12 ? i think you may need some changes from later rescomp, but then you will meet issues about the compression schemes which changed as well :-/ In fact i think you cannot partially update SGDK as i told you, you will meet some interaction issues.

Re: about sprites

Posted: Sun Dec 18, 2016 4:19 pm
by alko

Code: Select all


Sprite* sprites[80];
....

SPR_init(32, 256, 256);
    ......

  if(initspider==0)
    {
        VDP_setPalette(PAL2, spider1.palette->data);
        ind = TILE_USERINDEX;
        VDP_drawImageEx(PLAN_A, &spider1, TILE_ATTR_FULL(PAL2, FALSE, FALSE, FALSE, ind), 8,8, FALSE, TRUE);
        ind += spider1.tileset->numTile;



        sprites[0] = SPR_addSprite(&leg1, 100, 42, TILE_ATTR(PAL2, FALSE, FALSE, FALSE));
        sprites[1] = SPR_addSprite(&leg2, 83, 42, TILE_ATTR(PAL2, FALSE, FALSE, FALSE));
        sprites[3] = SPR_addSprite(&leg3, 74, 107, TILE_ATTR(PAL2, FALSE, FALSE, FALSE));
        sprites[4] = SPR_addSprite(&leg4, 115, 115, TILE_ATTR(PAL2, FALSE, FALSE, FALSE));
        sprites[5] = SPR_addSprite(&jaw, 138, 127, TILE_ATTR(PAL2, FALSE, FALSE, FALSE));

        sprites[6] = SPR_addSprite(&leg1, 175, 41, TILE_ATTR(PAL2, TRUE, FALSE, TRUE));
        sprites[7] = SPR_addSprite(&leg2, 177, 42, TILE_ATTR(PAL2, TRUE, FALSE, TRUE));
        sprites[8] = SPR_addSprite(&leg3, 178, 107, TILE_ATTR(PAL2, TRUE, FALSE, TRUE));
        initspider=1;
       ....
       
        SPR_update(sprites, 80);
        
        
    }

why do not display sprites?

Image

Re: about sprites

Posted: Mon Dec 19, 2016 9:41 am
by Stef
You are probably hitting the sprite limit per scanline. Currently rescomp does not optimize the sprite tiles so when you use big sprites as here you quickly reach the scanline sprite limitation. I should rewrite the sprite tile decomposition part but in fact the optimization process involved is not really trivial. You have to find a good balance between the number of VDP sprite and the scanline limit...

Re: about sprites

Posted: Mon Dec 19, 2016 4:35 pm
by alko
Stef wrote:You are probably hitting the sprite limit per scanline.

oh... you're right
I'm overestimated capabilities of the sprite-generator

Re: about sprites

Posted: Tue Dec 20, 2016 4:09 pm
by Hik
I used a for loop the other day to draw the same sprite over and over in a horizontal line
and found out that the line of sprites (each one 8x8 pixels) only covered 1/3rd of the screen.

Which made me think I might have to do the shooting differently than drawing a line of sprites.
I realized that other demos and games had lots of sprites going in curves so maybe there's that
way around this? Could the sprites be drawn on another vertical line yet look just about the same?

Re: about sprites

Posted: Wed Dec 21, 2016 10:31 am
by cero
The limit is 20 sprites per line (in the default 320px mode), how much area it covers depends on the sprite size. So use larger sprites and you can cover the entire screen.