From: LMH Date: Sun, 9 Nov 2014 19:15:30 +0000 (-1000) Subject: Basic code structure to allow for two new powerups X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=c0191e8d4f95bb533a225ea5aef8d55f6a39dc0d;hp=5e32f9729857c1322c2cf7d627f6e1692e15020b;p=supertux.git Basic code structure to allow for two new powerups --- diff --git a/WHATSNEW.txt b/WHATSNEW.txt index 0ba7ff4e8..a742979a6 100644 --- a/WHATSNEW.txt +++ b/WHATSNEW.txt @@ -10,23 +10,27 @@ icy island levels tweaked new sounds massive improvements to localization efficiency tweaks +move to SDL2 +menus reworked +addon manager improved +new tilemap- halloween Supertux Release 0.3.4 (2013-07) -------------------------------- -It's been more than three years since the last development snapshot for -Milestone 2 of SuperTux, making this a bit overdue. Once again it is hard to -say what the most notable changes are, but one thing players should notice is +It's been more than three years since the last development snapshot for +Milestone 2 of SuperTux, making this a bit overdue. Once again it is hard to +say what the most notable changes are, but one thing players should notice is a greater wealth of levels to play through an expanded avalibility of add-ons. Additionally, SuperTux development has moved to Google Code. Check it out at: http://code.google.com/p/supertux/ -If you are intersted in contribuiting to SuperTux, please do so. The more -people working on the project, the faster development can continue. The hope -is that this release will generate more interest which will lead to more -frequent releases. You can refer to the wiki page on "Contributing" to get +If you are intersted in contribuiting to SuperTux, please do so. The more +people working on the project, the faster development can continue. The hope +is that this release will generate more interest which will lead to more +frequent releases. You can refer to the wiki page on "Contributing" to get started: http://supertux.lethargik.org/wiki/Contributing @@ -73,12 +77,12 @@ SuperTux 0.3.2-SVN features: * final boss for Icy Island * brand new Forest World with new badguys and new game objects * new and improved soundtrack, immersive sound effects - * much more... + * much more... The changes in more detail: The SuperTux 0.1 engine was nearly completely rewritten. The game is translatable now, a new camera algorithm allows scrolling in all four directions. Collision -detection supports slopes and moving objects now. We have scripting +detection supports slopes and moving objects now. We have scripting support for dynamic level events and animations. New game objects include trampolines, switches, portable stones, upside-down levels, wind, moving platforms and particle effects. The sound diff --git a/src/object/bonus_block.cpp b/src/object/bonus_block.cpp index 29f6fa648..fb881b8aa 100644 --- a/src/object/bonus_block.cpp +++ b/src/object/bonus_block.cpp @@ -74,6 +74,8 @@ BonusBlock::BonusBlock(const Vector& pos, int data) : case 12: contents = CONTENT_CUSTOM; object = std::make_shared(get_pos(), "images/powerups/potions/red-potion.sprite"); break; + case 13: contents = CONTENT_AIRGROW; break; + case 14: contents = CONTENT_EARTHGROW; break; default: log_warning << "Invalid box contents" << std::endl; contents = CONTENT_COIN; @@ -116,6 +118,10 @@ BonusBlock::BonusBlock(const Reader& lisp) : contents = CONTENT_FIREGROW; } else if(contentstring == "icegrow") { contents = CONTENT_ICEGROW; + } else if(contentstring == "airgrow") { + contents = CONTENT_AIRGROW; + } else if(contentstring == "earthgrow") { + contents = CONTENT_EARTHGROW; } else if(contentstring == "star") { contents = CONTENT_STAR; } else if(contentstring == "1up") { @@ -252,6 +258,34 @@ BonusBlock::try_open(Player *player) break; } + case CONTENT_AIRGROW: + { + if(player->get_status()->bonus == NO_BONUS) { + auto riser = std::make_shared(get_pos(), std::make_shared(direction)); + sector->add_object(riser); + } else { + auto riser = std::make_shared( + get_pos(), std::make_shared(AIR_BONUS)); + sector->add_object(riser); + } + SoundManager::current()->play("sounds/upgrade.wav"); + break; + } + + case CONTENT_EARTHGROW: + { + if(player->get_status()->bonus == NO_BONUS) { + auto riser = std::make_shared(get_pos(), std::make_shared(direction)); + sector->add_object(riser); + } else { + auto riser = std::make_shared( + get_pos(), std::make_shared(EARTH_BONUS)); + sector->add_object(riser); + } + SoundManager::current()->play("sounds/upgrade.wav"); + break; + } + case CONTENT_STAR: { sector->add_object(std::make_shared(get_pos() + Vector(0, -32), direction)); @@ -379,6 +413,22 @@ BonusBlock::try_drop(Player *player) break; } + case CONTENT_AIRGROW: + { + sector->add_object(std::make_shared(get_pos() + Vector(0, 32), "images/powerups/iceflower/iceflower.sprite")); + SoundManager::current()->play("sounds/upgrade.wav"); + countdown = true; + break; + } + + case CONTENT_EARTHGROW: + { + sector->add_object(std::make_shared(get_pos() + Vector(0, 32), "images/powerups/fireflower/fireflower.sprite")); + SoundManager::current()->play("sounds/upgrade.wav"); + countdown = true; + break; + } + case CONTENT_STAR: { sector->add_object(std::make_shared(get_pos() + Vector(0, 32), direction)); diff --git a/src/object/bonus_block.hpp b/src/object/bonus_block.hpp index 816fa1939..1b3552924 100644 --- a/src/object/bonus_block.hpp +++ b/src/object/bonus_block.hpp @@ -35,6 +35,8 @@ public: CONTENT_COIN, CONTENT_FIREGROW, CONTENT_ICEGROW, + CONTENT_AIRGROW, + CONTENT_EARTHGROW, CONTENT_STAR, CONTENT_1UP, CONTENT_CUSTOM, diff --git a/src/object/flower.cpp b/src/object/flower.cpp index d823ed7b1..e367484b2 100644 --- a/src/object/flower.cpp +++ b/src/object/flower.cpp @@ -39,6 +39,16 @@ Flower::Flower(BonusType _type) : sprite = SpriteManager::current()->create("images/powerups/iceflower/iceflower.sprite"); SoundManager::current()->preload("sounds/fire-flower.wav"); lightsprite->set_color(Color(0.0f, 0.1f, 0.2f)); + } + else if(type == AIR_BONUS) { + sprite = SpriteManager::current()->create("images/powerups/iceflower/iceflower.sprite"); + SoundManager::current()->preload("sounds/fire-flower.wav"); + lightsprite->set_color(Color(0.15f, 0.0f, 0.15f)); + } + else if(type == EARTH_BONUS) { + sprite = SpriteManager::current()->create("images/powerups/fireflower/fireflower.sprite"); + SoundManager::current()->preload("sounds/fire-flower.wav"); + lightsprite->set_color(Color(0.0f, 0.3f, 0.0f)); } else { assert(false); } diff --git a/src/object/player.cpp b/src/object/player.cpp index c2bfb0e28..e50588eb4 100644 --- a/src/object/player.cpp +++ b/src/object/player.cpp @@ -952,6 +952,10 @@ Player::add_bonus(const std::string& bonustype) type = FIRE_BONUS; } else if(bonustype == "iceflower") { type = ICE_BONUS; + } else if(bonustype == "airflower") { + type = AIR_BONUS; + } else if(bonustype == "earthflower") { + type = EARTH_BONUS; } else if(bonustype == "none") { type = NO_BONUS; } else { @@ -973,11 +977,7 @@ Player::add_bonus(BonusType type, bool animate) // ignore GROWUP_BONUS if we're already big if (type == GROWUP_BONUS) { - if (player_status->bonus == GROWUP_BONUS) - return true; - if (player_status->bonus == FIRE_BONUS) - return true; - if (player_status->bonus == ICE_BONUS) + if (!player_status->bonus == NO_BONUS) return true; } @@ -1022,11 +1022,33 @@ Player::set_bonus(BonusType type, bool animate) Sector::current()->add_object(std::make_shared("images/objects/particles/icetux-cap.sprite", action, ppos, ANCHOR_TOP, pspeed, paccel, LAYER_OBJECTS-1)); if (climbing) stop_climbing(*climbing); } + if ((player_status->bonus == AIR_BONUS) && (animate)) { + // visually lose hat + Vector ppos = Vector((bbox.p1.x + bbox.p2.x) / 2, bbox.p1.y); + Vector pspeed = Vector(((dir==LEFT) ? +100 : -100), -300); + Vector paccel = Vector(0, 1000); + std::string action = (dir==LEFT)?"left":"right"; + Sector::current()->add_object(std::make_shared("images/objects/particles/icetux-cap.sprite", action, ppos, ANCHOR_TOP, pspeed, paccel, LAYER_OBJECTS-1)); + if (climbing) stop_climbing(*climbing); + } + if ((player_status->bonus == EARTH_BONUS) && (animate)) { + // visually lose hard-hat + Vector ppos = Vector((bbox.p1.x + bbox.p2.x) / 2, bbox.p1.y); + Vector pspeed = Vector(((dir==LEFT) ? +100 : -100), -300); + Vector paccel = Vector(0, 1000); + std::string action = (dir==LEFT)?"left":"right"; + Sector::current()->add_object(std::make_shared("images/objects/particles/firetux-helmet.sprite", action, ppos, ANCHOR_TOP, pspeed, paccel, LAYER_OBJECTS-1)); + if (climbing) stop_climbing(*climbing); + } player_status->max_fire_bullets = 0; player_status->max_ice_bullets = 0; + player_status->max_air_time = 0; + player_status->max_earth_time = 0; } if (type == FIRE_BONUS) player_status->max_fire_bullets++; if (type == ICE_BONUS) player_status->max_ice_bullets++; + if (type == AIR_BONUS) player_status->max_air_time++; + if (type == EARTH_BONUS) player_status->max_earth_time++; player_status->bonus = type; return true; @@ -1077,6 +1099,10 @@ Player::draw(DrawingContext& context) sa_prefix = "fire"; else if (player_status->bonus == ICE_BONUS) sa_prefix = "ice"; + else if (player_status->bonus == AIR_BONUS) + sa_prefix = "ice"; + else if (player_status->bonus == EARTH_BONUS) + sa_prefix = "fire"; else sa_prefix = "small"; @@ -1311,7 +1337,9 @@ Player::kill(bool completely) SoundManager::current()->play("sounds/hurt.wav"); if(player_status->bonus == FIRE_BONUS - || player_status->bonus == ICE_BONUS) { + || player_status->bonus == ICE_BONUS + || player_status->bonus == AIR_BONUS + || player_status->bonus == EARTH_BONUS) { safe_timer.start(TUX_SAFE_TIME); set_bonus(GROWUP_BONUS, true); } else if(player_status->bonus == GROWUP_BONUS) { diff --git a/src/supertux/player_status.cpp b/src/supertux/player_status.cpp index e2d1155d9..a66663bb0 100644 --- a/src/supertux/player_status.cpp +++ b/src/supertux/player_status.cpp @@ -93,12 +93,20 @@ PlayerStatus::write(lisp::Writer& writer) case ICE_BONUS: writer.write("bonus", "iceflower"); break; + case AIR_BONUS: + writer.write("bonus", "airflower"); + break; + case EARTH_BONUS: + writer.write("bonus", "earthflower"); + break; default: log_warning << "Unknown bonus type." << std::endl; writer.write("bonus", "none"); } writer.write("fireflowers", max_fire_bullets); writer.write("iceflowers", max_ice_bullets); + writer.write("airflowers", max_air_time); + writer.write("earthflowers", max_earth_time); writer.write("coins", coins); } @@ -118,6 +126,10 @@ PlayerStatus::read(const Reader& lisp) bonus = FIRE_BONUS; } else if(bonusname == "iceflower") { bonus = ICE_BONUS; + } else if(bonusname == "airflower") { + bonus = AIR_BONUS; + } else if(bonusname == "earthflower") { + bonus = EARTH_BONUS; } else { log_warning << "Unknown bonus '" << bonusname << "' in savefile" << std::endl; bonus = NO_BONUS; @@ -125,6 +137,8 @@ PlayerStatus::read(const Reader& lisp) } lisp.get("fireflowers", max_fire_bullets); lisp.get("iceflowers", max_ice_bullets); + lisp.get("airflowers", max_air_time); + lisp.get("earthflowers", max_earth_time); lisp.get("coins", coins); } diff --git a/src/supertux/player_status.hpp b/src/supertux/player_status.hpp index 2ad2836fe..6db8d8381 100644 --- a/src/supertux/player_status.hpp +++ b/src/supertux/player_status.hpp @@ -29,7 +29,7 @@ static const float BORDER_X = 10; static const float BORDER_Y = 10; enum BonusType { - NO_BONUS, GROWUP_BONUS, FIRE_BONUS, ICE_BONUS + NO_BONUS, GROWUP_BONUS, FIRE_BONUS, ICE_BONUS, AIR_BONUS, EARTH_BONUS }; class DrawingContext; @@ -56,6 +56,8 @@ public: BonusType bonus; int max_fire_bullets; /**< maximum number of fire bullets in play */ int max_ice_bullets; /**< maximum number of ice bullets in play */ + int max_air_time; /**< maximum number of seconds player can float in air */ + int max_earth_time; /**< maximum number of seconds player can turn to stone */ private: int displayed_coins;