X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fbadguy%2Fmrtree.cpp;h=8c688d4bb4f07ac95cc873a101d0ad178bd03cf2;hb=c52b9f5670e4e7f5c3847d0e2b00b4f1ba772944;hp=ddcc43aa3c781999de930df2df042116e8a8de5b;hpb=22ebbf03379aad8d3fc704e47e6cfa7acca8651d;p=supertux.git diff --git a/src/badguy/mrtree.cpp b/src/badguy/mrtree.cpp index ddcc43aa3..8c688d4bb 100644 --- a/src/badguy/mrtree.cpp +++ b/src/badguy/mrtree.cpp @@ -1,12 +1,10 @@ -// $Id$ -// // SuperTux // 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 -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,41 +12,35 @@ // 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. +// along with this program. If not, see . -#include +#include "badguy/mrtree.hpp" -#include "mrtree.hpp" -#include "stumpy.hpp" -#include "poisonivy.hpp" -#include "random_generator.hpp" +#include "audio/sound_manager.hpp" +#include "badguy/poisonivy.hpp" +#include "badguy/stumpy.hpp" +#include "math/random_generator.hpp" +#include "object/player.hpp" #include "object/sprite_particle.hpp" -#include "sector.hpp" +#include "supertux/object_factory.hpp" +#include "supertux/sector.hpp" + +#include -static const float WALKSPEED = 100; +static const float TREE_SPEED = 100; static const float POISONIVY_WIDTH = 32; static const float POISONIVY_HEIGHT = 32; static const float POISONIVY_Y_OFFSET = 24; - -MrTree::MrTree(const lisp::Lisp& reader) +MrTree::MrTree(const Reader& reader) : WalkingBadguy(reader, "images/creatures/mr_tree/mr_tree.sprite","left","right") { - walk_speed = WALKSPEED; + walk_speed = TREE_SPEED; max_drop_height = 16; sound_manager->preload("sounds/mr_tree.ogg"); } -void -MrTree::write(lisp::Writer& writer) -{ - writer.start_list("mrtree"); - WalkingBadguy::write(writer); - writer.end_list("mrtree"); -} - bool MrTree::collision_squished(GameObject& object) { @@ -69,8 +61,8 @@ MrTree::collision_squished(GameObject& object) // TODO: provide convenience function in MovingSprite or MovingObject? for (int px = (int)stumpy->get_bbox().p1.x; px < (int)stumpy->get_bbox().p2.x; px+=10) { Vector ppos = Vector(px, stumpy->get_bbox().p1.y-5); - float angle = systemRandom.randf(-M_PI_2, M_PI_2); - float velocity = systemRandom.randf(45, 90); + float angle = graphicsRandom.randf(-M_PI_2, M_PI_2); + float velocity = graphicsRandom.randf(45, 90); float vx = sin(angle)*velocity; float vy = -cos(angle)*velocity; Vector pspeed = Vector(vx, vy); @@ -79,24 +71,26 @@ MrTree::collision_squished(GameObject& object) } // spawn PoisonIvy - Vector leaf1_pos = Vector(stumpy_pos.x - POISONIVY_WIDTH - 1, stumpy_pos.y - POISONIVY_Y_OFFSET); - Rect leaf1_bbox = Rect(leaf1_pos.x, leaf1_pos.y, leaf1_pos.x + POISONIVY_WIDTH, leaf1_pos.y + POISONIVY_HEIGHT); + Vector leaf1_pos(stumpy_pos.x - POISONIVY_WIDTH - 1, stumpy_pos.y - POISONIVY_Y_OFFSET); + Rectf leaf1_bbox(leaf1_pos.x, leaf1_pos.y, leaf1_pos.x + POISONIVY_WIDTH, leaf1_pos.y + POISONIVY_HEIGHT); if (Sector::current()->is_free_of_movingstatics(leaf1_bbox, this)) { PoisonIvy* leaf1 = new PoisonIvy(leaf1_bbox.p1, LEFT); leaf1 = leaf1; + leaf1->countMe = false; Sector::current()->add_object(leaf1); } // spawn PoisonIvy - Vector leaf2_pos = Vector(stumpy_pos.x + sprite->get_current_hitbox_width() + 1, stumpy_pos.y - POISONIVY_Y_OFFSET); - Rect leaf2_bbox = Rect(leaf2_pos.x, leaf2_pos.y, leaf2_pos.x + POISONIVY_WIDTH, leaf2_pos.y + POISONIVY_HEIGHT); + Vector leaf2_pos(stumpy_pos.x + sprite->get_current_hitbox_width() + 1, stumpy_pos.y - POISONIVY_Y_OFFSET); + Rectf leaf2_bbox(leaf2_pos.x, leaf2_pos.y, leaf2_pos.x + POISONIVY_WIDTH, leaf2_pos.y + POISONIVY_HEIGHT); if (Sector::current()->is_free_of_movingstatics(leaf2_bbox, this)) { PoisonIvy* leaf2 = new PoisonIvy(leaf2_bbox.p1, RIGHT); leaf2 = leaf2; + leaf2->countMe = false; Sector::current()->add_object(leaf2); } return true; } -IMPLEMENT_FACTORY(MrTree, "mrtree") +/* EOF */