1 // $Id: Kugelblitz.cpp 2654 2005-06-29 14:16:22Z wansti $
4 // Copyright (C) 2005 Marek Moeckel <wansti@gmx.de>
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
22 #include "kugelblitz.hpp"
24 static const float JUMPSPEED=600;
25 static const float Kugelblitz_MID_TOLERANCE=4;
26 static const float Kugelblitz_LOW_TOLERANCE=2;
28 Kugelblitz::Kugelblitz(const lisp::Lisp& reader)
29 : groundhit_pos_set(false)
31 reader.get("x", start_position.x);
32 start_position.y = 0; //place above visible area
33 bbox.set_size(63.8, 127.8);
34 sprite = sprite_manager->create("kugelblitz");
35 sprite->set_action("falling");
36 physic.enable_gravity(false);
40 Kugelblitz::write(lisp::Writer& writer)
42 writer.start_list("kugelblitz");
44 writer.write_float("x", start_position.x);
45 writer.write_float("y", start_position.y);
47 writer.end_list("kugelblitz");
51 Kugelblitz::activate()
53 physic.set_velocity_y(-300);
57 Kugelblitz::collision_solid(GameObject& , const CollisionHit& chit)
63 Kugelblitz::collision_badguy(BadGuy& other , const CollisionHit& chit)
70 Kugelblitz::hit(const CollisionHit& chit)
73 if(chit.normal.y < -.5) {
74 if (!groundhit_pos_set)
76 pos_groundhit = get_pos();
77 groundhit_pos_set = true;
79 bbox.set_size(63.8, 63.8);
80 sprite->set_action("flying");
81 physic.set_velocity_y(0);
82 physic.set_velocity_x(100);
84 } else if(chit.normal.y < .5) { // bumped on roof
85 physic.set_velocity_y(0);
92 Kugelblitz::active_update(float elapsed_time)
94 BadGuy::active_update(elapsed_time);
97 IMPLEMENT_FACTORY(Kugelblitz, "kugelblitz")