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

Improvements to object type support, object versioning #2542

Merged
merged 43 commits into from
Sep 2, 2023
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
3dcc414
Improvements to object type support
Vankata453 Jul 16, 2023
f5c25d8
PowerUp type support, object versioning
Vankata453 Jul 17, 2023
4f7429c
Merge remote-tracking branch 'origin/master' into object-type-improve…
Vankata453 Jul 17, 2023
d371a63
Only auto-update object, if added in editor
Vankata453 Jul 18, 2023
5d6f24a
Added objects from object select menu are auto-updated
Vankata453 Jul 18, 2023
33687df
Object versioning: Patch notes
Vankata453 Jul 18, 2023
3076f52
Update version on direct object addition and editor placement
Vankata453 Jul 19, 2023
1c323c4
Object types for jumpy, fish swimming and chasing
Vankata453 Jul 19, 2023
1385be1
Use default sprite for default type sprite, bomb types
Vankata453 Jul 19, 2023
f7bb635
Object types for bonus block and switch
Vankata453 Jul 19, 2023
3e2ee11
Object types for unstable tile and weak block
Vankata453 Jul 19, 2023
0393a5a
Object types for more badguys
Vankata453 Jul 20, 2023
8d3df03
Merge remote-tracking branch 'supertux/master' into object-type-impro…
Vankata453 Jul 22, 2023
07e9f82
Fix shadowing a member variable
Vankata453 Jul 22, 2023
51dfaed
Merge remote-tracking branch 'supertux/master' into object-type-impro…
Vankata453 Jul 24, 2023
e3b14ef
Merge remote-tracking branch 'supertux/master' into object-type-impro…
Vankata453 Jul 26, 2023
0a3d4e8
Merge remote-tracking branch 'supertux/master' into object-type-impro…
Vankata453 Jul 26, 2023
6f6ff05
Object type support for more objects
Vankata453 Jul 26, 2023
061af32
Object type fixes
Vankata453 Jul 26, 2023
6dfb4d4
Retro bonus block type changes default coin sprite
Vankata453 Jul 26, 2023
2c2c2cb
Change default type for `WeakBlock`
Vankata453 Jul 26, 2023
de42b36
Fix bugs within laptop iceblock freeze state
Vankata453 Jul 27, 2023
0c629de
Retro powerup types, bonus block support
Vankata453 Aug 2, 2023
3c7d40a
Merge remote-tracking branch 'supertux/master' into object-type-impro…
Vankata453 Aug 4, 2023
69c3e43
Corrupted object type for `LeafShot` and `Jumpy`
Vankata453 Aug 4, 2023
db0d477
Rename and move "coffee" and "herring" `BonusBlock` contents
Vankata453 Aug 4, 2023
3b7832d
Remove object types from Switch
Vankata453 Aug 8, 2023
0f4fca7
Merge branch 'master' into object-type-improvements
Vankata453 Aug 12, 2023
2378fe4
Fix incorrect comment in "fish_harmless.hpp"
Vankata453 Aug 12, 2023
67ef773
`SmartBlock` no longer inherits object types from `MrIceBlock`
Vankata453 Aug 12, 2023
fc3121a
Make `get_types()` a virtual method in `MrIceBlock`
Vankata453 Aug 12, 2023
36f9c16
"retrocompatibility" -> "retro-compatibility"
Vankata453 Aug 12, 2023
db38c40
Merge remote-tracking branch 'supertux/master' into object-type-impro…
Vankata453 Aug 22, 2023
bf30c28
"Fatbat" type for `BouncingSnowball`, freezing
Vankata453 Aug 23, 2023
35c7917
Remove inherited object types from `RustyTrampoline`
Vankata453 Aug 23, 2023
a608a26
Fix squishing frozen `SnowBall` and `SmartBall` with object types
Vankata453 Aug 23, 2023
6618842
Improve `WeakBlock` retrocompatibility code, remove "linked" property
Vankata453 Aug 23, 2023
31ccefe
Move definitions of `GameObject` versioning functions to "game_object…
Vankata453 Aug 23, 2023
c5ef429
Move `SkullTile` functionality into `UnstableTile`, using a type
Vankata453 Aug 24, 2023
e3714d2
Fix freeze/unfreeze behaviour of flat/kicked laptop
Vankata453 Aug 24, 2023
e9c4f93
Stop flat timer in `MrIceBlock::set_state`
Vankata453 Aug 24, 2023
efb0770
Laptop now gradually slows down, when frozen in its KICKED state
Vankata453 Aug 27, 2023
42d28e2
"persistent" -> "present"
Vankata453 Aug 27, 2023
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
10 changes: 10 additions & 0 deletions data/images/objects/bonus_block/retro_invisibleblock.sprite
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(supertux-sprite
(action
(name "default-editor")
(images "box-invisible.png")
)
(action
(name "empty")
(images "box-empty.png")
)
)
40 changes: 33 additions & 7 deletions src/badguy/crusher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ Crusher::Crusher(const ReaderMapping& reader) :
m_whites()
{
parse_type(reader);
on_type_change(-1);

reader.get("sideways", m_sideways);
// TODO: Add distinct sounds for crusher hitting the ground and hitting Tux.
Expand All @@ -74,22 +73,49 @@ Crusher::get_types() const
return {
{ "ice-krush", _("Ice (normal)") },
{ "ice-krosh", _("Ice (big)") },
{ "rock-krush", _("Rock (normal)") },
{ "rock-krosh", _("Rock (big)") },
{ "corrupted-krush", _("Corrupted (normal)") },
{ "corrupted-krosh", _("Corrupted (big)") }
};
}

