Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linked sprite support, custom MovingSprite light sprites #2753

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

Vankata453
Copy link
Member

@Vankata453 Vankata453 commented Jan 30, 2024

Custom light sprites can now be added to all objects, which inherit MovingSprite. Setting a custom color for the light sprite is also possible, as long as the object is not designed to use foreign color values (for example, from an option).

To add a light sprite with an RGB color of 0.5, 0.2, 0.25, in a .sprite file:

(linked-sprites
  (light "path/to/light/sprite" 0.5 0.2 0.25)
)

Keep in mind that specifying color values is optional. The entry can also end after specifying the file.

Additionally:

  • Objects which utilize more than 1 sprite are now able to get the files of their additional sprites from the main one's linked-sprites list (the same block where light sprites can also be added, as shown above). This allows for expanded sprite customization for objects.

To add linked sprites, in a .sprite file:

(linked-sprites
  (key "path/to/sprite")
  (key2 "another/sprite/file")
)

Linked sprites can be added under sprite actions, too. If a sprite with the same key is found in the general linked sprites block and the action-specific one, the sprite specified by the action will be prioritized, thus overriding the default linked sprite file.

Sprites, which the specific object does not support, will be ignored.

  • Sprite actions now support the flip-offset property, which determines how much the sprite should be vertically offset when flipped vertically.

Objects which utilize more than 1 sprite now get the files of their additional sprites from the main one's "linked-sprites" list.

This allows for expanded sprite customization for objects.
Custom lightsprites can now be added to all objects, which inherit `MovingSprite`.

Setting a custom color for the lightsprite is also possible, as long as the object is not designed to use foreign color values (for example, from an option).
@mrkubax10 mrkubax10 added type:feature category:code status:needs-review Work needs to be reviewed by other people labels Jan 30, 2024
@Rusty-Box
Copy link
Member

Do the light sprites work per action or is it one for all?

@Vankata453
Copy link
Member Author

Do the light sprites work per action or is it one for all?

One for all, currently. I think per-action could be done, though.

@Rusty-Box
Copy link
Member

One for all, currently. I think per-action could be done, though.

That would be nice to have for sure

@Vankata453
Copy link
Member Author

One for all, currently. I think per-action could be done, though.

I'm thinking it could be done by having the same block available in action, and if a sprite with the same key as in the global block is available, then prioritize the one of the action.

Linked sprites can now be added to sprite actions too. If a sprite with the same key is found in the general linked sprites block and the action-specific one, the sprite specified by the action will be prioritized, thus overriding the default linked sprite file.
@MatusGuy
Copy link
Member

What was this trying to fix?

@Vankata453
Copy link
Member Author

What was this trying to fix?

Hardcoded sprites.

@Rusty-Box
Copy link
Member

@Vankata453 My brain explodes by trying to form this words so I'll do it like this. Can I:

  • Make a light .sprite file with 2+ actions
  • Link that .sprite file to the object's .sprite file
  • Assign individual actions of light sprite to each action of the object .sprite if needed

The way I originally was hoping we could achieve that was through a special tag within an action.
Here is an example Dive Mine.sprite file using the theoretical ([key name]-action "[action name]") tag:

 (action
  (name "left")
  (fps 12.0)
  (hitbox 14 19 32 32)
  (ticking-glow-action "idle")
  (images "left-0.png"
          "left-1.png"
          "left-2.png"
          "left-3.png"
		  "left-4.png"
		  "left-5.png"
		  "left-6.png"
		  "left-7.png"
		  "left-8.png"
		  "left-9.png"
		  "left-10.png"
		  "left-11.png"))

 (action
  (name "right")
  (fps 12.0)
  (hitbox 14 19 32 32)
  (ticking-glow-action "idle")
  (mirror-action "left"))
 
 (action
  (name "iced-left")
  (hitbox 5 8 32 32)
  (ticking-glow-action "idle")
  (images "left-0.png"))
 
 (action
  (name "iced-right")
  (hitbox 5 8 32 32)
  (ticking-glow-action "idle")
  (mirror-action "iced-left"))

 (action
  (name "ticking-left")
  (fps 15.0)
  (hitbox 14 19 32 32)
  (ticking-glow-action "ticking")
  (images "ticking-0.png"
          "ticking-1.png"
          "ticking-2.png"
          "ticking-3.png"
          "ticking-4.png"
		  "ticking-5.png"
		  "ticking-6.png"
		  "ticking-7.png"
		  "ticking-8.png"
		  "ticking-9.png"))

 
 (action
  (name "ticking-right")
  (fps 15.0)
  (hitbox 14 19 32 32)
  (ticking-glow-action "ticking")
  (mirror-action "ticking-left"))

  (linked-sprites
    (ticking-glow "images/creatures/dive_mine/ticking_glow/ticking_glow.sprite")
  )
)

