From 9575db2f6e595d7bd78a15bfbd3b03cbd142e87d Mon Sep 17 00:00:00 2001 From: Vankata453 <78196474+Vankata453@users.noreply.github.com> Date: Mon, 16 Dec 2024 20:17:14 +0200 Subject: [PATCH] Allow setting many custom sprites (light or not), use S-Expression objects --- .../crusher/corrupted/krosh_corrupt.sprite | 15 ++++- .../crusher/corrupted/krush_corrupt.sprite | 15 ++++- .../images/creatures/crusher/krosh_ice.sprite | 15 ++++- .../creatures/crusher/krosh_rock.sprite | 15 ++++- .../images/creatures/crusher/krush_ice.sprite | 15 ++++- .../creatures/crusher/krush_rock.sprite | 15 ++++- .../darttrap/granito/root_dart.sprite | 5 +- .../darttrap/skull/skull_dart.sprite | 5 +- .../creatures/dive_mine/dive_mine.sprite | 17 +++-- data/images/creatures/flame/flame.sprite | 9 ++- data/images/creatures/flame/ghostflame.sprite | 9 ++- data/images/creatures/flame/iceflame.sprite | 9 ++- .../flying_snowball/flying_snowball.sprite | 4 +- .../creatures/ghosttree/ghosttree.sprite | 10 ++- data/images/creatures/ghosttree/root.sprite | 4 +- .../creatures/gold_bomb/gold_bomb.sprite | 5 +- .../granito/corrupted/big/rock_mine.sprite | 8 ++- data/images/creatures/haywire/haywire.sprite | 38 +++++++++-- .../creatures/kugelblitz/kugelblitz.sprite | 6 +- .../images/creatures/livefire/livefire.sprite | 9 ++- .../creatures/mole/corrupted/root.sprite | 4 +- .../mole/corrupted/root_sapling.sprite | 4 +- data/images/creatures/mr_bomb/mr_bomb.sprite | 15 ++++- .../creatures/mr_candle/mr-candle.sprite | 4 +- data/images/creatures/mr_tree/mr_tree.sprite | 4 +- data/images/creatures/mr_tree/stumpy.sprite | 4 +- data/images/creatures/tux/tux.sprite | 8 ++- .../creatures/willowisp/willowisp.sprite | 4 +- .../objects/big_snowball/big_snowball.sprite | 5 +- .../objects/bonus_block/bonusblock.sprite | 4 +- data/images/objects/bonus_block/brick.sprite | 4 +- .../objects/bonus_block/brickIce.sprite | 4 +- .../objects/bonus_block/brickWeb.sprite | 4 +- .../objects/bonus_block/heavy-brick.sprite | 4 +- .../objects/bonus_block/orangeblock.sprite | 4 +- .../objects/bonus_block/purpleblock.sprite | 4 +- .../objects/bonus_block/retroblock.sprite | 4 +- data/images/objects/bullets/firebullet.sprite | 6 +- data/images/objects/candle/candle.sprite | 32 +++++++-- data/images/objects/door/door.sprite | 4 +- .../objects/explosion/explosion_large.sprite | 6 +- .../objects/explosion/explosion_medium.sprite | 6 +- data/images/objects/firefly/firefly.sprite | 4 +- data/images/objects/keys/key.sprite | 14 +++- data/images/objects/lantern/lantern.sprite | 4 +- data/images/objects/resetpoints/bell.sprite | 4 +- .../resetpoints/default-resetpoint.sprite | 4 +- .../images/objects/resetpoints/firefly.sprite | 4 +- data/images/objects/resetpoints/torch.sprite | 10 ++- data/images/objects/resetpoints/vbell.sprite | 4 +- data/images/objects/rublight/rublight.sprite | 4 +- data/images/objects/torch/torch1.sprite | 12 +++- data/images/objects/torch/torch2.sprite | 12 +++- data/images/objects/torch/torch3.sprite | 12 +++- data/images/objects/torch/torch4.sprite | 12 +++- .../images/objects/weak_block/strawbox.sprite | 4 +- data/images/particles/sparkle.sprite | 9 ++- .../powerups/airflower/airflower.sprite | 6 +- .../powerups/earthflower/earthflower.sprite | 6 +- data/images/powerups/egg/egg.sprite | 11 +++- .../powerups/fireflower/fireflower.sprite | 6 +- .../powerups/iceflower/iceflower.sprite | 6 +- data/images/powerups/star/star.sprite | 10 ++- src/badguy/badguy.cpp | 21 ++++-- src/badguy/crusher.cpp | 7 +- src/badguy/haywire.cpp | 1 - src/badguy/livefire.cpp | 5 +- src/badguy/mrbomb.cpp | 2 - src/badguy/rcrystallo.cpp | 9 --- src/badguy/rcrystallo.hpp | 1 - src/badguy/stalactite.cpp | 23 ++++++- src/badguy/treewillowisp.cpp | 6 ++ src/badguy/walking_candle.cpp | 12 ++-- src/badguy/willowisp.cpp | 23 ++++--- src/object/bullet.cpp | 22 ++++--- src/object/bullet.hpp | 2 +- src/object/decal.cpp | 9 ++- src/object/explosion.cpp | 24 ++++--- src/object/fallblock.cpp | 15 +++-- src/object/firefly.cpp | 10 ++- src/object/flower.cpp | 8 +-- src/object/flower.hpp | 2 +- src/object/invisible_block.cpp | 2 +- src/object/key.cpp | 15 +++-- src/object/lantern.cpp | 8 +-- src/object/lit_object.cpp | 20 +++--- src/object/moving_sprite.cpp | 21 ++++-- src/object/moving_sprite.hpp | 3 +- src/object/powerup.cpp | 5 +- src/object/rock.cpp | 8 ++- src/object/rublight.cpp | 10 ++- src/object/sprite_particle.cpp | 41 +++++++----- src/object/sprite_particle.hpp | 3 +- src/object/torch.cpp | 23 ++++--- src/sprite/sprite.cpp | 57 +++++++++------- src/sprite/sprite.hpp | 13 ++-- src/sprite/sprite_config.cpp | 51 +++++++++++++++ src/sprite/sprite_config.hpp | 45 +++++++++++++ src/sprite/sprite_data.cpp | 65 +++++++++---------- src/sprite/sprite_data.hpp | 28 +++----- 100 files changed, 810 insertions(+), 334 deletions(-) create mode 100644 src/sprite/sprite_config.cpp create mode 100644 src/sprite/sprite_config.hpp diff --git a/data/images/creatures/crusher/corrupted/krosh_corrupt.sprite b/data/images/creatures/crusher/corrupted/krosh_corrupt.sprite index de7c29d7375..82878e59a32 100644 --- a/data/images/creatures/crusher/corrupted/krosh_corrupt.sprite +++ b/data/images/creatures/crusher/corrupted/krosh_corrupt.sprite @@ -34,8 +34,17 @@ ) (linked-sprites - (left-eye "krosh_corrupt.sprite" "left-eye") - (right-eye "krosh_corrupt.sprite" "right-eye") - (whites "krosh_corrupt.sprite" "whites") + (left-eye + (file "krosh_corrupt.sprite") + (action "left-eye") + ) + (right-eye + (file "krosh_corrupt.sprite") + (action "right-eye") + ) + (whites + (file "krosh_corrupt.sprite") + (action "whites") + ) ) ) diff --git a/data/images/creatures/crusher/corrupted/krush_corrupt.sprite b/data/images/creatures/crusher/corrupted/krush_corrupt.sprite index ab1e729af85..148c5f822ff 100644 --- a/data/images/creatures/crusher/corrupted/krush_corrupt.sprite +++ b/data/images/creatures/crusher/corrupted/krush_corrupt.sprite @@ -34,8 +34,17 @@ ) (linked-sprites - (left-eye "krush_corrupt.sprite" "left-eye") - (right-eye "krush_corrupt.sprite" "right-eye") - (whites "krush_corrupt.sprite" "whites") + (left-eye + (file "krush_corrupt.sprite") + (action "left-eye") + ) + (right-eye + (file "krush_corrupt.sprite") + (action "right-eye") + ) + (whites + (file "krush_corrupt.sprite") + (action "whites") + ) ) ) diff --git a/data/images/creatures/crusher/krosh_ice.sprite b/data/images/creatures/crusher/krosh_ice.sprite index 32454d42468..263f9e9e364 100644 --- a/data/images/creatures/crusher/krosh_ice.sprite +++ b/data/images/creatures/crusher/krosh_ice.sprite @@ -34,8 +34,17 @@ ) (linked-sprites - (left-eye "krosh_ice.sprite" "left-eye") - (right-eye "krosh_ice.sprite" "right-eye") - (whites "krosh_ice.sprite" "whites") + (left-eye + (file "krosh_ice.sprite") + (action "left-eye") + ) + (right-eye + (file "krosh_ice.sprite") + (action "right-eye") + ) + (whites + (file "krosh_ice.sprite") + (action "whites") + ) ) ) diff --git a/data/images/creatures/crusher/krosh_rock.sprite b/data/images/creatures/crusher/krosh_rock.sprite index ca847cc5248..0d0a2224d5d 100644 --- a/data/images/creatures/crusher/krosh_rock.sprite +++ b/data/images/creatures/crusher/krosh_rock.sprite @@ -34,8 +34,17 @@ ) (linked-sprites - (left-eye "krosh_rock.sprite" "left-eye") - (right-eye "krosh_rock.sprite" "right-eye") - (whites "krosh_rock.sprite" "whites") + (left-eye + (file "krosh_rock.sprite") + (action "left-eye") + ) + (right-eye + (file "krosh_rock.sprite") + (action "right-eye") + ) + (whites + (file "krosh_rock.sprite") + (action "whites") + ) ) ) diff --git a/data/images/creatures/crusher/krush_ice.sprite b/data/images/creatures/crusher/krush_ice.sprite index f35d6a4798a..0f180398068 100644 --- a/data/images/creatures/crusher/krush_ice.sprite +++ b/data/images/creatures/crusher/krush_ice.sprite @@ -34,8 +34,17 @@ ) (linked-sprites - (left-eye "krush_ice.sprite" "left-eye") - (right-eye "krush_ice.sprite" "right-eye") - (whites "krush_ice.sprite" "whites") + (left-eye + (file "krush_ice.sprite") + (action "left-eye") + ) + (right-eye + (file "krush_ice.sprite") + (action "right-eye") + ) + (whites + (file "krush_ice.sprite") + (action "whites") + ) ) ) diff --git a/data/images/creatures/crusher/krush_rock.sprite b/data/images/creatures/crusher/krush_rock.sprite index b521f255984..5be1d2c5843 100644 --- a/data/images/creatures/crusher/krush_rock.sprite +++ b/data/images/creatures/crusher/krush_rock.sprite @@ -36,8 +36,17 @@ ) (linked-sprites - (left-eye "krush_rock.sprite" "left-eye") - (right-eye "krush_rock.sprite" "right-eye") - (whites "krush_rock.sprite" "whites") + (left-eye + (file "krush_rock.sprite") + (action "left-eye") + ) + (right-eye + (file "krush_rock.sprite") + (action "right-eye") + ) + (whites + (file "krush_rock.sprite") + (action "whites") + ) ) ) diff --git a/data/images/creatures/darttrap/granito/root_dart.sprite b/data/images/creatures/darttrap/granito/root_dart.sprite index f47f5880690..c1f4baadc0b 100644 --- a/data/images/creatures/darttrap/granito/root_dart.sprite +++ b/data/images/creatures/darttrap/granito/root_dart.sprite @@ -21,6 +21,9 @@ ) (linked-sprites - (light "dart_light.sprite" "" 1 1 1) + (custom-light + (file "dart_light.sprite") + (color 1 1 1) + ) ) ) diff --git a/data/images/creatures/darttrap/skull/skull_dart.sprite b/data/images/creatures/darttrap/skull/skull_dart.sprite index 342563acfe7..a2549e4f263 100644 --- a/data/images/creatures/darttrap/skull/skull_dart.sprite +++ b/data/images/creatures/darttrap/skull/skull_dart.sprite @@ -21,6 +21,9 @@ ) (linked-sprites - (light "dart_light.sprite" "" 1 1 1) + (custom-light + (file "dart_light.sprite") + (color 1 1 1) + ) ) ) diff --git a/data/images/creatures/dive_mine/dive_mine.sprite b/data/images/creatures/dive_mine/dive_mine.sprite index 5399ae6f7c3..625deef2fd5 100644 --- a/data/images/creatures/dive_mine/dive_mine.sprite +++ b/data/images/creatures/dive_mine/dive_mine.sprite @@ -37,7 +37,10 @@ (fps 15.0) (hitbox 14 19 32 32) (linked-sprites - (ticking-glow "ticking_glow/ticking_glow.sprite" "ticking") + (ticking-glow + (file "ticking_glow/ticking_glow.sprite") + (action "ticking") + ) ) (images "ticking-0.png" "ticking-1.png" @@ -56,11 +59,17 @@ (fps 15.0) (hitbox 14 19 32 32) (linked-sprites - (ticking-glow "ticking_glow/ticking_glow.sprite" "ticking") + (ticking-glow + (file "ticking_glow/ticking_glow.sprite") + (action "ticking") + ) ) (mirror-action "ticking-left")) (linked-sprites - (ticking-glow "ticking_glow/ticking_glow.sprite" "idle") + (ticking-glow + (file "ticking_glow/ticking_glow.sprite") + (action "idle") + ) ) -) \ No newline at end of file +) diff --git a/data/images/creatures/flame/flame.sprite b/data/images/creatures/flame/flame.sprite index 6b17c4c697e..8f2b0c08bd4 100644 --- a/data/images/creatures/flame/flame.sprite +++ b/data/images/creatures/flame/flame.sprite @@ -15,8 +15,13 @@ "flame-fade-3.png")) (linked-sprites - (light "images/objects/lightmap_light/lightmap_light-small.sprite" "" 0.21 0.13 0.08) - (smoke "images/particles/smoke.sprite") + (custom-light + (file "images/objects/lightmap_light/lightmap_light-small.sprite") + (color 0.21 0.13 0.08) + ) + (smoke + (file "images/particles/smoke.sprite") + ) ) ) diff --git a/data/images/creatures/flame/ghostflame.sprite b/data/images/creatures/flame/ghostflame.sprite index aa559dbdb70..062a655f275 100644 --- a/data/images/creatures/flame/ghostflame.sprite +++ b/data/images/creatures/flame/ghostflame.sprite @@ -9,8 +9,13 @@ "ghostflame-4.png")) (linked-sprites - (light "images/objects/lightmap_light/lightmap_light-small.sprite" "" 0.21 0 0.21) - (smoke "images/particles/smoke.sprite") + (custom-light + (file "images/objects/lightmap_light/lightmap_light-small.sprite") + (color 0.21 0 0.21) + ) + (smoke + (file "images/particles/smoke.sprite") + ) ) ) diff --git a/data/images/creatures/flame/iceflame.sprite b/data/images/creatures/flame/iceflame.sprite index 5e3e7d4167d..1a1fb4bb0d9 100644 --- a/data/images/creatures/flame/iceflame.sprite +++ b/data/images/creatures/flame/iceflame.sprite @@ -12,8 +12,13 @@ "iceflame-fade-2.png")) (linked-sprites - (light "images/objects/lightmap_light/lightmap_light-small.sprite" "" 0 0.13 0.18) - (smoke "images/particles/smoke.sprite") + (custom-light + (file "images/objects/lightmap_light/lightmap_light-small.sprite") + (color 0 0.13 0.18) + ) + (smoke + (file "images/particles/smoke.sprite") + ) ) ) diff --git a/data/images/creatures/flying_snowball/flying_snowball.sprite b/data/images/creatures/flying_snowball/flying_snowball.sprite index 4b9ec226852..ddf841c9555 100644 --- a/data/images/creatures/flying_snowball/flying_snowball.sprite +++ b/data/images/creatures/flying_snowball/flying_snowball.sprite @@ -39,6 +39,8 @@ (mirror-action "melting-left")) (linked-sprites - (smoke "images/particles/smoke.sprite") + (smoke + (file "images/particles/smoke.sprite") + ) ) ) diff --git a/data/images/creatures/ghosttree/ghosttree.sprite b/data/images/creatures/ghosttree/ghosttree.sprite index d231623295b..eb0ceecc2e5 100644 --- a/data/images/creatures/ghosttree/ghosttree.sprite +++ b/data/images/creatures/ghosttree/ghosttree.sprite @@ -22,7 +22,11 @@ (hitbox 230 300 40 60) (fps 4) (linked-sprites - (glow "ghosttree-glow.sprite" "dying" 1) + (glow + (file "ghosttree-glow.sprite") + (action "dying") + (loops 1) + ) ) (images "ghosttree-dying-0.png" @@ -33,6 +37,8 @@ ) (linked-sprites - (glow "ghosttree-glow.sprite") + (glow + (file "ghosttree-glow.sprite") + ) ) ) diff --git a/data/images/creatures/ghosttree/root.sprite b/data/images/creatures/ghosttree/root.sprite index 8d7765738a7..ee661060a7e 100644 --- a/data/images/creatures/ghosttree/root.sprite +++ b/data/images/creatures/ghosttree/root.sprite @@ -5,6 +5,8 @@ ) (linked-sprites - (base "root_base.sprite") + (base + (file "root_base.sprite") + ) ) ) diff --git a/data/images/creatures/gold_bomb/gold_bomb.sprite b/data/images/creatures/gold_bomb/gold_bomb.sprite index 6492599a879..1c987ccef68 100644 --- a/data/images/creatures/gold_bomb/gold_bomb.sprite +++ b/data/images/creatures/gold_bomb/gold_bomb.sprite @@ -179,6 +179,9 @@ (mirror-action "ticking-left")) (linked-sprites - (ticking-glow "images/creatures/mr_bomb/ticking_glow/ticking_glow.sprite" "exploding") + (ticking-glow + (file "images/creatures/mr_bomb/ticking_glow/ticking_glow.sprite") + (action "exploding") + ) ) ) diff --git a/data/images/creatures/granito/corrupted/big/rock_mine.sprite b/data/images/creatures/granito/corrupted/big/rock_mine.sprite index 18787b1fc87..35261f99410 100644 --- a/data/images/creatures/granito/corrupted/big/rock_mine.sprite +++ b/data/images/creatures/granito/corrupted/big/rock_mine.sprite @@ -42,7 +42,11 @@ ) (linked-sprites - (rock-particles "images/particles/granito_piece.sprite") - (shard "root_spike.sprite") + (rock-particles + (file "images/particles/granito_piece.sprite") + ) + (shard + (file "root_spike.sprite") + ) ) ) diff --git a/data/images/creatures/haywire/haywire.sprite b/data/images/creatures/haywire/haywire.sprite index 2c944faad86..174acfaaca1 100644 --- a/data/images/creatures/haywire/haywire.sprite +++ b/data/images/creatures/haywire/haywire.sprite @@ -33,7 +33,10 @@ (fps 20.0) (hitbox 14 19 32 32) (linked-sprites - (ticking-glow "ticking_glow/ticking_glow.sprite" "run") + (ticking-glow + (file "ticking_glow/ticking_glow.sprite") + (action "run") + ) ) (images "chase-0.png" "chase-1.png" @@ -48,7 +51,10 @@ (fps 20.0) (hitbox 14 19 32 32) (linked-sprites - (ticking-glow "ticking_glow/ticking_glow.sprite" "run") + (ticking-glow + (file "ticking_glow/ticking_glow.sprite") + (action "run") + ) ) (mirror-action "ticking-left")) @@ -85,7 +91,11 @@ (fps 20.0) (hitbox 14 19 32 32) (linked-sprites - (ticking-glow "ticking_glow/ticking_glow.sprite" "skid" 1) + (ticking-glow + (file "ticking_glow/ticking_glow.sprite") + (action "skid") + (loops 1) + ) ) (images "skid-0.png" "skid-1.png" @@ -98,7 +108,11 @@ (fps 20.0) (hitbox 14 19 32 32) (linked-sprites - (ticking-glow "ticking_glow/ticking_glow.sprite" "skid" 1) + (ticking-glow + (file "ticking_glow/ticking_glow.sprite") + (action "skid") + (loops 1) + ) ) (mirror-action "skid-left")) @@ -108,7 +122,11 @@ (fps 20.0) (hitbox 14 19 32 32) (linked-sprites - (ticking-glow "ticking_glow/ticking_glow.sprite" "jump" 1) + (ticking-glow + (file "ticking_glow/ticking_glow.sprite") + (action "jump") + (loops 1) + ) ) (images "jump-0.png" "jump-1.png" @@ -121,11 +139,17 @@ (fps 20.0) (hitbox 14 19 32 32) (linked-sprites - (ticking-glow "ticking_glow/ticking_glow.sprite" "jump" 1) + (ticking-glow + (file "ticking_glow/ticking_glow.sprite") + (action "jump") + (loops 1) + ) ) (mirror-action "jump-left")) (linked-sprites - (ticking-glow "ticking_glow/ticking_glow.sprite") + (ticking-glow + (file "ticking_glow/ticking_glow.sprite") + ) ) ) diff --git a/data/images/creatures/kugelblitz/kugelblitz.sprite b/data/images/creatures/kugelblitz/kugelblitz.sprite index ccd78fdab29..1a5c1ac7426 100644 --- a/data/images/creatures/kugelblitz/kugelblitz.sprite +++ b/data/images/creatures/kugelblitz/kugelblitz.sprite @@ -23,6 +23,10 @@ "pop-3.png")) (linked-sprites - (light "images/objects/lightmap_light/lightmap_light.sprite" "default" 0.2 0.1 0) + (custom-light + (file "images/objects/lightmap_light/lightmap_light.sprite") + (action "default") + (color 0.2 0.1 0) + ) ) ) diff --git a/data/images/creatures/livefire/livefire.sprite b/data/images/creatures/livefire/livefire.sprite index 0422cce0440..f63a5462047 100644 --- a/data/images/creatures/livefire/livefire.sprite +++ b/data/images/creatures/livefire/livefire.sprite @@ -62,7 +62,12 @@ (mirror-action "extinguish-left")) (linked-sprites - (light "images/objects/lightmap_light/lightmap_light-medium.sprite" "" 0.89 0.75 0.44) - (smoke "images/particles/smoke.sprite") + (custom-light + (file "images/objects/lightmap_light/lightmap_light-medium.sprite") + (color 0.89 0.75 0.44) + ) + (smoke + (file "images/particles/smoke.sprite") + ) ) ) diff --git a/data/images/creatures/mole/corrupted/root.sprite b/data/images/creatures/mole/corrupted/root.sprite index c1124854213..c703a845220 100644 --- a/data/images/creatures/mole/corrupted/root.sprite +++ b/data/images/creatures/mole/corrupted/root.sprite @@ -41,6 +41,8 @@ (mirror-action "base-left")) (linked-sprites - (rock "images/particles/corrupted_rock.sprite") + (rock + (file "images/particles/corrupted_rock.sprite") + ) ) ) diff --git a/data/images/creatures/mole/corrupted/root_sapling.sprite b/data/images/creatures/mole/corrupted/root_sapling.sprite index 501821828e2..36d7feb3657 100644 --- a/data/images/creatures/mole/corrupted/root_sapling.sprite +++ b/data/images/creatures/mole/corrupted/root_sapling.sprite @@ -95,6 +95,8 @@ ) (linked-sprites - (light "core_glow/core_glow.sprite") + (custom-light + (file "core_glow/core_glow.sprite") + ) ) ) diff --git a/data/images/creatures/mr_bomb/mr_bomb.sprite b/data/images/creatures/mr_bomb/mr_bomb.sprite index 143878cdf86..d4132741e7f 100644 --- a/data/images/creatures/mr_bomb/mr_bomb.sprite +++ b/data/images/creatures/mr_bomb/mr_bomb.sprite @@ -34,7 +34,10 @@ (loops 1) (hitbox 14 19 32 32) (linked-sprites - (ticking-glow "ticking_glow/ticking_glow.sprite" "exploding") + (ticking-glow + (file "ticking_glow/ticking_glow.sprite") + (action "exploding") + ) ) (images "ticking-0.png" "ticking-1.png" @@ -111,11 +114,17 @@ (loops 1) (hitbox 14 19 32 32) (linked-sprites - (ticking-glow "ticking_glow/ticking_glow.sprite" "exploding" 1) + (ticking-glow + (file "ticking_glow/ticking_glow.sprite") + (action "exploding") + (loops 1) + ) ) (mirror-action "ticking-left")) (linked-sprites - (ticking-glow "ticking_glow/ticking_glow.sprite") + (ticking-glow + (file "ticking_glow/ticking_glow.sprite") + ) ) ) diff --git a/data/images/creatures/mr_candle/mr-candle.sprite b/data/images/creatures/mr_candle/mr-candle.sprite index 26017ad16f8..de7f39435a4 100644 --- a/data/images/creatures/mr_candle/mr-candle.sprite +++ b/data/images/creatures/mr_candle/mr-candle.sprite @@ -30,6 +30,8 @@ ) (linked-sprites - (light "images/objects/lightmap_light/lightmap_light-medium.sprite") + (custom-light + (file "images/objects/lightmap_light/lightmap_light-medium.sprite") + ) ) ) diff --git a/data/images/creatures/mr_tree/mr_tree.sprite b/data/images/creatures/mr_tree/mr_tree.sprite index 7a0aea68fe9..7b23eb30b26 100644 --- a/data/images/creatures/mr_tree/mr_tree.sprite +++ b/data/images/creatures/mr_tree/mr_tree.sprite @@ -54,6 +54,8 @@ ) (linked-sprites - (leaf "images/particles/leaf.sprite") + (leaf + (file "images/particles/leaf.sprite") + ) ) ) diff --git a/data/images/creatures/mr_tree/stumpy.sprite b/data/images/creatures/mr_tree/stumpy.sprite index 6d9c2c02420..02d19d283fc 100644 --- a/data/images/creatures/mr_tree/stumpy.sprite +++ b/data/images/creatures/mr_tree/stumpy.sprite @@ -84,6 +84,8 @@ ) (linked-sprites - (bark "images/particles/bark.sprite") + (bark + (file "images/particles/bark.sprite") + ) ) ) diff --git a/data/images/creatures/tux/tux.sprite b/data/images/creatures/tux/tux.sprite index 361dd46a830..0868e0660ee 100644 --- a/data/images/creatures/tux/tux.sprite +++ b/data/images/creatures/tux/tux.sprite @@ -3059,7 +3059,11 @@ (mirror-action "credits-right")) (linked-sprites - (sparkle-invincible "images/particles/sparkle.sprite") - (rock-particle "images/particles/rock.sprite") + (sparkle-invincible + (file "images/particles/sparkle.sprite") + ) + (rock-particle + (file "images/particles/rock.sprite") + ) ) ) diff --git a/data/images/creatures/willowisp/willowisp.sprite b/data/images/creatures/willowisp/willowisp.sprite index d43386e56b9..779f9059196 100644 --- a/data/images/creatures/willowisp/willowisp.sprite +++ b/data/images/creatures/willowisp/willowisp.sprite @@ -33,7 +33,9 @@ ) (linked-sprites - (light "images/objects/lightmap_light/lightmap_light-small.sprite") + (custom-light + (file "images/objects/lightmap_light/lightmap_light-small.sprite") + ) ) ) diff --git a/data/images/objects/big_snowball/big_snowball.sprite b/data/images/objects/big_snowball/big_snowball.sprite index e6b26fe300e..353cd0e1494 100644 --- a/data/images/objects/big_snowball/big_snowball.sprite +++ b/data/images/objects/big_snowball/big_snowball.sprite @@ -10,6 +10,9 @@ (images "big_snowball_particle.png")) (linked-sprites - (particle "big_snowball.sprite" "particle") + (particle + (file "big_snowball.sprite") + (action "particle") + ) ) ) diff --git a/data/images/objects/bonus_block/bonusblock.sprite b/data/images/objects/bonus_block/bonusblock.sprite index 0e57566692b..1d9b9f7dd5d 100644 --- a/data/images/objects/bonus_block/bonusblock.sprite +++ b/data/images/objects/bonus_block/bonusblock.sprite @@ -31,6 +31,8 @@ (images "lightblock_off.png")) (linked-sprites - (on-light "images/objects/lightmap_light/bonusblock_light.png") + (on-light + (file "images/objects/lightmap_light/bonusblock_light.png") + ) ) ) diff --git a/data/images/objects/bonus_block/brick.sprite b/data/images/objects/bonus_block/brick.sprite index 217c2e0c612..5ed3ac8ed68 100644 --- a/data/images/objects/bonus_block/brick.sprite +++ b/data/images/objects/bonus_block/brick.sprite @@ -41,6 +41,8 @@ (images "../../tiles/blocks/brick_piece6.png")) (linked-sprites - (break-particles "brick.sprite") + (break-particles + (file "brick.sprite") + ) ) ) diff --git a/data/images/objects/bonus_block/brickIce.sprite b/data/images/objects/bonus_block/brickIce.sprite index a4afad6c1fc..e607bca36f1 100644 --- a/data/images/objects/bonus_block/brickIce.sprite +++ b/data/images/objects/bonus_block/brickIce.sprite @@ -11,6 +11,8 @@ (images "../../tiles/blocks/brick1.png")) (linked-sprites - (break-particles "brick.sprite") + (break-particles + (file "brick.sprite") + ) ) ) diff --git a/data/images/objects/bonus_block/brickWeb.sprite b/data/images/objects/bonus_block/brickWeb.sprite index 4e44441e466..1e6969e8287 100644 --- a/data/images/objects/bonus_block/brickWeb.sprite +++ b/data/images/objects/bonus_block/brickWeb.sprite @@ -11,6 +11,8 @@ (images "../../tiles/blocks/brick2.png")) (linked-sprites - (break-particles "brick.sprite") + (break-particles + (file "brick.sprite") + ) ) ) diff --git a/data/images/objects/bonus_block/heavy-brick.sprite b/data/images/objects/bonus_block/heavy-brick.sprite index 56ceb2ce3e1..4b13bf41ad6 100644 --- a/data/images/objects/bonus_block/heavy-brick.sprite +++ b/data/images/objects/bonus_block/heavy-brick.sprite @@ -41,6 +41,8 @@ (images "../../tiles/blocks/brick_piece12.png")) (linked-sprites - (break-particles "heavy-brick.sprite") + (break-particles + (file "heavy-brick.sprite") + ) ) ) diff --git a/data/images/objects/bonus_block/orangeblock.sprite b/data/images/objects/bonus_block/orangeblock.sprite index e884cfe874d..3fabb5486d7 100644 --- a/data/images/objects/bonus_block/orangeblock.sprite +++ b/data/images/objects/bonus_block/orangeblock.sprite @@ -21,6 +21,8 @@ (displacement-texture (file "displacement.png"))))) (linked-sprites - (on-light "images/objects/lightmap_light/bonusblock_light.png") + (on-light + (file "images/objects/lightmap_light/bonusblock_light.png") + ) ) ) diff --git a/data/images/objects/bonus_block/purpleblock.sprite b/data/images/objects/bonus_block/purpleblock.sprite index ed771016f16..46d1df6e5d1 100644 --- a/data/images/objects/bonus_block/purpleblock.sprite +++ b/data/images/objects/bonus_block/purpleblock.sprite @@ -21,6 +21,8 @@ (displacement-texture (file "displacement.png"))))) (linked-sprites - (on-light "images/objects/lightmap_light/bonusblock_light.png") + (on-light + (file "images/objects/lightmap_light/bonusblock_light.png") + ) ) ) diff --git a/data/images/objects/bonus_block/retroblock.sprite b/data/images/objects/bonus_block/retroblock.sprite index 19281347468..08bb6c03376 100644 --- a/data/images/objects/bonus_block/retroblock.sprite +++ b/data/images/objects/bonus_block/retroblock.sprite @@ -12,6 +12,8 @@ (displacement-texture (file "displacement.png"))))) (linked-sprites - (on-light "images/objects/lightmap_light/bonusblock_light.png") + (on-light + (file "images/objects/lightmap_light/bonusblock_light.png") + ) ) ) diff --git a/data/images/objects/bullets/firebullet.sprite b/data/images/objects/bullets/firebullet.sprite index bb82049fc83..3f7532a2a68 100644 --- a/data/images/objects/bullets/firebullet.sprite +++ b/data/images/objects/bullets/firebullet.sprite @@ -9,6 +9,10 @@ ) (linked-sprites - (light "images/objects/lightmap_light/lightmap_light-small.sprite" "default" 0.3 0.1 0) + (custom-light + (file "images/objects/lightmap_light/lightmap_light-small.sprite") + (action "default") + (color 0.3 0.1 0) + ) ) ) diff --git a/data/images/objects/candle/candle.sprite b/data/images/objects/candle/candle.sprite index 92fc273fd9e..32c452335d7 100644 --- a/data/images/objects/candle/candle.sprite +++ b/data/images/objects/candle/candle.sprite @@ -15,8 +15,14 @@ (hitbox 2 22 32 32) (fps 16) (linked-sprites - (light-1 "candle-light-1.sprite" "white") - (light-2 "candle-light-2.sprite" "white") + (light-1 + (file "candle-light-1.sprite") + (action "white") + ) + (light-2 + (file "candle-light-2.sprite") + (action "white") + ) ) (images "candle-1.png" @@ -38,8 +44,14 @@ (hitbox 2 22 32 32) (fps 16) (linked-sprites - (light-1 "candle-light-1.sprite" "white") - (light-2 "candle-light-2.sprite" "white") + (light-1 + (file "candle-light-1.sprite") + (action "white") + ) + (light-2 + (file "candle-light-2.sprite") + (action "white") + ) ) (images "candle-1.png" @@ -50,8 +62,14 @@ ) (linked-sprites - (light-1 "candle-light-1.sprite") - (light-2 "candle-light-2.sprite") - (smoke "images/particles/smoke.sprite") + (light-1 + (file "candle-light-1.sprite") + ) + (light-2 + (file "candle-light-2.sprite") + ) + (smoke + (file "images/particles/smoke.sprite") + ) ) ) diff --git a/data/images/objects/door/door.sprite b/data/images/objects/door/door.sprite index 08c19bb6043..dd7a3070f6d 100644 --- a/data/images/objects/door/door.sprite +++ b/data/images/objects/door/door.sprite @@ -43,6 +43,8 @@ ) (linked-sprites - (lock "door_lock.sprite") + (lock + (file "door_lock.sprite") + ) ) ) diff --git a/data/images/objects/explosion/explosion_large.sprite b/data/images/objects/explosion/explosion_large.sprite index 3a65a145d09..6838777cc18 100644 --- a/data/images/objects/explosion/explosion_large.sprite +++ b/data/images/objects/explosion/explosion_large.sprite @@ -27,6 +27,10 @@ ) (linked-sprites - (light "images/objects/lightmap_light/lightmap_light-large.sprite" "default" 1 0.5 0.2) + (custom-light + (file "images/objects/lightmap_light/lightmap_light-large.sprite") + (action "default") + (color 1 0.5 0.2) + ) ) ) diff --git a/data/images/objects/explosion/explosion_medium.sprite b/data/images/objects/explosion/explosion_medium.sprite index bf99260b5e3..11407bc3a73 100644 --- a/data/images/objects/explosion/explosion_medium.sprite +++ b/data/images/objects/explosion/explosion_medium.sprite @@ -27,6 +27,10 @@ ) (linked-sprites - (light "images/objects/lightmap_light/lightmap_light-medium.sprite" "default" 1 0.5 0.2) + (custom-light + (file "images/objects/lightmap_light/lightmap_light-medium.sprite") + (action "default") + (color 1 0.5 0.2) + ) ) ) diff --git a/data/images/objects/firefly/firefly.sprite b/data/images/objects/firefly/firefly.sprite index 8049e866b91..ce4731decbe 100644 --- a/data/images/objects/firefly/firefly.sprite +++ b/data/images/objects/firefly/firefly.sprite @@ -26,6 +26,8 @@ ) ) (linked-sprites - (reset "images/particles/reset.sprite") + (reset + (file "images/particles/reset.sprite") + ) ) ) diff --git a/data/images/objects/keys/key.sprite b/data/images/objects/keys/key.sprite index 757fff04ae2..884f7c417e8 100644 --- a/data/images/objects/keys/key.sprite +++ b/data/images/objects/keys/key.sprite @@ -10,8 +10,16 @@ (mirror-action "silver-right")) (linked-sprites - (light "images/objects/lightmap_light/lightmap_light-small.sprite") - (sparkle-small "images/particles/sparkle.sprite" "small") - (sparkle-collect "images/particles/sparkle.sprite" "small-key-collect") + (custom-light + (file "images/objects/lightmap_light/lightmap_light-small.sprite") + ) + (sparkle-small + (file "images/particles/sparkle.sprite") + (action "small") + ) + (sparkle-collect + (file "images/particles/sparkle.sprite") + (action "small-key-collect") + ) ) ) diff --git a/data/images/objects/lantern/lantern.sprite b/data/images/objects/lantern/lantern.sprite index 1ab57ddb589..a59dfdf5985 100644 --- a/data/images/objects/lantern/lantern.sprite +++ b/data/images/objects/lantern/lantern.sprite @@ -22,6 +22,8 @@ ) (linked-sprites - (light "images/objects/lightmap_light/lightmap_light.sprite") + (custom-light + (file "images/objects/lightmap_light/lightmap_light.sprite") + ) ) ) diff --git a/data/images/objects/resetpoints/bell.sprite b/data/images/objects/resetpoints/bell.sprite index b3e4203a419..845bb219bff 100644 --- a/data/images/objects/resetpoints/bell.sprite +++ b/data/images/objects/resetpoints/bell.sprite @@ -19,6 +19,8 @@ (hitbox 8 5 32 32) ) (linked-sprites - (reset "images/particles/reset.sprite") + (reset + (file "images/particles/reset.sprite") + ) ) ) diff --git a/data/images/objects/resetpoints/default-resetpoint.sprite b/data/images/objects/resetpoints/default-resetpoint.sprite index b3e4203a419..845bb219bff 100644 --- a/data/images/objects/resetpoints/default-resetpoint.sprite +++ b/data/images/objects/resetpoints/default-resetpoint.sprite @@ -19,6 +19,8 @@ (hitbox 8 5 32 32) ) (linked-sprites - (reset "images/particles/reset.sprite") + (reset + (file "images/particles/reset.sprite") + ) ) ) diff --git a/data/images/objects/resetpoints/firefly.sprite b/data/images/objects/resetpoints/firefly.sprite index fa062684e42..014dbed0f8c 100644 --- a/data/images/objects/resetpoints/firefly.sprite +++ b/data/images/objects/resetpoints/firefly.sprite @@ -20,6 +20,8 @@ ) ) (linked-sprites - (reset "images/particles/reset.sprite") + (reset + (file "images/particles/reset.sprite") + ) ) ) diff --git a/data/images/objects/resetpoints/torch.sprite b/data/images/objects/resetpoints/torch.sprite index 5fc8e7494cc..c39046296cf 100644 --- a/data/images/objects/resetpoints/torch.sprite +++ b/data/images/objects/resetpoints/torch.sprite @@ -27,7 +27,13 @@ ) (linked-sprites - (light "torch_light.sprite" "default" 0.87 0.64 0.12) - (reset "images/particles/reset.sprite") + (custom-light + (file "torch_light.sprite") + (action "default") + (color 0.87 0.64 0.12) + ) + (reset + (file "images/particles/reset.sprite") + ) ) ) diff --git a/data/images/objects/resetpoints/vbell.sprite b/data/images/objects/resetpoints/vbell.sprite index 6d2a7e58c42..6e40be8e125 100644 --- a/data/images/objects/resetpoints/vbell.sprite +++ b/data/images/objects/resetpoints/vbell.sprite @@ -19,6 +19,8 @@ ) ) (linked-sprites - (reset "images/particles/reset.sprite") + (reset + (file "images/particles/reset.sprite") + ) ) ) diff --git a/data/images/objects/rublight/rublight.sprite b/data/images/objects/rublight/rublight.sprite index 80fab52ff15..7d0592d58e9 100644 --- a/data/images/objects/rublight/rublight.sprite +++ b/data/images/objects/rublight/rublight.sprite @@ -21,6 +21,8 @@ ) (linked-sprites - (light "images/objects/lightmap_light/lightmap_light.sprite") + (custom-light + (file "images/objects/lightmap_light/lightmap_light.sprite") + ) ) ) diff --git a/data/images/objects/torch/torch1.sprite b/data/images/objects/torch/torch1.sprite index 8f43182aaae..c5dd94566f6 100644 --- a/data/images/objects/torch/torch1.sprite +++ b/data/images/objects/torch/torch1.sprite @@ -6,8 +6,14 @@ ) (linked-sprites - (flame "flame.sprite") - (glow "flame_glow.sprite") - (light "flame_light.sprite") + (flame + (file "flame.sprite") + ) + (glow + (file "flame_glow.sprite") + ) + (custom-light + (file "flame_light.sprite") + ) ) ) diff --git a/data/images/objects/torch/torch2.sprite b/data/images/objects/torch/torch2.sprite index c570ecc1a09..afb25596584 100644 --- a/data/images/objects/torch/torch2.sprite +++ b/data/images/objects/torch/torch2.sprite @@ -6,8 +6,14 @@ ) (linked-sprites - (flame "flame.sprite") - (glow "flame_glow.sprite") - (light "flame_light.sprite") + (flame + (file "flame.sprite") + ) + (glow + (file "flame_glow.sprite") + ) + (custom-light + (file "flame_light.sprite") + ) ) ) diff --git a/data/images/objects/torch/torch3.sprite b/data/images/objects/torch/torch3.sprite index c698d6a9a85..6f6897cdbd6 100644 --- a/data/images/objects/torch/torch3.sprite +++ b/data/images/objects/torch/torch3.sprite @@ -6,8 +6,14 @@ ) (linked-sprites - (flame "flame.sprite") - (glow "flame_glow.sprite") - (light "flame_light.sprite") + (flame + (file "flame.sprite") + ) + (glow + (file "flame_glow.sprite") + ) + (custom-light + (file "flame_light.sprite") + ) ) ) diff --git a/data/images/objects/torch/torch4.sprite b/data/images/objects/torch/torch4.sprite index a1d785bafab..5827d6fd3c9 100644 --- a/data/images/objects/torch/torch4.sprite +++ b/data/images/objects/torch/torch4.sprite @@ -6,8 +6,14 @@ ) (linked-sprites - (flame "flame.sprite") - (glow "flame_glow.sprite") - (light "flame_light.sprite") + (flame + (file "flame.sprite") + ) + (glow + (file "flame_glow.sprite") + ) + (custom-light + (file "flame_light.sprite") + ) ) ) diff --git a/data/images/objects/weak_block/strawbox.sprite b/data/images/objects/weak_block/strawbox.sprite index 6e42003dd9a..efc10697b29 100644 --- a/data/images/objects/weak_block/strawbox.sprite +++ b/data/images/objects/weak_block/strawbox.sprite @@ -32,6 +32,8 @@ ) (linked-sprites - (burn-light "images/objects/lightmap_light/lightmap_light-small.sprite") + (burn-light + (file "images/objects/lightmap_light/lightmap_light-small.sprite") + ) ) ) diff --git a/data/images/particles/sparkle.sprite b/data/images/particles/sparkle.sprite index f6b09b48014..8dd24e00da7 100644 --- a/data/images/particles/sparkle.sprite +++ b/data/images/particles/sparkle.sprite @@ -24,7 +24,10 @@ "sparkle-dark-0.png" ) (linked-sprites - (light "images/objects/lightmap_light/lightmap_light-tiny.sprite" "" 0.1 0.1 0.1) + (custom-light + (file "images/objects/lightmap_light/lightmap_light-tiny.sprite") + (color 0.1 0.1 0.1) + ) ) ) (action @@ -39,6 +42,8 @@ ) (linked-sprites - (light "images/objects/lightmap_light/lightmap_light-tiny.sprite") + (custom-light + (file "images/objects/lightmap_light/lightmap_light-tiny.sprite") + ) ) ) diff --git a/data/images/powerups/airflower/airflower.sprite b/data/images/powerups/airflower/airflower.sprite index 004045199eb..74f3e363043 100644 --- a/data/images/powerups/airflower/airflower.sprite +++ b/data/images/powerups/airflower/airflower.sprite @@ -9,6 +9,10 @@ "air_flower-1.png")) (linked-sprites - (light "images/objects/lightmap_light/lightmap_light-small.sprite" "default" 0.15 0 0.15) + (custom-light + (file "images/objects/lightmap_light/lightmap_light-small.sprite") + (action "default") + (color 0.15 0 0.15) + ) ) ) diff --git a/data/images/powerups/earthflower/earthflower.sprite b/data/images/powerups/earthflower/earthflower.sprite index 6ad70243108..f6c561f318f 100644 --- a/data/images/powerups/earthflower/earthflower.sprite +++ b/data/images/powerups/earthflower/earthflower.sprite @@ -9,6 +9,10 @@ "earth_flower-1.png")) (linked-sprites - (light "images/objects/lightmap_light/lightmap_light-small.sprite" "default" 0 0.3 0) + (custom-light + (file "images/objects/lightmap_light/lightmap_light-small.sprite") + (action "default") + (color 0 0.3 0) + ) ) ) diff --git a/data/images/powerups/egg/egg.sprite b/data/images/powerups/egg/egg.sprite index 53377f80493..c6261dec098 100644 --- a/data/images/powerups/egg/egg.sprite +++ b/data/images/powerups/egg/egg.sprite @@ -9,7 +9,14 @@ ) (linked-sprites - (shade "egg.sprite" "shadow") - (light "images/objects/lightmap_light/lightmap_light-small.sprite" "default" 0.2 0.2 0) + (shade + (file "egg.sprite") + (action "shadow") + ) + (custom-light + (file "images/objects/lightmap_light/lightmap_light-small.sprite") + (action "default") + (color 0.2 0.2 0) + ) ) ) diff --git a/data/images/powerups/fireflower/fireflower.sprite b/data/images/powerups/fireflower/fireflower.sprite index 5cf51d1d03e..cef8a970819 100644 --- a/data/images/powerups/fireflower/fireflower.sprite +++ b/data/images/powerups/fireflower/fireflower.sprite @@ -9,6 +9,10 @@ "fire_flower-1.png")) (linked-sprites - (light "images/objects/lightmap_light/lightmap_light-small.sprite" "default" 0.3 0 0) + (custom-light + (file "images/objects/lightmap_light/lightmap_light-small.sprite") + (action "default") + (color 0.3 0 0) + ) ) ) diff --git a/data/images/powerups/iceflower/iceflower.sprite b/data/images/powerups/iceflower/iceflower.sprite index 6d80b953e2d..2d8cca24828 100644 --- a/data/images/powerups/iceflower/iceflower.sprite +++ b/data/images/powerups/iceflower/iceflower.sprite @@ -9,6 +9,10 @@ "ice_flower-1.png")) (linked-sprites - (light "images/objects/lightmap_light/lightmap_light-small.sprite" "default" 0 0.1 0.2) + (custom-light + (file "images/objects/lightmap_light/lightmap_light-small.sprite") + (action "default") + (color 0 0.1 0.2) + ) ) ) diff --git a/data/images/powerups/star/star.sprite b/data/images/powerups/star/star.sprite index 670a5663c6a..0e230d5ae43 100644 --- a/data/images/powerups/star/star.sprite +++ b/data/images/powerups/star/star.sprite @@ -11,7 +11,13 @@ "star-1.png")) (linked-sprites - (light "images/objects/lightmap_light/lightmap_light-small.sprite" "default" 0.4 0.4 0.4) - (sparkle "images/particles/sparkle.sprite") + (custom-light + (file "images/objects/lightmap_light/lightmap_light-small.sprite") + (action "default") + (color 0.4 0.4 0.4) + ) + (sparkle + (file "images/particles/sparkle.sprite") + ) ) ) diff --git a/src/badguy/badguy.cpp b/src/badguy/badguy.cpp index d9229dc16cf..c2df37d41a1 100644 --- a/src/badguy/badguy.cpp +++ b/src/badguy/badguy.cpp @@ -166,9 +166,14 @@ BadGuy::draw(DrawingContext& context) { if (m_unfreeze_timer.started() && m_unfreeze_timer.get_timeleft() <= 1.f) { - m_sprite->draw(context.color(), draw_pos + Vector(graphicsRandom.randf(-3, 3), 0.f), m_layer - 1, m_flip); + const Vector draw_pos_shake = draw_pos + Vector(graphicsRandom.randf(-3, 3), 0.f); + + m_sprite->draw(context.color(), draw_pos_shake, m_layer - 1, m_flip); if (is_portable()) - m_freezesprite->draw(context.color(), draw_pos + Vector(graphicsRandom.randf(-3, 3), 0.f), m_layer); + m_freezesprite->draw(context.color(), draw_pos_shake, m_layer); + + for (auto& sprite : m_custom_sprites) + sprite->draw(context.color(), draw_pos_shake, m_layer - 1, m_flip); } else { @@ -176,14 +181,22 @@ BadGuy::draw(DrawingContext& context) m_freezesprite->draw(context.color(), get_pos(), m_layer); m_sprite->draw(context.color(), get_pos(), m_layer - 1, m_flip); + + for (auto& sprite : m_custom_sprites) + sprite->draw(context.color(), get_pos(), m_layer - 1, m_flip); } if (!m_frozen) { if (m_burning) + { m_burn_light_sprite->draw(context.light(), m_col.m_bbox.get_middle() + draw_offset, 0); - else if (m_light_sprite) - m_light_sprite->draw(context.light(), m_col.m_bbox.get_middle() + draw_offset, 0); + } + else + { + for (auto& sprite : m_light_sprites) + sprite->draw(context.light(), m_col.m_bbox.get_middle() + draw_offset, 0); + } } } } diff --git a/src/badguy/crusher.cpp b/src/badguy/crusher.cpp index 99baf782fc8..ff08e660dfe 100644 --- a/src/badguy/crusher.cpp +++ b/src/badguy/crusher.cpp @@ -495,8 +495,11 @@ Crusher::draw(DrawingContext& context) // Draw the whites of crusher's eyes even further behind. m_whites->draw(context.color(), draw_pos, m_layer, m_flip); - if (m_light_sprite) - m_light_sprite->draw(context.light(), m_col.m_bbox.get_middle() + draw_offset, m_layer + 3); + for (auto& sprite : m_custom_sprites) + sprite->draw(context.color(), draw_pos, m_layer + 2, m_flip); + + for (auto& sprite : m_light_sprites) + sprite->draw(context.light(), m_col.m_bbox.get_middle() + draw_offset, m_layer + 3); } ObjectSettings diff --git a/src/badguy/haywire.cpp b/src/badguy/haywire.cpp index 37ca071fe24..e93dbe2095e 100644 --- a/src/badguy/haywire.cpp +++ b/src/badguy/haywire.cpp @@ -230,7 +230,6 @@ Haywire::active_update(float dt_sec) void Haywire::draw(DrawingContext& context) { - m_sprite->draw(context.color(), get_pos(), m_layer, m_flip); if (stomped_timer.get_timeleft() < 0.05f && m_is_exploding) { m_exploding_sprite->set_blend(Blend::ADD); diff --git a/src/badguy/livefire.cpp b/src/badguy/livefire.cpp index 39a52ad92ae..b0c1def8b3a 100644 --- a/src/badguy/livefire.cpp +++ b/src/badguy/livefire.cpp @@ -129,7 +129,10 @@ LiveFire::kill_fall() m_physic.set_velocity_y(0); m_physic.set_acceleration_y(0); m_physic.enable_gravity(false); - m_light_sprite->set_color(Color(1.0f, 0.9f, 0.8f)); + + for (auto& sprite : m_light_sprites) + sprite->set_color(Color(1.0f, 0.9f, 0.8f)); + set_group(COLGROUP_DISABLED); state = STATE_DEAD; diff --git a/src/badguy/mrbomb.cpp b/src/badguy/mrbomb.cpp index 670c70965e2..34f67062d8e 100644 --- a/src/badguy/mrbomb.cpp +++ b/src/badguy/mrbomb.cpp @@ -155,8 +155,6 @@ MrBomb::active_update(float dt_sec) void MrBomb::draw(DrawingContext& context) { - m_sprite->draw(context.color(), get_pos(), m_layer, m_flip); - if (m_state == MB_STATE_TICKING) { m_exploding_sprite->set_blend(Blend::ADD); diff --git a/src/badguy/rcrystallo.cpp b/src/badguy/rcrystallo.cpp index 367c61dcb4b..aa1296363f0 100644 --- a/src/badguy/rcrystallo.cpp +++ b/src/badguy/rcrystallo.cpp @@ -144,15 +144,6 @@ RCrystallo::active_update(float dt_sec) } } -void -RCrystallo::draw(DrawingContext& context) -{ - context.push_transform(); - Vector draw_pos = get_pos() + m_physic.get_velocity() * context.get_time_offset(); - m_sprite->draw(context.color(), draw_pos, m_layer); - context.pop_transform(); -} - void RCrystallo::collision_solid(const CollisionHit& hit) { diff --git a/src/badguy/rcrystallo.hpp b/src/badguy/rcrystallo.hpp index b47ea645463..3aaed5d51f5 100644 --- a/src/badguy/rcrystallo.hpp +++ b/src/badguy/rcrystallo.hpp @@ -35,7 +35,6 @@ class RCrystallo final : public WalkingBadguy virtual GameObjectClasses get_class_types() const override { return WalkingBadguy::get_class_types().add(typeid(RCrystallo)); } virtual void active_update(float dt_sec) override; - virtual void draw(DrawingContext& context) override; virtual void collision_solid(const CollisionHit& hit) override; virtual HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit) override; virtual HitResponse collision_player(Player& player, const CollisionHit& hit) override; diff --git a/src/badguy/stalactite.cpp b/src/badguy/stalactite.cpp index bd6e78bfab8..5878ee0d0e8 100644 --- a/src/badguy/stalactite.cpp +++ b/src/badguy/stalactite.cpp @@ -192,13 +192,30 @@ Stalactite::draw(DrawingContext& context) if (get_state() == STATE_INIT || get_state() == STATE_INACTIVE) return; - if (state == STALACTITE_SQUISHED) { + if (state == STALACTITE_SQUISHED) + { m_sprite->draw(context.color(), get_pos(), LAYER_OBJECTS); - } else if (state == STALACTITE_SHAKING) { + + for (auto& sprite : m_custom_sprites) + sprite->draw(context.color(), get_pos(), LAYER_OBJECTS); + } + else if (state == STALACTITE_SHAKING) + { m_sprite->draw(context.color(), get_pos() + shake_delta, m_layer, m_flip); - } else { + + for (auto& sprite : m_custom_sprites) + sprite->draw(context.color(), get_pos() + shake_delta, m_layer, m_flip); + } + else + { m_sprite->draw(context.color(), get_pos(), m_layer, m_flip); + + for (auto& sprite : m_custom_sprites) + sprite->draw(context.color(), get_pos(), m_layer, m_flip); } + + for (auto& sprite : m_light_sprites) + sprite->draw(context.light(), m_col.m_bbox.get_middle(), 0); } void diff --git a/src/badguy/treewillowisp.cpp b/src/badguy/treewillowisp.cpp index 3e4a033e5fb..54d248db5ee 100644 --- a/src/badguy/treewillowisp.cpp +++ b/src/badguy/treewillowisp.cpp @@ -107,6 +107,12 @@ TreeWillOWisp::draw(DrawingContext& context) { m_sprite->draw(context.color(), get_pos(), m_layer); m_sprite->draw(context.light(), get_pos(), m_layer); + + for (auto& sprite : m_custom_sprites) + sprite->draw(context.color(), get_pos(), m_layer); + + for (auto& sprite : m_light_sprites) + sprite->draw(context.light(), m_col.m_bbox.get_middle(), 0); } void diff --git a/src/badguy/walking_candle.cpp b/src/badguy/walking_candle.cpp index 48ec3a1dbb5..5145f09c553 100644 --- a/src/badguy/walking_candle.cpp +++ b/src/badguy/walking_candle.cpp @@ -32,8 +32,8 @@ WalkingCandle::WalkingCandle(const ReaderMapping& reader) : m_lightcolor = Color(vColor); m_sprite->set_color(m_lightcolor); - if (m_light_sprite) - m_light_sprite->set_color(m_lightcolor); + for (auto& sprite : m_light_sprites) + sprite->set_color(m_lightcolor); m_countMe = false; } @@ -62,8 +62,8 @@ WalkingCandle::unfreeze(bool melt) BadGuy::unfreeze(melt); initialize(); m_sprite->set_color(m_lightcolor); - if (m_light_sprite) - m_light_sprite->set_color(m_lightcolor); + for (auto& sprite : m_light_sprites) + sprite->set_color(m_lightcolor); } HitResponse @@ -105,8 +105,8 @@ WalkingCandle::after_editor_set() WalkingBadguy::after_editor_set(); m_sprite->set_color(m_lightcolor); - if (m_light_sprite) - m_light_sprite->set_color(m_lightcolor); + for (auto& sprite : m_light_sprites) + sprite->set_color(m_lightcolor); } /* EOF */ diff --git a/src/badguy/willowisp.cpp b/src/badguy/willowisp.cpp index 78beed7ee73..3e396d87926 100644 --- a/src/badguy/willowisp.cpp +++ b/src/badguy/willowisp.cpp @@ -78,12 +78,12 @@ WillOWisp::WillOWisp(const ReaderMapping& reader) : SoundManager::current()->preload(SOUNDFILE); SoundManager::current()->preload("sounds/warp.wav"); - if (m_light_sprite) - { - m_light_sprite->set_color(Color(m_color.red * 0.2f, - m_color.green * 0.2f, - m_color.blue * 0.2f)); - } + + const Color light_color(m_color.red * 0.2f, + m_color.green * 0.2f, + m_color.blue * 0.2f); + for (auto& sprite : m_light_sprites) + sprite->set_color(light_color); m_sprite->set_color(m_color); set_action("idle"); @@ -102,12 +102,11 @@ WillOWisp::after_editor_set() { BadGuy::after_editor_set(); - if (m_light_sprite) - { - m_light_sprite->set_color(Color(m_color.red * 0.2f, - m_color.green * 0.2f, - m_color.blue * 0.2f)); - } + const Color light_color(m_color.red * 0.2f, + m_color.green * 0.2f, + m_color.blue * 0.2f); + for (auto& sprite : m_light_sprites) + sprite->set_color(light_color); m_sprite->set_color(m_color); } diff --git a/src/object/bullet.cpp b/src/object/bullet.cpp index aab4488b636..f591ab58ea7 100644 --- a/src/object/bullet.cpp +++ b/src/object/bullet.cpp @@ -30,7 +30,7 @@ Bullet::Bullet(const Vector& pos, const Vector& xm, Direction dir, BonusType typ physic(), life_count(3), sprite(), - lightsprite(), + lightsprites(), type(type_) { physic.set_velocity(xm); @@ -51,7 +51,7 @@ Bullet::Bullet(const Vector& pos, const Vector& xm, Direction dir, BonusType typ break; } - lightsprite = sprite->create_linked_light_sprite(); + lightsprites = sprite->create_custom_linked_sprites(true); m_col.m_bbox.set_pos(pos); m_col.m_bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height()); @@ -61,18 +61,22 @@ void Bullet::update(float dt_sec) { // Cause fireball color to flicker randomly. - if (lightsprite) + if (!lightsprites.empty()) { + Color light_color; if (graphicsRandom.rand(5) != 0) { - lightsprite->set_color(Color(0.3f + graphicsRandom.randf(10) / 100.0f, - 0.1f + graphicsRandom.randf(20.0f) / 100.0f, - graphicsRandom.randf(10.0f) / 100.0f)); + light_color = Color(0.3f + graphicsRandom.randf(10) / 100.0f, + 0.1f + graphicsRandom.randf(20.0f) / 100.0f, + graphicsRandom.randf(10.0f) / 100.0f); } else { - lightsprite->set_color(Color(0.3f, 0.1f, 0.0f)); + light_color = Color(0.3f, 0.1f, 0.0f); } + + for (auto& sprite : lightsprites) + sprite->set_color(light_color); } if (life_count <= 0) @@ -101,8 +105,8 @@ void Bullet::draw(DrawingContext& context) { sprite->draw(context.color(), get_pos(), LAYER_OBJECTS); - if (lightsprite) - lightsprite->draw(context.light(), m_col.m_bbox.get_middle(), 0); + for (auto& sprite : lightsprites) + sprite->draw(context.light(), m_col.m_bbox.get_middle(), 0); } void diff --git a/src/object/bullet.hpp b/src/object/bullet.hpp index 64cc50694c4..084a62c0d6e 100644 --- a/src/object/bullet.hpp +++ b/src/object/bullet.hpp @@ -56,7 +56,7 @@ class Bullet final : public MovingObject Physic physic; int life_count; SpritePtr sprite; - SpritePtr lightsprite; + std::vector lightsprites; BonusType type; private: diff --git a/src/object/decal.cpp b/src/object/decal.cpp index ba8f4b73f0e..ff7bd09f995 100644 --- a/src/object/decal.cpp +++ b/src/object/decal.cpp @@ -62,9 +62,12 @@ Decal::~Decal() void Decal::draw(DrawingContext& context) { - if (m_visible || m_fade_timer.started()) - m_sprite->draw(context.color(), get_pos(), m_layer, m_flip); - if (m_visible && m_sprite_timer.started()) + if (!m_visible) + return; + + if (m_fade_timer.started()) + MovingSprite::draw(context); + if (m_sprite_timer.started()) m_fade_sprite->draw(context.color(), get_pos(), m_layer, m_flip); } diff --git a/src/object/explosion.cpp b/src/object/explosion.cpp index 027f3a20796..283a0aa3f48 100644 --- a/src/object/explosion.cpp +++ b/src/object/explosion.cpp @@ -62,8 +62,8 @@ void Explosion::on_sprite_update() { MovingSprite::on_sprite_update(); - if (m_light_sprite) - m_light_sprite->get_color().alpha = 0.f; + for (auto& sprite : m_light_sprites) + sprite->get_color().alpha = 0.f; } void @@ -164,27 +164,31 @@ Explosion::update(float ) break; case E_STATE_EXPLODING: - if (m_light_sprite) - m_light_sprite->get_color().alpha = std::min(m_fading_timer.get_progress(), 1.f); + { + const float light_alpha = std::min(m_fading_timer.get_progress(), 1.f); + for (auto& sprite : m_light_sprites) + sprite->get_color().alpha = light_alpha; if (m_fading_timer.check()) { m_fading_timer.start(short_fuse ? .85f : 1.5f); m_state = E_STATE_FADING; } - - break; + } + break; case E_STATE_FADING: - if (m_light_sprite) - m_light_sprite->get_color().alpha = std::max(1.f - m_fading_timer.get_progress(), 0.f); + { + const float light_alpha = std::min(m_fading_timer.get_progress(), 1.f); + for (auto& sprite : m_light_sprites) + sprite->get_color().alpha = light_alpha; if (m_fading_timer.check()) { remove_me(); } - - break; + } + break; } } diff --git a/src/object/fallblock.cpp b/src/object/fallblock.cpp index 2fd245b32e2..e6c69b75f52 100644 --- a/src/object/fallblock.cpp +++ b/src/object/fallblock.cpp @@ -106,14 +106,21 @@ FallBlock::collision_solid(const CollisionHit& hit) void FallBlock::draw(DrawingContext& context) { - Vector pos = get_pos(); // shaking + Vector offset; if (m_state == SHAKE) { - pos.x += static_cast(graphicsRandom.rand(-8, 8)); - pos.y += static_cast(graphicsRandom.rand(-5, 5)); + offset.x = static_cast(graphicsRandom.rand(-8, 8)); + offset.y = static_cast(graphicsRandom.rand(-5, 5)); } - m_sprite->draw(context.color(), pos, m_layer, m_flip); + + m_sprite->draw(context.color(), get_pos() + offset, m_layer, m_flip); + + for (auto& sprite : m_custom_sprites) + sprite->draw(context.color(), get_pos() + offset, m_layer, m_flip); + + for (auto& sprite : m_light_sprites) + sprite->draw(context.light(), m_col.m_bbox.get_middle() + offset, 0); } bool diff --git a/src/object/firefly.cpp b/src/object/firefly.cpp index 22e3b254f2b..03c2f0662c8 100644 --- a/src/object/firefly.cpp +++ b/src/object/firefly.cpp @@ -53,8 +53,14 @@ Firefly::draw(DrawingContext& context) { m_sprite->draw(context.color(), get_pos(), m_layer, m_flip); - if (m_light_sprite && (activated || m_sprite->get_action() == "ringing")) - m_light_sprite->draw(context.light(), m_col.m_bbox.get_middle(), 0, m_flip); + for (auto& sprite : m_custom_sprites) + sprite->draw(context.color(), get_pos(), m_layer, m_flip); + + if (activated || m_sprite->get_action() == "ringing") + { + for (auto& sprite : m_light_sprites) + sprite->draw(context.light(), m_col.m_bbox.get_middle(), 0, m_flip); + } } void diff --git a/src/object/flower.cpp b/src/object/flower.cpp index e59cb58c998..36f9af03ccc 100644 --- a/src/object/flower.cpp +++ b/src/object/flower.cpp @@ -26,7 +26,7 @@ Flower::Flower(BonusType _type, const std::string& custom_sprite) : type(_type), sprite(), flip(NO_FLIP), - lightsprite() + lightsprites() { m_col.m_bbox.set_size(32, 32); @@ -50,7 +50,7 @@ Flower::Flower(BonusType _type, const std::string& custom_sprite) : assert(false); } - lightsprite = sprite->create_linked_light_sprite(); + lightsprites = sprite->create_custom_linked_sprites(true); set_group(COLGROUP_TOUCHABLE); } @@ -64,8 +64,8 @@ void Flower::draw(DrawingContext& context) { sprite->draw(context.color(), get_pos(), LAYER_OBJECTS, flip); - if (lightsprite) - lightsprite->draw(context.light(), m_col.m_bbox.get_middle(), 0); + for (auto& sprite : lightsprites) + sprite->draw(context.light(), m_col.m_bbox.get_middle(), 0); } HitResponse diff --git a/src/object/flower.hpp b/src/object/flower.hpp index d371368dc63..fc70ac82314 100644 --- a/src/object/flower.hpp +++ b/src/object/flower.hpp @@ -48,7 +48,7 @@ class Flower final : public MovingObject SpritePtr sprite; Flip flip; - SpritePtr lightsprite; + std::vector lightsprites; private: Flower(const Flower&) = delete; diff --git a/src/object/invisible_block.cpp b/src/object/invisible_block.cpp index 733193e7dc3..8cd446a8cb9 100644 --- a/src/object/invisible_block.cpp +++ b/src/object/invisible_block.cpp @@ -55,7 +55,7 @@ void InvisibleBlock::draw(DrawingContext& context) { if (visible || Editor::is_active()) - m_sprite->draw(context.color(), get_pos(), LAYER_OBJECTS); + Block::draw(context); } bool diff --git a/src/object/key.cpp b/src/object/key.cpp index 4e1b586b6f7..fe922ece1f5 100644 --- a/src/object/key.cpp +++ b/src/object/key.cpp @@ -45,8 +45,8 @@ Key::Key(const ReaderMapping& reader) : if (reader.get("color", vColor)) { m_color = Color(vColor); } - if (m_light_sprite) - m_light_sprite->set_color(m_color); + for (auto& sprite : m_light_sprites) + sprite->set_color(m_color); // TODO: Add proper sound SoundManager::current()->preload("sounds/metal_hit.ogg"); @@ -186,8 +186,11 @@ Key::draw(DrawingContext& context) m_sprite->draw(context.color(), get_pos(), m_layer, m_flip); - if (m_light_sprite) - m_light_sprite->draw(context.light(), m_col.m_bbox.get_middle(), m_layer + 1); + for (auto& sprite : m_custom_sprites) + sprite->draw(context.light(), get_pos(), m_layer, m_flip); + + for (auto& sprite : m_light_sprites) + sprite->draw(context.light(), m_col.m_bbox.get_middle(), m_layer + 1); } ObjectSettings @@ -207,8 +210,8 @@ Key::after_editor_set() { MovingSprite::after_editor_set(); - if (m_light_sprite) - m_light_sprite->set_color(m_color); + for (auto& sprite : m_light_sprites) + sprite->set_color(m_color); m_sprite->set_color(m_color); } diff --git a/src/object/lantern.cpp b/src/object/lantern.cpp index 232e7e5270b..13767bcba44 100644 --- a/src/object/lantern.cpp +++ b/src/object/lantern.cpp @@ -72,8 +72,8 @@ Lantern::after_editor_set() void Lantern::updateColor() { - if (m_light_sprite) - m_light_sprite->set_color(lightcolor); + for (auto& sprite : m_light_sprites) + sprite->set_color(lightcolor); //Turn lantern off if light is black if (lightcolor.red == 0 && lightcolor.green == 0 && lightcolor.blue == 0){ set_action("off"); @@ -90,8 +90,8 @@ Lantern::draw(DrawingContext& context //Draw the Sprite. MovingSprite::draw(context); //Let there be light. - if (m_light_sprite) - m_light_sprite->draw(context.light(), m_col.m_bbox.get_middle(), 0); + for (auto& sprite : m_light_sprites) + sprite->draw(context.light(), m_col.m_bbox.get_middle(), 0); } HitResponse diff --git a/src/object/lit_object.cpp b/src/object/lit_object.cpp index 8c438295642..9f011eb8853 100644 --- a/src/object/lit_object.cpp +++ b/src/object/lit_object.cpp @@ -40,11 +40,12 @@ LitObject::LitObject(const ReaderMapping& reader) : reader.get("action", m_sprite_action); reader.get("light-action", m_light_sprite_action); - m_light_sprite = SpriteManager::current()->create(m_light_sprite_name); - m_light_sprite->set_blend(Blend::ADD); + m_light_sprites.clear(); + m_light_sprites.push_back(SpriteManager::current()->create(m_light_sprite_name)); + m_light_sprites[0]->set_blend(Blend::ADD); set_action(m_sprite_action); - m_light_sprite->set_action(m_light_sprite_action); + m_light_sprites[0]->set_action(m_light_sprite_action); set_group(COLGROUP_DISABLED); } @@ -53,7 +54,7 @@ void LitObject::draw(DrawingContext& context) { m_sprite->draw(context.color(), get_pos(), m_layer - 1, m_flip); - m_light_sprite->draw(context.light(), get_pos() - m_light_offset, m_layer - 1, m_flip); + m_light_sprites[0]->draw(context.light(), get_pos() - m_light_offset, m_layer - 1, m_flip); } void @@ -82,11 +83,12 @@ LitObject::after_editor_set() { MovingSprite::after_editor_set(); - m_light_sprite = SpriteManager::current()->create(m_light_sprite_name); - m_light_sprite->set_blend(Blend::ADD); + m_light_sprites.clear(); + m_light_sprites.push_back(SpriteManager::current()->create(m_light_sprite_name)); + m_light_sprites[0]->set_blend(Blend::ADD); set_action(m_sprite_action); - m_light_sprite->set_action(m_light_sprite_action); + m_light_sprites[0]->set_action(m_light_sprite_action); } void @@ -99,13 +101,13 @@ LitObject::on_flip(float height) const std::string& LitObject::get_light_action() const { - return m_light_sprite->get_action(); + return m_light_sprites[0]->get_action(); } void LitObject::set_light_action(const std::string& action) { - m_light_sprite->set_action(action); + m_light_sprites[0]->set_action(action); } diff --git a/src/object/moving_sprite.cpp b/src/object/moving_sprite.cpp index 2c88f06d302..c00e6262ad8 100644 --- a/src/object/moving_sprite.cpp +++ b/src/object/moving_sprite.cpp @@ -35,7 +35,8 @@ MovingSprite::MovingSprite(const Vector& pos, const std::string& sprite_name_, m_sprite_name(sprite_name_), m_default_sprite_name(sprite_name_), m_sprite(), - m_light_sprite(), + m_light_sprites(), + m_custom_sprites(), m_layer(layer_), m_flip(NO_FLIP), m_sprite_found(false), @@ -58,7 +59,8 @@ MovingSprite::MovingSprite(const ReaderMapping& reader, const std::string& sprit m_sprite_name(sprite_name_), m_default_sprite_name(sprite_name_), m_sprite(), - m_light_sprite(), + m_light_sprites(), + m_custom_sprites(), m_layer(layer_), m_flip(NO_FLIP), m_sprite_found(false), @@ -81,7 +83,8 @@ MovingSprite::MovingSprite(const ReaderMapping& reader, int layer_, CollisionGro m_sprite_name(), m_default_sprite_name(), m_sprite(), - m_light_sprite(), + m_light_sprites(), + m_custom_sprites(), m_layer(layer_), m_flip(NO_FLIP), m_sprite_found(false), @@ -100,8 +103,11 @@ MovingSprite::draw(DrawingContext& context) { m_sprite->draw(context.color(), get_pos(), m_layer, m_flip); - if (m_light_sprite) - m_light_sprite->draw(context.light(), m_col.m_bbox.get_middle(), 0); + for (auto& sprite : m_custom_sprites) + sprite->draw(context.color(), get_pos(), m_layer, m_flip); + + for (auto& sprite : m_light_sprites) + sprite->draw(context.light(), m_col.m_bbox.get_middle(), 0); } void @@ -203,8 +209,9 @@ MovingSprite::on_sprite_update() // Update hitbox update_hitbox(); - // Update light sprite - m_light_sprite = m_sprite->create_linked_light_sprite(); + // Update custom sprites + m_light_sprites = m_sprite->create_custom_linked_sprites(true); + m_custom_sprites = m_sprite->create_custom_linked_sprites(false); // Update other linked sprites auto linked_sprites = get_linked_sprites(); diff --git a/src/object/moving_sprite.hpp b/src/object/moving_sprite.hpp index f66370829c7..41621b5c6d6 100644 --- a/src/object/moving_sprite.hpp +++ b/src/object/moving_sprite.hpp @@ -166,7 +166,8 @@ class MovingSprite : public MovingObject so support for sprite switching for object types is retained. */ std::string m_default_sprite_name; SpritePtr m_sprite; - SpritePtr m_light_sprite; + std::vector m_light_sprites; + std::vector m_custom_sprites; int m_layer; /**< Sprite's z-position. Refer to video/drawing_context.hpp for sensible values. */ Flip m_flip; diff --git a/src/object/powerup.cpp b/src/object/powerup.cpp index 8ec6333c698..75d61ee2090 100644 --- a/src/object/powerup.cpp +++ b/src/object/powerup.cpp @@ -265,14 +265,11 @@ PowerUp::update(float dt_sec) void PowerUp::draw(DrawingContext& context) { - m_sprite->draw(context.color(), get_pos(), m_layer, m_flip); + MovingSprite::draw(context); // Stars and herrings are brighter. if (m_type == STAR || m_type == HERRING) m_sprite->draw(context.color(), get_pos(), m_layer, m_flip); - - if (m_light_sprite) - m_light_sprite->draw(context.light(), m_col.m_bbox.get_middle(), 0); } ObjectSettings diff --git a/src/object/rock.cpp b/src/object/rock.cpp index c6762141741..f5e8794943a 100644 --- a/src/object/rock.cpp +++ b/src/object/rock.cpp @@ -277,8 +277,14 @@ Rock::ungrab(MovingObject& object, Direction dir) void Rock::draw(DrawingContext& context) { - Vector offset = physic.get_velocity() * context.get_time_offset(); + const Vector offset = physic.get_velocity() * context.get_time_offset(); m_sprite->draw(context.color(), get_pos() + offset, m_layer, m_flip); + + for (auto& sprite : m_custom_sprites) + sprite->draw(context.color(), get_pos() + offset, m_layer, m_flip); + + for (auto& sprite : m_light_sprites) + sprite->draw(context.light(), m_col.m_bbox.get_middle(), 0); } ObjectSettings diff --git a/src/object/rublight.cpp b/src/object/rublight.cpp index e1d43776e4b..1e178cfadfb 100644 --- a/src/object/rublight.cpp +++ b/src/object/rublight.cpp @@ -135,14 +135,18 @@ RubLight::draw(DrawingContext& context) { float brightness = get_brightness(); Color col = color.multiply_linearly(brightness); - if (m_light_sprite) + + for (auto& sprite : m_light_sprites) { - m_light_sprite->set_color(col); - m_light_sprite->draw(context.light(), get_pos(), m_layer); + sprite->set_color(col); + sprite->draw(context.light(), get_pos(), m_layer); } } m_sprite->draw(context.color(), get_pos(), m_layer, m_flip); + + for (auto& sprite : m_custom_sprites) + sprite->draw(context.light(), get_pos(), m_layer, m_flip); } void diff --git a/src/object/sprite_particle.cpp b/src/object/sprite_particle.cpp index ba41ca066da..0cea744522c 100644 --- a/src/object/sprite_particle.cpp +++ b/src/object/sprite_particle.cpp @@ -26,46 +26,52 @@ SpriteParticle::SpriteParticle(const std::string& sprite_name, const std::string& action, const Vector& position_, AnchorPoint anchor, const Vector& velocity_, const Vector& acceleration_, - int drawing_layer_, bool notimeout, Color color_) : + int drawing_layer_, bool notimeout, Color color) : SpriteParticle(SpriteManager::current()->create(sprite_name), action, position_, anchor, velocity_, acceleration_, - drawing_layer_, notimeout, color_) + drawing_layer_, notimeout, color) { } SpriteParticle::SpriteParticle(const SpriteData::LinkedSprite& linked_sprite, const Vector& position_, AnchorPoint anchor, const Vector& velocity_, const Vector& acceleration_, - int drawing_layer_, bool notimeout, Color color_) : - SpriteParticle(SpriteManager::current()->create(linked_sprite.file), linked_sprite.action.empty() ? "default" : linked_sprite.action, + int drawing_layer_, bool notimeout, Color color) : + SpriteParticle(SpriteManager::current()->create(linked_sprite.file), linked_sprite.config.action.empty() ? "default" : linked_sprite.config.action, position_, anchor, velocity_, acceleration_, - drawing_layer_, notimeout, color_) + drawing_layer_, notimeout, color) { } SpriteParticle::SpriteParticle(SpritePtr sprite_, const std::string& action, const Vector& position_, AnchorPoint anchor, const Vector& velocity_, const Vector& acceleration_, - int drawing_layer_, bool notimeout, Color color_) : + int drawing_layer_, bool notimeout, Color color) : sprite(std::move(sprite_)), position(position_), velocity(velocity_), acceleration(acceleration_), drawing_layer(drawing_layer_), - lightsprite(), - no_time_out(false), - color(Color::WHITE) + lightsprites(), + no_time_out(false) { sprite->set_action(action, 1); sprite->set_animation_loops(1); //TODO: this is necessary because set_action will not set "loops" when "action" is the default action - sprite->set_color(color_); + sprite->set_color(color); position -= get_anchor_pos(sprite->get_current_hitbox(), anchor); no_time_out = notimeout; - lightsprite = sprite->create_linked_light_sprite(); - if (lightsprite) + for (const auto& sprite_data : sprite->get_custom_linked_sprites()) { - if (!sprite->get_linked_light_sprite()->color) - lightsprite->set_color(color_); + if (!sprite_data.light) + continue; + + SpritePtr sprite = SpriteManager::current()->create(sprite_data.file); + sprite->apply_config(sprite_data.config); + sprite->set_blend(Blend::ADD); + if (sprite_data.config.color == Color(1.0f, 1.0f, 1.0f, 1.0f)) + sprite->set_color(color); + + lightsprites.push_back(std::move(sprite)); } } @@ -104,10 +110,13 @@ SpriteParticle::draw(DrawingContext& context) Vector draw_pos = position + velocity * context.get_time_offset(); sprite->draw(context.color(), draw_pos, drawing_layer); - if (lightsprite) + if (!lightsprites.empty()) { sprite->draw(context.light(), draw_pos, drawing_layer); - lightsprite->draw(context.light(), draw_pos + Vector(12, 12), 0); + + draw_pos += Vector(12.f, 12.f); + for (auto& sprite : lightsprites) + sprite->draw(context.light(), draw_pos, 0); } } diff --git a/src/object/sprite_particle.hpp b/src/object/sprite_particle.hpp index 0c9b099192b..d021bafe3a2 100644 --- a/src/object/sprite_particle.hpp +++ b/src/object/sprite_particle.hpp @@ -58,9 +58,8 @@ class SpriteParticle final : public GameObject Vector velocity; Vector acceleration; int drawing_layer; - SpritePtr lightsprite; + std::vector lightsprites; bool no_time_out; - Color color; private: SpriteParticle(const SpriteParticle&) = delete; diff --git a/src/object/torch.cpp b/src/object/torch.cpp index 324cd366bee..cc797ca6c41 100644 --- a/src/object/torch.cpp +++ b/src/object/torch.cpp @@ -44,12 +44,13 @@ Torch::Torch(const ReaderMapping& reader) : m_light_color = Color(vColor); m_flame->set_color(m_light_color); m_flame_glow->set_color(m_light_color); - if (m_light_sprite) - m_light_sprite->set_color(m_light_color); + for (auto& sprite : m_light_sprites) + sprite->set_color(m_light_color); } m_flame->set_action(m_light_color.greyscale() >= 1.f ? "default" : "greyscale"); - m_light_sprite->set_action(m_light_color.greyscale() >= 1.f ? "default" : "greyscale"); + for (auto& sprite : m_light_sprites) + sprite->set_action(m_light_color.greyscale() >= 1.f ? "default" : "greyscale"); m_flame_glow->set_action(m_light_color.greyscale() >= 1.f ? "default" : "greyscale"); set_group(COLGROUP_TOUCHABLE); @@ -73,15 +74,16 @@ Torch::draw(DrawingContext& context) if (m_flip != NO_FLIP) pos.y -= 24.0f; m_flame->draw(context.color(), pos, m_layer - 1, m_flip); - if (m_light_sprite) - { - m_light_sprite->draw(context.light(), pos, m_layer); - } + for (auto& sprite : m_light_sprites) + sprite->draw(context.light(), pos, m_layer); m_flame_glow->draw(context.color(), pos, m_layer - 1, m_flip); } m_sprite->draw(context.color(), get_pos(), m_layer - 1, m_flip); + + for (auto& sprite : m_custom_sprites) + sprite->draw(context.color(), get_pos(), m_layer - 1, m_flip); } void @@ -120,11 +122,12 @@ Torch::after_editor_set() m_flame->set_color(m_light_color); m_flame_glow->set_color(m_light_color); - if (m_light_sprite) - m_light_sprite->set_color(m_light_color); + for (auto& sprite : m_light_sprites) + sprite->set_color(m_light_color); m_flame->set_action(m_light_color.greyscale() >= 1.f ? "default" : "greyscale"); - m_light_sprite->set_action(m_light_color.greyscale() >= 1.f ? "default" : "greyscale"); + for (auto& sprite : m_light_sprites) + sprite->set_action(m_light_color.greyscale() >= 1.f ? "default" : "greyscale"); m_flame_glow->set_action(m_light_color.greyscale() >= 1.f ? "default" : "greyscale"); } diff --git a/src/sprite/sprite.cpp b/src/sprite/sprite.cpp index 3daa2914835..5f87b7b7065 100644 --- a/src/sprite/sprite.cpp +++ b/src/sprite/sprite.cpp @@ -28,13 +28,13 @@ Sprite::Sprite(SpriteData& newdata) : m_data(newdata), m_frame(0), m_frameidx(0), - m_animation_loops(-1), m_last_ticks(), + m_is_paused(false), + m_animation_loops(-1), m_angle(0.0f), m_alpha(1.0f), m_color(1.0f, 1.0f, 1.0f, 1.0f), m_blend(), - m_is_paused(false), m_action(m_data.get_action("normal")) { if (!m_action) @@ -46,8 +46,8 @@ Sprite::Sprite(const Sprite& other) : m_data(other.m_data), m_frame(other.m_frame), m_frameidx(other.m_frameidx), - m_animation_loops(other.m_animation_loops), m_last_ticks(g_game_time), + m_animation_loops(other.m_animation_loops), m_angle(0.0f), // FIXME: this can't be right m_alpha(1.0f), m_color(1.0f, 1.0f, 1.0f, 1.0f), @@ -67,6 +67,18 @@ Sprite::clone() const return SpritePtr(new Sprite(*this)); } +void +Sprite::apply_config(const SpriteConfig& config) +{ + set_action(config.action); + + m_animation_loops = config.loops; + m_angle = config.angle; + m_alpha = config.alpha; + m_color = config.color; + m_blend = config.blend; +} + bool Sprite::set_action(const std::string& name, const Direction& dir, int loops) { @@ -213,28 +225,31 @@ Sprite::draw_scaled(Canvas& canvas, const Rectf& dest_rect, int layer, context.pop_transform(); } -const std::optional& -Sprite::get_linked_light_sprite() const +const std::vector& +Sprite::get_custom_linked_sprites() const { - return m_action->linked_light_sprite ? m_action->linked_light_sprite : m_data.linked_light_sprite; + return m_action->custom_linked_sprites.empty() ? m_data.custom_linked_sprites : m_action->custom_linked_sprites; } -SpritePtr -Sprite::create_linked_light_sprite() const +std::vector +Sprite::create_custom_linked_sprites(bool light) const { - const auto& sprite_data = get_linked_light_sprite(); + const auto& sprites_data = get_custom_linked_sprites(); - SpritePtr sprite; - if (sprite_data) + std::vector result; + for (const SpriteData::LinkedSprite& sprite_data : sprites_data) { - sprite = SpriteManager::current()->create(sprite_data->file); - if (!sprite_data->action.empty()) - sprite->set_action(sprite_data->action); - if (sprite_data->color) - sprite->set_color(*sprite_data->color); - sprite->set_blend(Blend::ADD); + if (sprite_data.light != light) + continue; + + SpritePtr sprite = SpriteManager::current()->create(sprite_data.file); + sprite->apply_config(sprite_data.config); + if (sprite_data.light) + sprite->set_blend(Blend::ADD); + + result.push_back(std::move(sprite)); } - return sprite; + return result; } bool @@ -269,10 +284,8 @@ Sprite::create_linked_sprite(const std::string& key) const const auto& sprite_data = get_linked_sprite(key); SpritePtr sprite = SpriteManager::current()->create(sprite_data.file); - if (sprite_data.action.empty()) - sprite->set_animation_loops(sprite_data.loops); - else - sprite->set_action(sprite_data.action, sprite_data.loops); + sprite->apply_config(sprite_data.config); + return sprite; } diff --git a/src/sprite/sprite.hpp b/src/sprite/sprite.hpp index 8b5ac32f2ac..a7e40c06030 100644 --- a/src/sprite/sprite.hpp +++ b/src/sprite/sprite.hpp @@ -36,6 +36,8 @@ class Sprite final SpritePtr clone() const; + void apply_config(const SpriteConfig& config); + /** Draw sprite, automatically calculates next frame */ void draw(Canvas& canvas, const Vector& pos, int layer, Flip flip = NO_FLIP); @@ -88,9 +90,9 @@ class Sprite final /** Get current action name */ inline const std::string& get_action() const { return m_action->name; } - /** Get linked light sprite */ - const std::optional& get_linked_light_sprite() const; - SpritePtr create_linked_light_sprite() const; + /** Get custom linked sprites */ + const std::vector& get_custom_linked_sprites() const; + std::vector create_custom_linked_sprites(bool light) const; /** Get linked sprite by key */ bool has_linked_sprite(const std::string& key) const; @@ -145,13 +147,14 @@ class Sprite final float m_frame; // between 0 and get_frames() int m_frameidx; - int m_animation_loops; float m_last_ticks; + bool m_is_paused; + + int m_animation_loops; float m_angle; float m_alpha; Color m_color; Blend m_blend; - bool m_is_paused; const SpriteData::Action* m_action; diff --git a/src/sprite/sprite_config.cpp b/src/sprite/sprite_config.cpp new file mode 100644 index 00000000000..659948cfd62 --- /dev/null +++ b/src/sprite/sprite_config.cpp @@ -0,0 +1,51 @@ +// SuperTux +// Copyright (C) 2006 Matthias Braun +// 2023-2024 Vankata453 +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#include "sprite/sprite_config.hpp" + +#include "util/reader_mapping.hpp" + +SpriteConfig::SpriteConfig() : + action(), + loops(-1), + angle(0.0f), + alpha(1.0f), + color(1.0f, 1.0f, 1.0f, 1.0f), + blend() +{ +} + +SpriteConfig::SpriteConfig(const ReaderMapping& reader) : + SpriteConfig() +{ + reader.get("action", action); + reader.get("loops", loops); + reader.get("angle", angle); + reader.get("alpha", alpha); + + std::vector v_color; + reader.get("color", v_color); + if (!v_color.empty()) + color = Color(v_color); + + std::string blend_str; + reader.get("blend", blend_str); + if (!blend_str.empty()) + blend = Blend_from_string(blend_str); +} + +/* EOF */ diff --git a/src/sprite/sprite_config.hpp b/src/sprite/sprite_config.hpp new file mode 100644 index 00000000000..775bfcedbd3 --- /dev/null +++ b/src/sprite/sprite_config.hpp @@ -0,0 +1,45 @@ +// SuperTux +// Copyright (C) 2024 Vankata453 +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#ifndef HEADER_SUPERTUX_SPRITE_SPRITE_CONFIG_HPP +#define HEADER_SUPERTUX_SPRITE_SPRITE_CONFIG_HPP + +#include + +#include "video/blend.hpp" +#include "video/color.hpp" + +class ReaderMapping; + +struct SpriteConfig final +{ +public: + SpriteConfig(); + SpriteConfig(const ReaderMapping& reader); + +public: + std::string action; + + int loops; + float angle; + float alpha; + Color color; + Blend blend; +}; + +#endif + +/* EOF */ diff --git a/src/sprite/sprite_data.cpp b/src/sprite/sprite_data.cpp index 60851d6b80b..424a3406311 100644 --- a/src/sprite/sprite_data.cpp +++ b/src/sprite/sprite_data.cpp @@ -35,8 +35,23 @@ #include "video/surface.hpp" #include "video/texture_manager.hpp" +LinkedSpritesContainer::LinkedSprite::LinkedSprite() : + file(), + config(), + light(false) +{ +} + +LinkedSpritesContainer::LinkedSprite::LinkedSprite(const std::string& file_, SpriteConfig config_, + bool light_) : + file(file_), + config(std::move(config_)), + light(light_) +{ +} + LinkedSpritesContainer::LinkedSpritesContainer() : - linked_light_sprite(), + custom_linked_sprites(), linked_sprites() { } @@ -44,46 +59,24 @@ LinkedSpritesContainer::LinkedSpritesContainer() : void LinkedSpritesContainer::parse_linked_sprites(const ReaderMapping& mapping) { - auto iter_sprites = mapping.get_iter(); - while (iter_sprites.next()) + auto iter = mapping.get_iter(); + while (iter.next()) { - const auto& sx = iter_sprites.as_mapping().get_sexp(); - const auto& arr = sx.as_array(); - - std::string filepath = FileSystem::join(mapping.get_doc().get_directory(), arr[1].as_string()); - if (!PHYSFS_exists(filepath.c_str())) // If file path is not relative to current directory, make it relative to root - filepath = arr[1].as_string(); + auto mapping = iter.as_mapping(); - const std::string key = arr[0].as_string(); - if (key == "light") // The key "light" is reserved for light sprites - { - linked_light_sprite = LinkedLightSprite(filepath); + std::string file; + mapping.get("file", file); - if (arr.size() >= 3) // Default action has been specified - { - linked_light_sprite->action = arr[2].as_string(); + std::string filepath = FileSystem::join(mapping.get_doc().get_directory(), file); + if (!PHYSFS_exists(filepath.c_str())) // If file path is not relative to current directory, make it relative to root + filepath = file; - if (arr.size() >= 6) // Color has been specified - { - linked_light_sprite->color = Color(arr[3].as_float(), arr[4].as_float(), - arr[5].as_float()); - } - } - } + if (iter.get_key() == "custom") + custom_linked_sprites.emplace_back(filepath, SpriteConfig(iter.as_mapping()), false); + else if (iter.get_key() == "custom-light") + custom_linked_sprites.emplace_back(filepath, SpriteConfig(iter.as_mapping()), true); else - { - LinkedSprite linked_sprite = LinkedSprite(filepath); - - if (arr.size() >= 3) // Default action has been specified - { - linked_sprite.action = arr[2].as_string(); - - if (arr.size() >= 4) // Default action loops have been specified - linked_sprite.loops = arr[3].as_int(); - } - - linked_sprites[key] = std::move(linked_sprite); - } + linked_sprites[iter.get_key()] = LinkedSprite(filepath, SpriteConfig(iter.as_mapping()), false); } } diff --git a/src/sprite/sprite_data.hpp b/src/sprite/sprite_data.hpp index 13fcdadbbc1..81b55b4c06e 100644 --- a/src/sprite/sprite_data.hpp +++ b/src/sprite/sprite_data.hpp @@ -24,6 +24,7 @@ #include #include +#include "sprite/sprite_config.hpp" #include "video/color.hpp" #include "video/surface_ptr.hpp" @@ -42,29 +43,18 @@ class LinkedSpritesContainer public: struct LinkedSprite final { - LinkedSprite(const std::string& file_ = {}) : - file(file_), action(), loops(-1) - {} + LinkedSprite(); + LinkedSprite(const std::string& file, SpriteConfig config, + bool light = false); std::string file; - std::string action; - int loops; + SpriteConfig config; + bool light; }; - struct LinkedLightSprite final - { - LinkedLightSprite(const std::string& file_ = {}) : - file(file_), action(), color() - {} - std::string file; - std::string action; - std::optional color; - }; - typedef std::unordered_map LinkedSprites; - -protected: - std::optional linked_light_sprite; - LinkedSprites linked_sprites; +public: + std::vector custom_linked_sprites; + std::unordered_map linked_sprites; }; class SpriteData final : public LinkedSpritesContainer