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 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
355eb19
Linked sprite support
Vankata453 Jan 28, 2024
653d258
`MovingSprite` light sprite support
Vankata453 Jan 30, 2024
866af12
`MovingSprite`: Use a map for linked sprites list, instead of struct
Vankata453 Jan 30, 2024
bf855b5
"light" -> "on-light"
Vankata453 Jan 30, 2024
073c426
Undo unneeded changes to "red-potion.sprite"
Vankata453 Jan 30, 2024
f11eebf
`SpriteManager`: Dummy sprite data handling improvements
Vankata453 Jan 30, 2024
aeab60f
Sprite action-specific linked sprites
Vankata453 Jan 30, 2024
25696a4
Default actions for linked sprites
Vankata453 Jun 15, 2024
abb7455
Merge remote-tracking branch 'supertux/master' into custom-linked-spr…
Vankata453 Jun 15, 2024
c9ebd6e
Fix torch.sprite [ci skip]
Vankata453 Jun 15, 2024
7f62ce9
Merge branch 'real-master' into custom-linked-sprites
MatusGuy Aug 20, 2024
aa8dcf6
light is stupid i hate it
MatusGuy Aug 20, 2024
90e8086
dart light ooooo BUT ITS BLURRY WHAHAHA
MatusGuy Aug 20, 2024
10269ad
Un-hardcode linked sprite actions, allow for setting custom loop count
Vankata453 Aug 31, 2024
1743ffd
Undo DiveMine hitbox changes [ci skip]
Vankata453 Aug 31, 2024
f9bd9f7
Undo DiveMine hitbox changes [ci skip]
Vankata453 Aug 31, 2024
0084152
Merge remote-tracking branch 'supertux/master' into custom-linked-spr…
Vankata453 Nov 18, 2024
4f778d9
Fix `Candle` custom light sprites not being configured
Vankata453 Nov 18, 2024
3a6141e
Do not use `Dart` light sprite as `BadGuy::lightsprite`
Vankata453 Nov 18, 2024
87e89cf
Fix `SpriteData` code duplication, remove sprite hardcoding for many …
Vankata453 Nov 20, 2024
4fddd07
Merge branch 'master' into custom-linked-sprites
Vankata453 Nov 22, 2024
882eeb1
`Crusher` now draws its custom light sprite
Vankata453 Nov 23, 2024
a2f4d77
Fix "Missing sprite" issues with some objects
Vankata453 Nov 23, 2024
380ea8b
Replace `m_sprite->clone()` with a linked sprite in objects
Vankata453 Nov 23, 2024
ebe57ca
"light" -> "on-light", remove unneeded `set_blend`
Vankata453 Nov 23, 2024
22de58b
Remove more unneeded `set_blend(Blend::ADD)`
Vankata453 Nov 23, 2024
b5c798c
`WeakBlock`: `lightsprite` -> `m_burn_sprite`
Vankata453 Nov 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion data/images/creatures/dive_mine/dive_mine.sprite
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,8 @@
(fps 15.0)
(hitbox 14 19 32 32)
(mirror-action "ticking-left"))


(linked-sprites
(ticking-glow "images/creatures/dive_mine/ticking_glow/ticking_glow.sprite")
)
)
4 changes: 4 additions & 0 deletions data/images/creatures/ghosttree/ghosttree.sprite
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@
"ghosttree-dying-0.png"
)
)

(linked-sprites
(glow "ghosttree-glow.sprite")
)
)
4 changes: 4 additions & 0 deletions data/images/creatures/ghosttree/root.sprite
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@
(name "default")
(images "root.png")
)

(linked-sprites
(base "root_base.sprite")
)
)
5 changes: 4 additions & 1 deletion data/images/creatures/gold_bomb/gold_bomb.sprite
Original file line number Diff line number Diff line change
Expand Up @@ -177,5 +177,8 @@
(loops 1)
(hitbox 14 19 32 32)
(mirror-action "ticking-left"))