std::string
Crusher::get_default_sprite_name() const
{
const std::string size_prefix = (m_ic_size == NORMAL ? "krush" : "krosh");
switch (m_ic_type)
{
case ROCK:
return "images/creatures/crusher/" + size_prefix + "_rock.sprite";
case CORRUPTED:
return "images/creatures/crusher/corrupted/" + size_prefix + "_corrupt.sprite";
default:
return "images/creatures/crusher/" + size_prefix + "_ice.sprite";
}
}

void
Crusher::on_type_change(int old_type)
{
m_ic_size = (m_type == 0 || m_type == 2 ? NORMAL : LARGE);
m_ic_type = (m_type == 0 || m_type == 1 ? ICE : CORRUPTED);

if (!has_found_sprite()) // Change sprite only if a custom sprite has not just been loaded.
m_ic_size = (m_type % 2 == 0 ? NORMAL : LARGE);
switch (m_type)
{
const std::string size_prefix = (m_ic_size == NORMAL ? "krush" : "krosh");
change_sprite("images/creatures/crusher/" + (m_ic_type == CORRUPTED ? "corrupted/" + size_prefix + "_corrupt" : size_prefix + "_ice") + ".sprite");
case 0:
case 1:
m_ic_type = ICE;
break;
case 2:
case 3:
m_ic_type = ROCK;
break;
case 4:
case 5:
m_ic_type = CORRUPTED;
break;
}

MovingSprite::on_type_change();
}

HitResponse
Expand Down
2 changes: 2 additions & 0 deletions src/badguy/crusher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class Crusher final : public MovingSprite
enum Type
{
ICE,
ROCK,
CORRUPTED
};

Expand All @@ -72,6 +73,7 @@ class Crusher final : public MovingSprite

virtual ObjectSettings get_settings() override;
GameObjectTypes get_types() const override;
std::string get_default_sprite_name() const override;

virtual void on_flip(float height) override;

Expand Down
22 changes: 15 additions & 7 deletions src/badguy/dispenser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ Dispenser::Dispenser(const ReaderMapping& reader) :
// if (badguys.size() <= 0)
// throw std::runtime_error("No badguys in dispenser.");

set_correct_action();

m_col.m_bbox.set_size(m_sprite->get_current_hitbox_width(), m_sprite->get_current_hitbox_height());
update_hitbox();
m_countMe = false;
}

