Sprite issue with first SGDK project

SGDK only sub forum

Moderator: Stef

Post Reply
Bulldoggamer
Newbie
Posts: 2
Joined: Sat Sep 26, 2015 3:54 pm

Sprite issue with first SGDK project

Post by Bulldoggamer » Thu Nov 26, 2015 2:40 am

Okay, so, I don’t have anything yet, but, I do have what I think is something like 50% of two games lol.

Let me start with this one, that’s bugging me to death.
First I tried to load sprites.
Image

The sprite resources should be declared in resources file like this, right?

Image

“filepath” width(of one frame), height(of one frame), some_number(cannot get what is it), amount of total sprites.
If you look at my code, sprite.c and sprite.h, it provides ability to load sprite and manipulate it. As I understand it, as a super amateur, I just need to send resourceId (e.g. SPR_Viking1) when you create a sprite.
As I understand for the sprite resource, every frame should be the same size. So, in this instance, it should be 16 x 32 pixels….right? Unfortunately, lol, the size is 128 x 800. A width of 128 which is not correct, because the frame width is 16 pixels and totals frames in row is 7. I think it should be 112 width. But if it is 112 width then we lost part of attacking Viking, and really, who wants a Viking that can’t pillage?

Image

Any help on that?

Here’s another attempt where I created a file with cut attacking Viking viking1.png with the following settings

Image

Indexed color and 8bit channel
When I try to compile it, it crashes. With rescomp.EXE. I tried to use different image type, but, no dice. Without viking1.png resource it compiles fine.
These were the problems with assets. I’m a total noob here. Any help would be killer.

User avatar
Stef
Very interested
Posts: 2781
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Sprite issue with first SGDK project

Post by Stef » Thu Nov 26, 2015 11:33 pm

The rescomp.txt give you description of the resource file :
https://github.com/Stephane-D/SGDK/blob ... escomp.txt

And here is the description of SPRITE resource type :
SPRITE
------
Take an image as input and transform it in SGDK SpriteDefinition structure.
SpriteDefinition is used to draw, animate and manage sprites, it internally contains severals TileSet, Palette and Animation structures.

Syntax:
SPRITE name img_file width heigth [compression [time [collision]]]

name name of the output SpriteDefinition structure
img_file path of the input image file (should be 8bpp .bmp or .png)
width width of a single sprite frame in tile (should be <= 20)
heigth heigth of a single sprite frame in tile (should be <= 20)
compression compression type (use unpackSprite(..) to unpack)
-1 = AUTO (use best compression scheme)
0 = NONE (no compression)
1 = APLIB (aplib library)
2 = LZKN (Konami LZW compression, disable for legal reason)
3 = RLE (4bits RLE compression)
4 = RLE MAP (tilemap adapted RLE)
time display frame time in 1/60 of second (time between each animation frame)
collision collision type: CIRCLE, BOX or NONE (BOX by default)

Some informations about how SpriteDefinition is generated from the input image:
- input image dimension is aligned on tile (multiple of 8).
- input image is a grid where each cell represents a single sprite frame and where a row define a complete sprite animation.
- cell size (frame size) = width * height (in tile)
- a frame can be composed of several internal VDP sprites (max = 20) if width or height are > 4.
- rescomp detect flipped frame to avoid redundant sprite tiles.
- rescomp detect empty frame at end of animation row to not store empty frame data.
- rescomp detect frame copy inside an animation to generate the according animation sequence.
- collision bounds are calculated by using 75% of the original sprite frame.
- In future rescomp could detect empty tiles in a frame to optimize the internal VDP sprite usage (and also improve the collision box).
That may be a nice future addition :)
Given your sprite sheet, you should enlarge your cell to the largest frame cell (for instance 32x32 or 24x32 pixels).
Also the image format should be a PNG file where ideally only 15 colors are used + 1 transparent color (which should be at position 0 in the palette).

User avatar
ronin68k
Interested
Posts: 25
Joined: Mon Nov 02, 2015 5:28 am
Location: Krasnodar, Russia

Re: Sprite issue with first SGDK project

Post by ronin68k » Sun Dec 24, 2017 9:00 pm

Hi guys! I have a question about the sprite engine.
The problem is when i draw the sprite, sprite engine does not crop blank tiles and draws the sprite in VDP all the way, so it takes lot of VDP space.
Do i need to chunk the sprite myself or there is a way sprite engine can do it automatically? Thank you.

Image

Boyfinn
Interested
Posts: 49
Joined: Sat Aug 08, 2015 12:12 pm
Location: Lapland, Finland

Re: Sprite issue with first SGDK project

Post by Boyfinn » Mon Dec 25, 2017 6:53 pm

Shouldn't rescomp automatically copy identical tiles?

User avatar
Stef
Very interested
Posts: 2781
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Sprite issue with first SGDK project

Post by Stef » Tue Dec 26, 2017 10:00 am

That is a know issue, currently rescomp doesn't "optimize" sprite cutting, that is something i plan to work out soon as it's a problem both for VRAM occupation and DMA bandwidth usage.

User avatar
Sik
Very interested
Posts: 714
Joined: Thu Apr 10, 2008 3:03 pm
Contact:

Re: Sprite issue with first SGDK project

Post by Sik » Tue Dec 26, 2017 5:34 pm

Yeah, the problem is that it's well known to not be trivial. And now that we're aware that Virgin had a tool that could detect repeated parts across sprites and with flipping, I'm not sure anybody here will want to settle for less than that (shame we don't have the source code to that tool in particular so we need to figure it out again on our own).
Sik is pronounced as "seek", not as "sick".

User avatar
ronin68k
Interested
Posts: 25
Joined: Mon Nov 02, 2015 5:28 am
Location: Krasnodar, Russia

Re: Sprite issue with first SGDK project

Post by ronin68k » Thu Dec 28, 2017 12:34 pm

wow... :D well, good luck with the solving of this problem, guys! I'll be waiting for updates. Thanks again!

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests