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 Kugelblitz::Kugelblitz(const lisp::Lisp& reader)
25 : groundhit_pos_set(false)
27 reader.get("x", start_position.x);
28 start_position.y = 0; //place above visible area
29 bbox.set_size(63.8, 63.8);
30 sprite = sprite_manager->create("kugelblitz");
31 sprite->set_action("falling");
32 physic.enable_gravity(false);
36 Kugelblitz::write(lisp::Writer& writer)
38 writer.start_list("kugelblitz");
40 writer.write_float("x", start_position.x);
41 writer.write_float("y", start_position.y);
43 writer.end_list("kugelblitz");
47 Kugelblitz::activate()
49 physic.set_velocity_y(-300);
50 physic.set_velocity_x(-20); //fall a little to the left
54 Kugelblitz::collision_solid(GameObject& other, const CollisionHit& chit)
60 Kugelblitz::collision_badguy(BadGuy& other , const CollisionHit& chit)
62 //Let the Kugelblitz explode, too?
68 Kugelblitz::hit(const CollisionHit& chit)
71 if(chit.normal.y < -.5) {
72 if (!groundhit_pos_set)
74 pos_groundhit = get_pos(); //I'm leaving this in, we might need it here, too
75 groundhit_pos_set = true;
77 sprite->set_action("flying");
78 physic.set_velocity_y(0);
79 physic.set_velocity_x(100);
81 } else if(chit.normal.y < .5) { // bumped on roof
82 physic.set_velocity_y(0);
89 Kugelblitz::active_update(float elapsed_time)
91 BadGuy::active_update(elapsed_time);
94 IMPLEMENT_FACTORY(Kugelblitz, "kugelblitz")