Expand Down Expand Up @@ -343,9 +341,6 @@ Dispenser::is_portable() const
void
Dispenser::set_correct_action()
{
if (!has_found_sprite()) // Change sprite only if a custom sprite has not just been loaded.
change_sprite("images/creatures/dispenser/" + (m_type == DispenserType::POINT ? "invisible" : type_value_to_id(m_type)) + ".sprite");

switch (m_type)
{
case DispenserType::CANNON:
Expand All @@ -362,6 +357,7 @@ Dispenser::set_correct_action()
void
Dispenser::on_type_change(int old_type)
{
MovingSprite::on_type_change();
set_correct_action();
}

Expand Down Expand Up @@ -389,12 +385,24 @@ GameObjectTypes
Dispenser::get_types() const
{
return {
{ "cannon", _("cannon") },
{ "dropper", _("dropper") },
{ "cannon", _("cannon") },
{ "point", _("invisible") }
};
}

std::string
Dispenser::get_default_sprite_name() const
{
switch (m_type)
{
case POINT:
return "images/creatures/dispenser/invisible.sprite";
default:
return "images/creatures/dispenser/" + type_value_to_id(m_type) + ".sprite";
}
}

void
Dispenser::on_flip(float height)
{
Expand Down
3 changes: 2 additions & 1 deletion src/badguy/dispenser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Dispenser final : public BadGuy,
{
private:
enum DispenserType {
CANNON, DROPPER, POINT
DROPPER, CANNON, POINT
};

public:
Expand All @@ -55,6 +55,7 @@ class Dispenser final : public BadGuy,

virtual ObjectSettings get_settings() override;
virtual GameObjectTypes get_types() const override;
std::string get_default_sprite_name() const override;

virtual void on_flip(float height) override;

Expand Down
13 changes: 13 additions & 0 deletions src/badguy/fish_chasing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,24 @@ FishChasing::FishChasing(const ReaderMapping& reader) :
m_lost_distance(),
m_chase_speed()
{
parse_type(reader);
reader.get("track-distance", m_track_distance, TRACK_DISTANCE);
reader.get("lost-distance", m_lost_distance, LOST_DISTANCE);
reader.get("chase-speed", m_chase_speed, CHASE_SPEED);
}

std::string
FishChasing::get_default_sprite_name() const
{
switch (m_type)
{
case FOREST:
return "images/creatures/fish/forest/brownfish.sprite";
default:
return m_default_sprite_name;
}
}

void
FishChasing::active_update(float dt_sec) {
// Perform basic updates.
Expand Down
2 changes: 2 additions & 0 deletions src/badguy/fish_chasing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class FishChasing final : public FishSwimming
virtual std::string get_overlay_size() const override { return "2x2"; }
virtual ObjectSettings get_settings() override;

std::string get_default_sprite_name() const override;

private:
enum ChaseState {
NORMAL,
Expand Down
2 changes: 2 additions & 0 deletions src/badguy/fish_harmless.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class FishHarmless final : public FishSwimming
virtual std::string get_display_name() const override { return display_name(); }
virtual std::string get_overlay_size() const override { return "1x1"; }

GameObjectTypes get_types() const override { return {}; }

private:
FishHarmless(const FishHarmless&) = delete;
FishHarmless& operator=(const FishHarmless&) = delete;
Expand Down
22 changes: 22 additions & 0 deletions src/badguy/fish_swimming.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ FishSwimming::FishSwimming(const ReaderMapping& reader) :
m_float_timer(),
m_radius()
{
parse_type(reader);
reader.get("radius", m_radius, 100.0f);
}

Expand All @@ -46,6 +47,27 @@ FishSwimming::FishSwimming(const ReaderMapping& reader, const std::string& sprit
reader.get("radius", m_radius, 100.0f);
}

GameObjectTypes
FishSwimming::get_types() const
{
return {
{ "snow", _("Snow") },
{ "forest", _("Forest") }
};
}

std::string
FishSwimming::get_default_sprite_name() const
{
switch (m_type)
{
case FOREST:
return "images/creatures/fish/forest/bluefish.sprite";
default:
return m_default_sprite_name;
}
}

ObjectSettings
FishSwimming::get_settings()
{
Expand Down
8 changes: 8 additions & 0 deletions src/badguy/fish_swimming.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,18 @@ class FishSwimming : public BadGuy
virtual std::string get_overlay_size() const override { return "2x1"; }
virtual ObjectSettings get_settings() override;

virtual GameObjectTypes get_types() const override;
virtual std::string get_default_sprite_name() const override;

void turn_around();
void maintain_velocity(float goal_x_velocity);

protected:
enum Type {
SNOW,
FOREST
};

enum FishYState {
DISRUPTED,
BALANCED
Expand Down
Loading