Page 1 of 2
How put my sprites into new SGDK project?
Posted: Thu Nov 19, 2015 4:49 pm
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.
Re: How put my sprites into new SGDK project?
Posted: Thu Nov 19, 2015 8:40 pm
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).
Re: How put my sprites into new SGDK project?
Posted: Tue Nov 24, 2015 10:46 pm
by alko
Re: How put my sprites into new SGDK project?
Posted: Tue Nov 24, 2015 11:04 pm
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 !
Re: How put my sprites into new SGDK project?
Posted: Thu Nov 26, 2015 10:41 pm
by matteus
I've had problems with transparency I don't think they work :/
Re: How put my sprites into new SGDK project?
Posted: Fri Nov 27, 2015 4:15 pm
by alko
Transparent color should be first in palette indexes.
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.
Re: How put my sprites into new SGDK project?
Posted: Fri Nov 27, 2015 9:53 pm
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

Re: How put my sprites into new SGDK project?
Posted: Mon Nov 30, 2015 3:04 pm
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

Re: How put my sprites into new SGDK project?
Posted: Tue Dec 01, 2015 6:52 pm
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).
Re: How put my sprites into new SGDK project?
Posted: Wed Dec 02, 2015 10:16 am
by alko
how to fill PAL3 indices of sprite "ball" ?
Re: How put my sprites into new SGDK project?
Posted: Wed Dec 02, 2015 12:20 pm
by alko
Bat tiles climb on background (320*240).
necessary move bat tiles in VDP RAM
and incomprehensible where did this blue color.
in color table it is not present

Re: How put my sprites into new SGDK project?
Posted: Wed Dec 02, 2015 2:00 pm
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);
Re: How put my sprites into new SGDK project?
Posted: Thu Dec 03, 2015 10:20 am
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);
}
Re: How put my sprites into new SGDK project?
Posted: Thu Dec 03, 2015 10:34 am
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 !
Re: How put my sprites into new SGDK project?
Posted: Sat Dec 05, 2015 9:42 am
by alko
That is what is there for now:
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 ).
P.S.: PC-version https://youtu.be/96-FxYu_Fr0?list=PLvUf ... xhG17X6zNS