(linked-sprites
(explode "images/creatures/mr_bomb/ticking_glow/ticking_glow.sprite")
)
)
5 changes: 5 additions & 0 deletions data/images/creatures/granito/corrupted/big/rock_mine.sprite
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,9 @@
(hitbox 18 26 48 48)
(mirror-action "broken-left")
)

(linked-sprites
(rock-particles "images/particles/granito_piece.sprite")
(shard "root_spike.sprite")
)
)
4 changes: 4 additions & 0 deletions data/images/creatures/haywire/haywire.sprite
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,8 @@
(fps 20.0)
(hitbox 14 19 32 32)
(mirror-action "jump-left"))

(linked-sprites
(ticking-glow "ticking_glow/ticking_glow.sprite")
)
)
6 changes: 5 additions & 1 deletion data/images/creatures/kugelblitz/kugelblitz.sprite
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@
"pop-1.png"
"pop-2.png"
"pop-3.png"))
)

(linked-sprites
(light "images/objects/lightmap_light/lightmap_light.sprite" 0.2 0.1 0)
)
)
5 changes: 4 additions & 1 deletion data/images/creatures/mr_bomb/mr_bomb.sprite
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,8 @@
(loops 1)
(hitbox 14 19 32 32)
(mirror-action "ticking-left"))


(linked-sprites
(explode "ticking_glow/ticking_glow.sprite")
)
)
4 changes: 4 additions & 0 deletions data/images/objects/bonus_block/bonusblock.sprite
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@
(action
(name "off")
(images "lightblock_off.png"))

(linked-sprites
(on-light "images/objects/lightmap_light/bonusblock_light.png")
)
)
4 changes: 4 additions & 0 deletions data/images/objects/bonus_block/orangeblock.sprite
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@
(surface
(diffuse-texture (file "orange_empty.png"))
(displacement-texture (file "displacement.png")))))

(linked-sprites
(on-light "images/objects/lightmap_light/bonusblock_light.png")
)
)
4 changes: 4 additions & 0 deletions data/images/objects/bonus_block/purpleblock.sprite
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@
(surface
(diffuse-texture (file "purple_empty.png"))
(displacement-texture (file "displacement.png")))))

(linked-sprites
(on-light "images/objects/lightmap_light/bonusblock_light.png")
)
)
4 changes: 4 additions & 0 deletions data/images/objects/bonus_block/retroblock.sprite
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@
(surface
(diffuse-texture (file "box-empty.png"))
(displacement-texture (file "displacement.png")))))

(linked-sprites
(on-light "images/objects/lightmap_light/bonusblock_light.png")
)
)
4 changes: 4 additions & 0 deletions data/images/objects/bullets/firebullet.sprite
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@
"fire_bullet-2.png"
"fire_bullet-3.png")
)

(linked-sprites
(light "images/objects/lightmap_light/lightmap_light-small.sprite" 0.3 0.1 0)
)
)
6 changes: 5 additions & 1 deletion data/images/objects/candle/candle.sprite
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,9 @@
"candle-0.png"
)
)
)

(linked-sprites
(light-1 "candle-light-1.sprite")
(light-2 "candle-light-2.sprite")
)
)
4 changes: 4 additions & 0 deletions data/images/objects/door/door.sprite
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,8 @@
"door-1.png"
"door-0.png")
)

(linked-sprites
(lock "door_lock.sprite")
)
)
5 changes: 4 additions & 1 deletion data/images/objects/explosion/explosion.sprite
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@
(hitbox 0 0 48 48)
(images "pop-0.png")
)
)

(linked-sprites
(light "images/objects/lightmap_light/lightmap_light-large.sprite" 0.6 0.6 0.6)
)
)
5 changes: 5 additions & 0 deletions data/images/objects/keys/key.sprite
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@
(name "silver-left")
(hitbox 0 2 48 28)
(mirror-action "silver-right"))

