1 // $Id: dart.cpp 3327 2006-04-13 15:02:40Z sommer $
3 // Dart - Your average poison dart
4 // Copyright (C) 2006 Christoph Sommer <supertux@2006.expires.deltadevelopment.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
26 const float SPEED = 200;
29 Dart::Dart(const lisp::Lisp& reader) : set_direction(false), parent(0)
31 reader.get("x", start_position.x);
32 reader.get("y", start_position.y);
34 sprite = sprite_manager->create("images/creatures/dart/dart.sprite");
35 physic.enable_gravity(false);
39 Dart::Dart(float pos_x, float pos_y, Direction d, const BadGuy* parent = 0) : set_direction(true), initial_direction(d), parent(parent)
41 start_position.x = pos_x;
42 start_position.y = pos_y;
44 sprite = sprite_manager->create("images/creatures/dart/dart.sprite");
45 physic.enable_gravity(false);
50 Dart::write(lisp::Writer& writer)
52 writer.start_list("dart");
53 writer.write_float("x", start_position.x);
54 writer.write_float("y", start_position.y);
55 writer.end_list("dart");
61 if (set_direction) dir = initial_direction;
62 physic.set_velocity_x(dir == LEFT ? -::SPEED : ::SPEED);
63 sprite->set_action(dir == LEFT ? "flying-left" : "flying-right");
73 Dart::collision_solid(GameObject& , const CollisionHit& )
80 Dart::collision_badguy(BadGuy& badguy, const CollisionHit& )
82 // ignore collisions with parent
83 if (&badguy == parent) {
92 Dart::collision_player(Player& player, const CollisionHit& hit)
95 return BadGuy::collision_player(player, hit);
100 IMPLEMENT_FACTORY(Dart, "dart")