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 » Sun Nov 06, 2016 5:09 pm

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 » Mon Nov 07, 2016 9:43 am

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 » Mon Nov 07, 2016 8:24 pm

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 » Mon Nov 07, 2016 9:06 pm

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 » Tue Nov 08, 2016 7:16 am

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 » Tue Nov 08, 2016 4:46 pm

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 » Tue Nov 08, 2016 5:46 pm

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 » Tue Nov 08, 2016 8:49 pm

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 » Sun Nov 13, 2016 4:58 pm

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 » Sun Nov 13, 2016 9:53 pm

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 » Sun Dec 18, 2016 4:19 pm

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 » Mon Dec 19, 2016 9:41 am

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 » Mon Dec 19, 2016 4:35 pm

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 » Tue Dec 20, 2016 4:09 pm

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: 338
Joined: Mon Nov 30, 2015 1:55 pm

Re: about sprites

Post by cero » Wed Dec 21, 2016 10:31 am

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