X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fobject%2Fpowerup.cpp;h=f274d485e4891e2ca9e4f58da6fdf65d2ad5b469;hb=5f1c84ed5ce0ab5450f92082a9aaaa9ca0effc39;hp=ad0104633a529e701aa7fb973b032df7e6b8c915;hpb=5d1290054358cb4560f54bcd6840121a69360bf9;p=supertux.git diff --git a/src/object/powerup.cpp b/src/object/powerup.cpp index ad0104633..f274d485e 100644 --- a/src/object/powerup.cpp +++ b/src/object/powerup.cpp @@ -1,7 +1,7 @@ -// $Id: growup.cpp 2458 2005-05-10 11:29:58Z matzebraun $ -// +// $Id$ +// // SuperTux -// Copyright (C) 2005 Matthias Braun +// Copyright (C) 2006 Matthias Braun // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -12,41 +12,31 @@ // 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, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -// 02111-1307, USA. +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + #include +#include #include +#include #include "powerup.hpp" #include "resources.hpp" #include "player.hpp" -#include "sprite/sprite_manager.hpp" #include "audio/sound_manager.hpp" #include "object_factory.hpp" #include "sector.hpp" #include "log.hpp" PowerUp::PowerUp(const lisp::Lisp& lisp) + : MovingSprite(lisp, LAYER_OBJECTS, COLGROUP_MOVING) { - lisp.get("x", bbox.p1.x); - lisp.get("y", bbox.p1.y); - lisp.get("sprite", sprite_name); lisp.get("script", script); no_physics = false; lisp.get("disable-physics", no_physics); - bbox.set_size(32, 32); - sprite = sprite_manager->create(sprite_name); physic.enable_gravity(true); - - set_group(COLGROUP_MOVING); -} - -PowerUp::~PowerUp() -{ - delete sprite; } HitResponse @@ -76,10 +66,10 @@ PowerUp::collision(GameObject& other, const CollisionHit& hit) // some defaults if no script has been set if (sprite_name == "images/powerups/egg/egg.sprite") { - player->set_bonus(GROWUP_BONUS, true); + player->add_bonus(GROWUP_BONUS, true); sound_manager->play("sounds/grow.wav"); } else if (sprite_name == "images/powerups/fireflower/fireflower.sprite") { - player->set_bonus(FIRE_BONUS, true); + player->add_bonus(FIRE_BONUS, true); sound_manager->play("sounds/fire-flower.wav"); } else if (sprite_name == "images/powerups/star/star.sprite") { player->make_invincible(); @@ -96,11 +86,5 @@ PowerUp::update(float elapsed_time) movement = physic.get_movement(elapsed_time); } -void -PowerUp::draw(DrawingContext& context) -{ - sprite->draw(context, get_pos(), LAYER_OBJECTS); -} - IMPLEMENT_FACTORY(PowerUp, "powerup");