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

Options for rock, portable trampoline, and potion bonus blocks. #2496

Merged
merged 1 commit into from
Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
57 changes: 52 additions & 5 deletions src/object/bonus_block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@

#include "object/bonus_block.hpp"

#include <memory>

#include "audio/sound_manager.hpp"
#include "badguy/badguy.hpp"
#include "badguy/crusher.hpp"
#include "editor/editor.hpp"
#include "math/vector.hpp"
#include "object/bouncy_coin.hpp"
#include "object/coin_explode.hpp"
#include "object/coin_rain.hpp"
Expand All @@ -29,6 +32,7 @@
#include "object/player.hpp"
#include "object/portable.hpp"
#include "object/powerup.hpp"
#include "object/rock.hpp"
#include "object/specialriser.hpp"
#include "object/star.hpp"
#include "object/trampoline.hpp"
Expand Down Expand Up @@ -182,11 +186,11 @@ BonusBlock::get_content_by_data(int tile_data) const
case 5: return Content::ICEGROW;
case 6: return Content::LIGHT;
case 7: return Content::TRAMPOLINE;
case 8: return Content::CUSTOM; // Trampoline
case 9: return Content::CUSTOM; // Rock
case 8: return Content::PORTABLE_TRAMPOLINE; // Trampoline
case 9: return Content::ROCK; // Rock
case 10: return Content::RAIN;
case 11: return Content::EXPLODE;
case 12: return Content::CUSTOM; // Red potion
case 12: return Content::POTION; // Red potion
case 13: return Content::AIRGROW;
case 14: return Content::EARTHGROW;
case 15: return Content::LIGHT_ON;
Expand All @@ -210,9 +214,9 @@ BonusBlock::get_settings()
result.add_enum(_("Content"), reinterpret_cast<int*>(&m_contents),
{_("Coin"), _("Growth (fire flower)"), _("Growth (ice flower)"), _("Growth (air flower)"),
_("Growth (earth flower)"), _("Star"), _("Tux doll"), _("Custom"), _("Script"), _("Light"), _("Light (On)"),
_("Trampoline"), _("Coin rain"), _("Coin explosion")},
_("Trampoline"), _("Portable trampoline"), _("Coin rain"), _("Coin explosion"), _("Rock"), _("Potion")},
{"coin", "firegrow", "icegrow", "airgrow", "earthgrow", "star",
"1up", "custom", "script", "light", "light-on", "trampoline", "rain", "explode"},
"1up", "custom", "script", "light", "light-on", "trampoline", "portabletrampoline", "rain", "explode", "rock", "potion"},
static_cast<int>(Content::COIN), "contents");
result.add_sexp(_("Custom Content"), "custom-contents", m_custom_sx);

Expand Down Expand Up @@ -357,6 +361,22 @@ BonusBlock::try_open(Player* player)
play_upgrade_sound = true;
break;
}
case Content::PORTABLE_TRAMPOLINE:
{
Sector::get().add<SpecialRiser>(get_pos(), std::make_unique<Trampoline>(get_pos(), true), true);
play_upgrade_sound = true;
break;
}
case Content::ROCK:
{
Sector::get().add<SpecialRiser>(get_pos(), std::make_unique<Rock>(get_pos(), "images/objects/rock/rock.sprite"));
break;
}
case Content::POTION:
{
Sector::get().add<SpecialRiser>(get_pos(), std::make_unique<PowerUp>(get_pos(), "images/powerups/potions/red-potion.sprite"));
break;
}
case Content::RAIN:
{
Sector::get().add<CoinRain>(get_pos(), true);
Expand Down Expand Up @@ -489,6 +509,24 @@ BonusBlock::try_drop(Player *player)
try_open(player);
break;
}
case Content::ROCK:
{
Sector::get().add<Rock>(get_pos() + Vector(0, 32), "images/objects/rock/rock.sprite");
countdown = true;
break;
}
case Content::PORTABLE_TRAMPOLINE:
{
Sector::get().add<Trampoline>(get_pos() + Vector(0, 32), true);
countdown = true;
break;
}
case Content::POTION:
{
Sector::get().add<PowerUp>(get_pos() + Vector(0, 32), "images/powerups/potions/red-potion.sprite");
countdown = true;
break;
}
case Content::EXPLODE:
{
Sector::get().add<CoinExplode>(get_pos() + Vector (0, 40));
Expand Down Expand Up @@ -586,6 +624,12 @@ BonusBlock::get_content_from_string(const std::string& contentstring) const
return Content::LIGHT_ON;
} else if (contentstring == "trampoline") {
return Content::TRAMPOLINE;
} else if (contentstring == "portabletrampoline") {
return Content::PORTABLE_TRAMPOLINE;
} else if (contentstring == "potion") {
return Content::POTION;
} else if (contentstring == "rock") {
return Content::ROCK;
} else if (contentstring == "rain") {
return Content::RAIN;
} else if (contentstring == "explode") {
Expand Down Expand Up @@ -613,6 +657,9 @@ BonusBlock::contents_to_string(const BonusBlock::Content& content) const
case Content::LIGHT: return "light";
case Content::LIGHT_ON: return "light-on";
case Content::TRAMPOLINE: return "trampoline";
case Content::PORTABLE_TRAMPOLINE: return "portabletrampoline";
case Content::POTION: return "potion";
case Content::ROCK: return "rock";
case Content::RAIN: return "rain";
case Content::EXPLODE: return "explode";
default: return "coin";
Expand Down
5 changes: 4 additions & 1 deletion src/object/bonus_block.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ class BonusBlock final : public Block
LIGHT,
LIGHT_ON,
TRAMPOLINE,
PORTABLE_TRAMPOLINE,
RAIN,
EXPLODE
EXPLODE,
ROCK,
POTION
};

public:
Expand Down
Loading