(linked-sprites
(light "images/objects/lightmap_light/lightmap_light-small.sprite")
(sparkle "images/particles/sparkle.sprite")
)
)
4 changes: 4 additions & 0 deletions data/images/objects/lantern/lantern.sprite
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@
(hitbox 8 28 34 39)
(images "lantern-1.png")
)

(linked-sprites
(light "images/objects/lightmap_light/lightmap_light.sprite")
)
)
6 changes: 5 additions & 1 deletion data/images/objects/resetpoints/torch.sprite
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,9 @@
"torch6.png"

)
)
)

(linked-sprites
(light "torch_light.sprite" 0.87 0.64 0.12)
)
)
8 changes: 8 additions & 0 deletions data/images/objects/resetpoints/torch_light.sprite
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(supertux-sprite
(action
(name "default")
(images "../lightmap_light/lightmap_light-small.png")
(hitbox 64 76 0 0)
(flip-offset 48)
)
)
4 changes: 4 additions & 0 deletions data/images/objects/rublight/rublight.sprite
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@
(name "inactive")
(images "rublight-0.png")
)

(linked-sprites
(light "images/objects/lightmap_light/lightmap_light.sprite")
)
)
6 changes: 6 additions & 0 deletions data/images/objects/torch/torch1.sprite
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@
(hitbox 0 0 16 100)
(images "torch1.png")
)

(linked-sprites
(flame "flame.sprite")
(glow "flame_glow.sprite")
(light "flame_light.sprite")
)
)
6 changes: 6 additions & 0 deletions data/images/objects/torch/torch2.sprite
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@
(hitbox 0 0 16 100)
(images "torch2.png")
)

(linked-sprites
(flame "flame.sprite")
(glow "flame_glow.sprite")
(light "flame_light.sprite")
)
)
6 changes: 6 additions & 0 deletions data/images/objects/torch/torch3.sprite
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@
(hitbox 0 0 16 100)
(images "torch3.png")
)

(linked-sprites
(flame "flame.sprite")
(glow "flame_glow.sprite")
(light "flame_light.sprite")
)
)
6 changes: 6 additions & 0 deletions data/images/objects/torch/torch4.sprite
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@
(hitbox 0 0 16 100)
(images "torch4.png")
)

(linked-sprites
(flame "flame.sprite")
(glow "flame_glow.sprite")
(light "flame_light.sprite")
)
)
4 changes: 4 additions & 0 deletions data/images/objects/weak_block/strawbox.sprite
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,8 @@
"strawbox-11.png"
)
)

(linked-sprites
(burn-light "images/objects/lightmap_light/lightmap_light-small.sprite")
)
)
4 changes: 4 additions & 0 deletions data/images/particles/sparkle.sprite
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,8 @@
"sparkle-0.png"
)
)

(linked-sprites
(light "images/objects/lightmap_light/lightmap_light-tiny.sprite")
)
)
7 changes: 6 additions & 1 deletion data/images/powerups/airflower/airflower.sprite
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@
"air_flower-2.png"
"air_flower-3.png"
"air_flower-2.png"
"air_flower-1.png")))
"air_flower-1.png"))

(linked-sprites
(light "images/objects/lightmap_light/lightmap_light-small.sprite" 0.15 0 0.15)
)
)
7 changes: 6 additions & 1 deletion data/images/powerups/earthflower/earthflower.sprite
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@
"earth_flower-2.png"
"earth_flower-3.png"
"earth_flower-2.png"
"earth_flower-1.png")))
"earth_flower-1.png"))

(linked-sprites
(light "images/objects/lightmap_light/lightmap_light-small.sprite" 0 0.3 0)
)
)
6 changes: 5 additions & 1 deletion data/images/powerups/egg/egg.sprite
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@
(name "shadow")
(images "egg-shade.png")
)
)

