about sprites

SGDK only sub forum

Moderator: Stef

alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

about sprites

Post 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 ?
Image
Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: about sprites

Post 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.
alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Re: about sprites

Post 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.
Image
Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: about sprites

Post by Stef »

Are you using last SGDK ? I just tested ad it works for me.
alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Re: about sprites

Post by alko »

alko wrote:SGDK previous version.
Image
Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: about sprites

Post 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 ?
alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Re: about sprites

Post 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.
Image
Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: about sprites

Post by Stef »

Maybe you can try to just upgrade the sprite.c / sprite.h files if they don't conflict with others.
alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Re: about sprites

Post by alko »

I must rebuild rescomp?

Image
Image
Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: about sprites

Post 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.
alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Re: about sprites

Post 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
Image
Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: about sprites

Post 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...
alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Re: about sprites

Post 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
Image
Hik
Very interested
Posts: 68
Joined: Thu Jul 30, 2015 11:39 pm
Location: Iceland

Re: about sprites

Post 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?
cero
Very interested
Posts: 340
Joined: Mon Nov 30, 2015 1:55 pm

Re: about sprites

Post 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.
Post Reply