Stephane-D / SGDK

SGDK - A free and open development kit for the Sega Mega Drive
https://www.patreon.com/SGDK
MIT License
1.73k stars 186 forks source link

Sprite Engine complex animation #92

Open dimiro1 opened 7 years ago

dimiro1 commented 7 years ago

Is it possible set the duration of a single sprite animation with the rescomp utility?

A(5) B(5) C(1)
D(8) E(5) F(5)

As I am understanding, now, it is possible to set only a single time value:

SPRITE mysprite_sprite "sprites/mysprite.png" 6 6 0 5 NONE
Stephane-D commented 7 years ago

Unfortunately right now you can indeed only setup the duration for the whole animation. I need to improve the resource form (using XML probably) to allow that or at least add kind of array support for that specific parameter. What you can eventually in the meantime try is to modify the generated .s file from rescomp (using hand compilation) so you change change duration for each frame but as soon you will modify your resource, the makefile will regenerate the .s file so that is a really convenient solution :-/ A proper Sprite editor with proper XML format would be the solution... I keep the issue open in the meantime...

dimiro1 commented 7 years ago

Thanks for your reply.

For the "array" parameter I am thinking in something like this:

SPRITE mysprite_sprite "sprites/mysprite.png" 6 6 0 "5,5,1|8,5,5" NONE

What do you think?

Stephane-D commented 7 years ago

I would probably do something as usual array format in programming language : [[5,5,1][8,5,5]] without any space obviously as space are used to separate parameters ;)

dimiro1 commented 7 years ago

Do you want to keep retro compatibility? I can see two approaches:

  1. Change the command for SPRITE_ANIMATION or SPRITE_ARRAY
  2. Add an extra parameter at the end of the command.

What do you think?

Stephane-D commented 7 years ago

Of course i want to keep retro compatibility :) If i detect '[' first character then i assume an array otherwise an assume a single value

dimiro1 commented 7 years ago

@Stephane-D Thanks, I am not familiar with the codebase and I am working on OSX, but, I will try to implement it.

Stephane-D commented 7 years ago

Oh you plan to do the code change by yourself ? that would be really handy ! thanks !

dimiro1 commented 7 years ago

I hope to open the PR soon. :)

Stephane-D commented 7 years ago

Cool :) One suggestion about it : if the array does not match the number of expected row/column or is malformed, you may just display a warning about it and use the valid value found for remaining frames.

D0NM commented 9 months ago

I look at the issue from 2017 year ))) We solved the problem in other way. In the game code.

I just want to remind that there is also unused anim->loop in SGDK sprite struct

I mean it is not possible to define it via RESCOMP params, yet.

Stephane-D commented 9 months ago

I look at the issue from 2017 year ))) We solved the problem in other way. In the game code.

I just want to remind that there is also unused anim->loop in SGDK sprite struct

I mean it is not possible to define it via RESCOMP params, yet.

Yeah I realized I had this information not properly used (It could even be used to avoid loop afaik). Need to change that too but the SPRITE resource declaration is already overwhelmed by parameters, I definitely need to update the resource declaration format (for something as JSON for instance)