(linked-sprites
(shade "egg.sprite")
(light "images/objects/lightmap_light/lightmap_light-small.sprite" 0.2 0.2 0)
)
)
7 changes: 6 additions & 1 deletion data/images/powerups/fireflower/fireflower.sprite
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@
"fire_flower-2.png"
"fire_flower-3.png"
"fire_flower-2.png"
"fire_flower-1.png")))
"fire_flower-1.png"))

(linked-sprites
(light "images/objects/lightmap_light/lightmap_light-small.sprite" 0.3 0 0)
)
)
7 changes: 6 additions & 1 deletion data/images/powerups/iceflower/iceflower.sprite
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@
"ice_flower-2.png"
"ice_flower-3.png"
"ice_flower-2.png"
"ice_flower-1.png")))
"ice_flower-1.png"))

(linked-sprites
(light "images/objects/lightmap_light/lightmap_light-small.sprite" 0 0.1 0.2)
)
)
7 changes: 6 additions & 1 deletion data/images/powerups/star/star.sprite
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@
"star-4.png"
"star-3.png"
"star-2.png"
"star-1.png")))
"star-1.png"))

(linked-sprites
(light "images/objects/lightmap_light/lightmap_light-small.sprite" 0.4 0.4 0.4)
)
)
13 changes: 8 additions & 5 deletions src/badguy/badguy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,16 @@ BadGuy::draw(DrawingContext& context)

if (m_state == STATE_INIT || m_state == STATE_INACTIVE)
{
if (Editor::is_active()) {
m_sprite->draw(context.color(), get_pos(), m_layer, m_flip);
}
if (Editor::is_active())
MovingSprite::draw(context);
}
else
{
if (m_state == STATE_FALLING)
{
context.push_transform();
context.set_flip(context.get_flip() ^ VERTICAL_FLIP);
m_sprite->draw(context.color(), get_pos(), m_layer, m_flip);
MovingSprite::draw(context);
context.pop_transform();
}
else
Expand All @@ -165,7 +164,11 @@ BadGuy::draw(DrawingContext& context)
{
if (m_frozen && is_portable())
m_freezesprite->draw(context.color(), get_pos(), m_layer);
m_sprite->draw(context.color(), get_pos(), m_layer - (m_frozen ? 1 : 0), m_flip);

if (m_frozen)
m_sprite->draw(context.color(), get_pos(), m_layer - 1, m_flip);
else
MovingSprite::draw(context);
}

if (m_glowing)
Expand Down
10 changes: 9 additions & 1 deletion src/badguy/bomb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
Bomb::Bomb(const Vector& pos, Direction dir_, const std::string& custom_sprite /*= "images/creatures/mr_bomb/mr_bomb.sprite"*/ ) :
BadGuy( pos, dir_, custom_sprite ),
ticking(SoundManager::current()->create_sound_source("sounds/fizz.wav")),
m_exploding_sprite(SpriteManager::current()->create("images/creatures/mr_bomb/ticking_glow/ticking_glow.sprite"))
m_exploding_sprite(m_sprite->get_linked_sprite("explode"))
{
SoundManager::current()->preload("sounds/explosion.wav");
set_action("ticking", dir_, 1);
Expand All @@ -41,6 +41,14 @@ Bomb::Bomb(const Vector& pos, Direction dir_, const std::string& custom_sprite /
ticking->play();
}

MovingSprite::LinkedSprites
Bomb::get_linked_sprites()
{
return {
{ "explode", m_exploding_sprite }
};
}

void
Bomb::collision_solid(const CollisionHit& hit)
{
Expand Down
3 changes: 3 additions & 0 deletions src/badguy/bomb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ class Bomb final : public BadGuy
virtual void stop_looping_sounds() override;
virtual void play_looping_sounds() override;

protected:
LinkedSprites get_linked_sprites() override;

private:
std::unique_ptr<SoundSource> ticking;
SpritePtr m_exploding_sprite;
Expand Down
Loading
Loading