How put my sprites into new SGDK project?

SGDK only sub forum

Moderator: Stef

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

How put my sprites into new SGDK project?

Post by alko »

Have a set of sprites 48 * 48, located in different BMP files.
How to import them into my project?
And also to create animations and displaying multiple sprites on different layers.
For compilation I set up CodeBlocks.
Last edited by alko on Thu Nov 19, 2015 5:22 pm, edited 3 times in total.
Image
Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: How put my sprites into new SGDK project?

Post by Stef »

Get a look on the included "sprite" sample (in sample SGDK folder). You will see a gfx.res file in 'res' folder which define the sprites resources.
You can have more informations about how to define resources with rescomp.txt file (in 'bin' folder this time).
alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Re: How put my sprites into new SGDK project?

Post by alko »

violated palette indexes.
And instead of a transparent color - white color. :oops:

Image

Image

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

Re: How put my sprites into new SGDK project?

Post by Stef »

Can you edit the palette with Paint.NET ? I guess your palette is not correctly set, you can arrange it with gimp 2 for instance.
The transparent color should be correctly handled by rescomp but maybe i've a bug here, i will check that !
matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Re: How put my sprites into new SGDK project?

Post by matteus »

I've had problems with transparency I don't think they work :/
alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Re: How put my sprites into new SGDK project?

Post by alko »

Transparent color should be first in palette indexes. :oops:

By the way, sample with sonic sprites unoptimized.
Example Violence Pingouin better in terms of drawing sprites\tiles, but source more difficult for a beginner.
Image
Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: How put my sprites into new SGDK project?

Post by Stef »

Definitely the way the sprite engine work is not optimized currently but the next SGDK version will include major changes to make it faster and more efficient... I will look into that transparent color issue, if you look at the sonic sample, the transparent color is not at index 0 but it's referenced as the transparent color in the PNG file an rescomp does handle it correctly :)
alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Re: How put my sprites into new SGDK project?

Post by alko »

I'm trying display second sprite
occurs conflict of palettes

Code: Select all

 SPR_initSprite(&sprites[0], &x_sprite, fix32ToInt(posx - camposx), fix32ToInt(posy - camposy), TILE_ATTR(PAL2, TRUE, FALSE, FALSE));
 SPR_update(sprites, 1);

 SPR_initSprite(&sprites[1], &ball_sprite, fix32ToInt(posx - camposx), 10, TILE_ATTR(PAL2, TRUE, FALSE, FALSE));
 SPR_update(sprites, 2);

Code: Select all

SPRITE ball_sprite "ball.png" 4 4 -1
SPRITE x_sprite  "x1.png" 8 4 -1
Image

Image
Image
Image
Ralakimus
Interested
Posts: 19
Joined: Mon Nov 30, 2015 12:38 pm

Re: How put my sprites into new SGDK project?

Post by Ralakimus »

alko wrote:

Code: Select all

SPR_initSprite(&sprites[1], &ball_sprite, fix32ToInt(posx - camposx), 10, TILE_ATTR( ---->PAL2<----, TRUE, FALSE, FALSE));
 SPR_update(sprites, 2);
Check the arrows surrounding the "PAL2" text. It's using the same palette line as the first sprite, so just change it to the appropriate palette file. (Unless it was intended for both sprites to share it, in that case, your sprite needs to be fixed to use the proper palette entries).
alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Re: How put my sprites into new SGDK project?

Post by alko »

Image

how to fill PAL3 indices of sprite "ball" ?
Image
alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Re: How put my sprites into new SGDK project?

Post by alko »

Bat tiles climb on background (320*240).

Image

necessary move bat tiles in VDP RAM
Image

and incomprehensible where did this blue color.
in color table it is not present
Image
Image
Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: How put my sprites into new SGDK project?

Post by Stef »

Color index 0 is transparent so you always have to take care of that, the blue color come from the background color (which is set to palette 0 index 0 by default).
And you can fill palette entry with the classic VDP_setPalette(..) method.
For instance for your ball sprite :

Code: Select all

VDP_setPalette(PAL3, ball_sprite.palette->data);
alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Re: How put my sprites into new SGDK project?

Post by alko »

how to display an array sprites ?
that's right ?

Code: Select all

int i;
for(i=0;i<150;i++){
SPR_initSprite(&sprites[i], &rain_sprite, i, i, TILE_ATTR(PAL3, TRUE, FALSE, FALSE));
SPR_update(sprites, i+1);
 }
    
Image
Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: How put my sprites into new SGDK project?

Post by Stef »

alko wrote:how to display an array sprites ?
that's right ?

Code: Select all

int i;
for(i=0;i<150;i++){
SPR_initSprite(&sprites[i], &rain_sprite, i, i, TILE_ATTR(PAL3, TRUE, FALSE, FALSE));
SPR_update(sprites, i+1);
 }
    

Almost ;)

Code: Select all

int i;

for(i=0;i<80;i++)
	SPR_initSprite(&sprites[i], &rain_sprite, i, i, TILE_ATTR(PAL3, TRUE, FALSE, FALSE));
	
SPR_update(sprites, 80);
Note than Megadrive support only to display 80 simultaneous sprites at max and 20 on the same line !
alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Re: How put my sprites into new SGDK project?

Post by alko »

That is what is there for now:

Image

I want to add decorations.
but how to avoid the restriction of sprites?
to be seen "blood" particles and background decorations (for example, chain and scrolling fog ).
Image

P.S.: PC-version https://youtu.be/96-FxYu_Fr0?list=PLvUf ... xhG17X6zNS
Image
Post Reply