Skip to content
Open
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
Binary file added data/images/objects/bonus_block/malus-badegg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/powerups/badegg/badegg-shade.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/powerups/badegg/badegg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions data/images/powerups/badegg/badegg.sprite
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(supertux-sprite
(action
(name "default")
(images "badegg.png")
)
(action
(name "shadow")
(images "badegg-shade.png")
)
)
30 changes: 27 additions & 3 deletions data/images/tiles.strf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

;; next-id: 7949
;; free/skipped ids (please use before any other):
;; 4639-4660, 5061-5089, 5268-5283, 5453-5527
;; 4641-4660, 5061-5089, 5268-5283, 5453-5527
;; No group ids are currently skipped! Delete this line if any are and replace it with said ids...

(tilegroup
Expand Down Expand Up @@ -1429,8 +1429,9 @@
102 140 3161 3162
104 105 3160 7026
3037 2943 2944 2945
2946 112 1311 7394
7396 7397 7398 7395
2946 4640 112 1311
7394 7396 7397 7398
7395 0 0 0

57 58 2841 2842
59 60 2843 2844
Expand Down Expand Up @@ -2143,6 +2144,29 @@
(fps 15)
)

(tile
(id 4640)
(images
"objects/bonus_block/full-0.png"
"objects/bonus_block/full-1.png"
"objects/bonus_block/full-2.png"
"objects/bonus_block/full-3.png"
"objects/bonus_block/full-4.png"
"objects/bonus_block/full-3.png"
"objects/bonus_block/full-2.png"
"objects/bonus_block/full-1.png"
"objects/bonus_block/full-0.png"
"objects/bonus_block/full-0.png"
"objects/bonus_block/full-0.png"
)
(solid #t)
(object-name "bonusblock")
(object-data "(sprite \"images/objects/bonus_block/bonusblock.sprite\") (data 18)")
(editor-images "objects/bonus_block/malus-badegg.png")
(data 18)
(fps 15)
)

(tile
(id 1)
(images
Expand Down
35 changes: 29 additions & 6 deletions src/object/bonus_block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ BonusBlock::get_content_by_data(int tile_data) const
case 15: return Content::LIGHT_ON;
case 16: return Content::RETROGROW;
case 17: return Content::RETROSTAR;
case 18: return Content::BADEGG;
default:
log_warning << "Invalid box contents" << std::endl;
return Content::COIN;
Expand All @@ -265,9 +266,9 @@ BonusBlock::get_settings()
result.add_int(_("Count"), &m_hit_counter, "count", get_default_hit_counter());
result.add_enum(_("Content"), reinterpret_cast<int*>(&m_contents),
{ _("Coin"), _("Growth (fire flower)"), _("Growth (ice flower)"), _("Growth (air flower)"),
_("Growth (earth flower)"), _("Growth (retro)"), _("Star"), _("Star (retro)"), _("Tux doll"), _("Custom"), _("Script"), _("Light"), _("Light (On)"),
_("Growth (earth flower)"), _("Growth (retro)"), _("Star"), _("Star (retro)"), _("Tux doll"), _("Rotten egg"), _("Custom"), _("Script"), _("Light"), _("Light (On)"),
_("Trampoline"), _("Portable trampoline"), _("Coin rain"), _("Coin explosion"), _("Rock"), _("Potion") },
{ "coin", "firegrow", "icegrow", "airgrow", "earthgrow", "retrogrow", "star", "retrostar", "1up", "custom", "script", "light", "light-on",
{ "coin", "firegrow", "icegrow", "airgrow", "earthgrow", "retrogrow", "star", "retrostar", "1up", "badegg", "custom", "script", "light", "light-on",
"trampoline", "portabletrampoline", "rain", "explode", "rock", "potion" },
static_cast<int>(Content::COIN), "contents");

Expand Down Expand Up @@ -414,6 +415,12 @@ BonusBlock::try_open(Player* player)
break;
}

case Content::BADEGG:
{
raise_growup_bonus(player, MALUS_BADEGG, direction);
break;
}

case Content::CUSTOM:
{
auto moving_obj_copy = to_moving_object(GameObjectFactory::instance().create(m_object->get_class_name(), get_pos() + Vector(0, -32),
Expand Down Expand Up @@ -582,6 +589,12 @@ BonusBlock::try_drop(Player *player)
break;
}

case Content::BADEGG:
{
drop_growup_bonus(player, PowerUp::BADEGG, direction, countdown);
break;
}

case Content::CUSTOM:
{
// NOTE: Non-portable trampolines could be moved to Content::CUSTOM, but they should not drop.
Expand Down Expand Up @@ -656,9 +669,13 @@ BonusBlock::raise_growup_bonus(Player* player, const BonusType& bonus, const Dir
const std::string& growup_sprite, const std::string& flower_sprite)
{
std::unique_ptr<MovingObject> obj;
if (player->get_status().bonus[player->get_id()] == BONUS_NONE)
if (bonus == MALUS_BADEGG)
{
obj = std::make_unique<GrowUp>(MALUS_BADEGG, get_pos(), dir, growup_sprite);
}
else if (player->get_status().bonus[player->get_id()] == BONUS_NONE)
{
obj = std::make_unique<GrowUp>(get_pos(), dir, growup_sprite);
obj = std::make_unique<GrowUp>(BONUS_GROWUP, get_pos(), dir, growup_sprite);
}
else
{
Expand All @@ -673,9 +690,13 @@ void
BonusBlock::drop_growup_bonus(Player* player, int type, const Direction& dir, bool& countdown,
const std::string& growup_sprite)
{
if (player->get_status().bonus[player->get_id()] == BONUS_NONE)
if (type == PowerUp::BADEGG)
{
Sector::get().add<GrowUp>(MALUS_BADEGG, get_pos() + Vector(0, 32), dir, growup_sprite);
}
else if (player->get_status().bonus[player->get_id()] == BONUS_NONE)
{
Sector::get().add<GrowUp>(get_pos() + Vector(0, 32), dir, growup_sprite);
Sector::get().add<GrowUp>(BONUS_GROWUP, get_pos() + Vector(0, 32), dir, growup_sprite);
}
else
{
Expand Down Expand Up @@ -720,6 +741,8 @@ BonusBlock::get_content_from_string(const std::string& contentstring) const
return Content::RETROSTAR;
else if (contentstring == "1up")
return Content::ONEUP;
else if (contentstring == "badegg")
return Content::BADEGG;
else if (contentstring == "custom")
return Content::CUSTOM;
else if (contentstring == "script") // Use this when the bonus block is intended to contain ONLY a script.
Expand Down
1 change: 1 addition & 0 deletions src/object/bonus_block.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class BonusBlock final : public Block
STAR,
RETROSTAR,
ONEUP,
BADEGG,
CUSTOM,
SCRIPT,
LIGHT,
Expand Down
39 changes: 28 additions & 11 deletions src/object/growup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,33 @@
#include "sprite/sprite.hpp"
#include "sprite/sprite_manager.hpp"

GrowUp::GrowUp(const Vector& pos, Direction direction, const std::string& custom_sprite) :
MovingSprite(pos, custom_sprite.empty() ? "images/powerups/egg/egg.sprite" : custom_sprite, LAYER_OBJECTS, COLGROUP_MOVING),
GrowUp::GrowUp(BonusType type, const Vector& pos, Direction direction, const std::string& custom_sprite) :
MovingSprite(pos,
!custom_sprite.empty() ? custom_sprite :
(type == BONUS_GROWUP) ? "images/powerups/egg/egg.sprite" :
"images/powerups/badegg/badegg.sprite",
LAYER_OBJECTS, COLGROUP_MOVING
),
m_growup_type(type),
m_growup_default_sprite((m_growup_type == BONUS_GROWUP) ? "images/powerups/egg/egg.sprite" : "images/powerups/badegg/badegg.sprite"),
m_physic(),
m_custom_sprite(!custom_sprite.empty()),
m_shadesprite(SpriteManager::current()->create("images/powerups/egg/egg.sprite")),
m_shadesprite(SpriteManager::current()->create(m_growup_default_sprite)),
m_lightsprite(SpriteManager::current()->create("images/objects/lightmap_light/lightmap_light-small.sprite"))
{
m_physic.enable_gravity(true);
m_physic.set_velocity_x((direction == Direction::LEFT) ? -100.0f : 100.0f);
SoundManager::current()->preload("sounds/grow.ogg");
// Set the shadow action for the egg sprite, so it remains in place as the egg rolls.
m_shadesprite->set_action("shadow");
// Configure the light sprite for the glow effect.
m_lightsprite->set_blend(Blend::ADD);
m_lightsprite->set_color(Color(0.2f, 0.2f, 0.0f));
if (m_growup_type == BONUS_GROWUP) {
m_lightsprite->set_color(Color(0.2f, 0.2f, 0.0f));
SoundManager::current()->preload("sounds/grow.ogg");
} else {
m_lightsprite->set_color(Color(0.2f, 0.0f, 0.2f));
SoundManager::current()->preload("sounds/hurt.wav");
}
}

void
Expand Down Expand Up @@ -84,13 +96,18 @@ GrowUp::collision(MovingObject& other, const CollisionHit& hit )
{
auto player = dynamic_cast<Player*>(&other);
if (player != nullptr) {
if (!player->add_bonus(BONUS_GROWUP, true)) {
// Tux can't grow right now.
collision_solid( hit );
return ABORT_MOVE;
if (m_growup_type == BONUS_GROWUP) {
if (!player->add_bonus(BONUS_GROWUP, true)) {
// Tux can't grow right now.
collision_solid( hit );
return ABORT_MOVE;
}

SoundManager::current()->play("sounds/grow.ogg", get_pos());
} else {
player->kill(false);
SoundManager::current()->play("sounds/hurt.wav", get_pos());
}

SoundManager::current()->play("sounds/grow.ogg", get_pos());
remove_me();

return ABORT_MOVE;
Expand Down
5 changes: 4 additions & 1 deletion src/object/growup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
#include "object/moving_sprite.hpp"
#include "supertux/direction.hpp"
#include "supertux/physic.hpp"
#include "supertux/player_status.hpp"

class GrowUp final : public MovingSprite
{
public:
GrowUp(const Vector& pos, Direction direction = Direction::RIGHT, const std::string& custom_sprite = "");
GrowUp(BonusType type, const Vector& pos, Direction direction = Direction::RIGHT, const std::string& custom_sprite = "");
virtual GameObjectClasses get_class_types() const override { return MovingSprite::get_class_types().add(typeid(GrowUp)); }

virtual bool is_saveable() const override { return false; }
Expand All @@ -39,6 +40,8 @@ class GrowUp final : public MovingSprite
private:
Physic m_physic;

BonusType m_growup_type;
std::string m_growup_default_sprite;
const bool m_custom_sprite;
SpritePtr m_shadesprite;
SpritePtr m_lightsprite;
Expand Down
16 changes: 16 additions & 0 deletions src/object/powerup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ PowerUp::get_types() const
{
return {
{ "egg", _("Egg") },
{ "badegg", _("Rotten Egg") },
{ "fire", _("Fire Flower") },
{ "ice", _("Ice Flower") },
{ "air", _("Air Flower") },
Expand All @@ -77,6 +78,8 @@ PowerUp::get_default_sprite_name() const
{
switch (m_type)
{
case BADEGG:
return "images/powerups/badegg/badegg.sprite";
case FIRE:
return "images/powerups/fireflower/fireflower.sprite";
case ICE:
Expand Down Expand Up @@ -107,6 +110,7 @@ PowerUp::initialize()
{
physic.enable_gravity(true);
SoundManager::current()->preload("sounds/grow.ogg");
SoundManager::current()->preload("sounds/hurt.wav");
SoundManager::current()->preload("sounds/fire-flower.wav");
SoundManager::current()->preload("sounds/gulp.wav");

Expand All @@ -115,6 +119,8 @@ PowerUp::initialize()
{
if (matches_sprite("images/powerups/egg/egg.sprite"))
m_type = EGG;
else if (matches_sprite("images/powerups/badegg/badegg.sprite"))
m_type = BADEGG;
else if (matches_sprite("images/powerups/fireflower/fireflower.sprite"))
m_type = FIRE;
else if (matches_sprite("images/powerups/iceflower/iceflower.sprite"))
Expand Down Expand Up @@ -147,6 +153,9 @@ PowerUp::setup_lightsprite()
case EGG:
lightsprite->set_color(Color(0.2f, 0.2f, 0.0f));
break;
case BADEGG:
lightsprite->set_color(Color(0.2f, 0.f, 0.2f));
break;
case FIRE:
lightsprite->set_color(Color(0.3f, 0.0f, 0.0f));
break;
Expand Down Expand Up @@ -209,6 +218,10 @@ PowerUp::collision(MovingObject& other, const CollisionHit&)
return FORCE_MOVE;
SoundManager::current()->play("sounds/grow.ogg", get_pos());
break;
case BADEGG:
player->kill(false);
SoundManager::current()->play("sounds/hurt.wav", get_pos());
break;
case FIRE:
case COFFEE:
if (!player->add_bonus(BONUS_FIRE, true))
Expand Down Expand Up @@ -255,6 +268,9 @@ PowerUp::get_type_from_bonustype(int type)
case BONUS_GROWUP:
return EGG;

case MALUS_BADEGG:
return BADEGG;

case BONUS_FIRE:
return FIRE;

Expand Down
1 change: 1 addition & 0 deletions src/object/powerup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class PowerUp : public MovingSprite
public:
enum Type {
EGG,
BADEGG,
FIRE,
ICE,
AIR,
Expand Down
8 changes: 8 additions & 0 deletions src/supertux/player_status.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ PlayerStatus::get_bonus_name(BonusType bonustype)
return "earthflower";
case BONUS_GROWUP:
return "egg";
case MALUS_BADEGG:
return "badegg";
case BONUS_NONE:
return "none";
default:
Expand All @@ -124,6 +126,8 @@ PlayerStatus::get_bonus_from_name(const std::string& name)
return BONUS_NONE;
} else if (name == "growup" || name == "egg") {
return BONUS_GROWUP;
} else if (name == "badegg") {
return MALUS_BADEGG;
} else if (name == "fireflower") {
return BONUS_FIRE;
} else if (name == "iceflower") {
Expand Down Expand Up @@ -152,6 +156,8 @@ PlayerStatus::get_bonus_sprite(BonusType bonustype)
return "images/powerups/earthflower/earthflower.sprite";
case BONUS_GROWUP:
return "images/powerups/egg/egg.sprite";
case MALUS_BADEGG:
return "images/powerups/badegg/badegg.sprite";
default:
return "";
}
Expand Down Expand Up @@ -358,6 +364,8 @@ PlayerStatus::get_bonus_prefix(int player_id) const
return "small";
case BONUS_GROWUP:
return "big";
case MALUS_BADEGG:
return "corrupt";
case BONUS_FIRE:
return "fire";
case BONUS_ICE:
Expand Down
3 changes: 2 additions & 1 deletion src/supertux/player_status.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ enum BonusType {
BONUS_FIRE, /*!< @description Fire bonus. */
BONUS_ICE, /*!< @description Ice bonus. */
BONUS_AIR, /*!< @description Air bonus. */
BONUS_EARTH /*!< @description Earth bonus. */
BONUS_EARTH, /*!< @description Earth bonus. */
MALUS_BADEGG /*!< @description Rotten Egg fake bonus. */
};

/** This class keeps player status between different game sessions (for
Expand Down
Loading