The way the tag would work is that it will check for action names within the linked sprite file (in this case dive_mine/ticking_glow/ticking_glow.sprite), i.e. "idle" and "ticking".

@Vankata453
Copy link
Member Author

@Rusty-Box Action-specific linked-sprites are already supported, so what I believe only needs to be done to support this is to be able to link sprites with custom default actions.

I modified your example, so by default it globally (for all actions) links the ticking-glow sprite with the action idle (since most actions seem to use it). Since only the last two actions use the ticking action from the sprite, it's declared again in a new linked-sprites block inside of them, with the same name (thus it will override the global ticking-glow linked sprite, which has the idle action).

At the end, the modified example looks like this:

 (action
  (name "left")
  (fps 12.0)
  (hitbox 14 19 32 32)
  (images "left-0.png"
          "left-1.png"
          "left-2.png"
          "left-3.png"
		  "left-4.png"
		  "left-5.png"
		  "left-6.png"
		  "left-7.png"
		  "left-8.png"
		  "left-9.png"
		  "left-10.png"
		  "left-11.png"))

 (action
  (name "right")
  (fps 12.0)
  (hitbox 14 19 32 32)
  (mirror-action "left"))
 
 (action
  (name "iced-left")
  (hitbox 5 8 32 32)
  (images "left-0.png"))
 
 (action
  (name "iced-right")
  (hitbox 5 8 32 32)
  (mirror-action "iced-left"))

 (action
  (name "ticking-left")
  (fps 15.0)
  (hitbox 14 19 32 32)
  (linked-sprites
    (ticking-glow "images/creatures/dive_mine/ticking_glow/ticking_glow.sprite" "ticking")
  )
  (images "ticking-0.png"
          "ticking-1.png"
          "ticking-2.png"
          "ticking-3.png"
          "ticking-4.png"
		  "ticking-5.png"
		  "ticking-6.png"
		  "ticking-7.png"
		  "ticking-8.png"
		  "ticking-9.png"))

 
 (action
  (name "ticking-right")
  (fps 15.0)
  (hitbox 14 19 32 32)
  (linked-sprites
    (ticking-glow "images/creatures/dive_mine/ticking_glow/ticking_glow.sprite" "ticking")
  )
  (mirror-action "ticking-left"))

 (linked-sprites
   (ticking-glow "images/creatures/dive_mine/ticking_glow/ticking_glow.sprite" "idle")
 )

@Rusty-Box
Copy link
Member

@Rusty-Box Action-specific linked-sprites are already supported, so what I believe only needs to be done to support this is to be able to link sprites with custom default actions.

Wait but Dive Mine's glow never changes. Rather is disappears when it should begins playing the ticking action, as of now. Is there just no way to define that right now? I'm so confused

@Vankata453
Copy link
Member Author

Wait but Dive Mine's glow never changes. Rather is disappears when it should begins playing the ticking action, as of now. Is there just no way to define that right now? I'm so confused

As I mentioned in the beginning, it still has to be done, I just offered a way it could work.

@Rusty-Box
Copy link
Member

Okay. Good to know. I thought I was going crazy here 😅
In that case I guess my only note would be that I feel like my proposal looks a bit better in terms of readbilty and having to type less but I ain't a coder so I don't wanna pretend I know better. Atleast I know now that I wasn't crazy, so that's nice :]

@Vankata453
Copy link
Member Author

Vankata453 commented Mar 13, 2024

May be better in terms of readability, but would be more of a pain to implement. :D

(Oh, and this approach is also way more flexible, since you can also change the whole sprite, not just the action.)

@Rusty-Box
Copy link
Member

Is it just me or is it not working? I updated Dive Mine's sprite file to look like you showed in this example here but it doesn't seem to work. The light keeps disapearing when you approach Dive Mine instead of changing the action of the linked sprite. Am I doing something wrong here?

@Rusty-Box
Copy link
Member

Also the candle light doesn't seem to be rendered as a lightmap since you get a black box when you place it

@Rusty-Box
Copy link
Member

Another thing: the lit object crashes the game if you place it

@Rusty-Box
Copy link
Member

@MatusGuy Why does Dart Traps light have numbers in its linked sprite and why (when I change it) it either crashes my game or doesn't show any glowing. Is it hardcoded? It should care what I put there, should it? Since this is were you set it up to how you please when it comes to naming. It works with Dive Mine seemingly and I tried a similar naming convention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:code status:needs-review Work needs to be reviewed by other people type:feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants