bc3145050f75ab5a5f0da6fed512030c11c58686
[supertux.git] / src / badguy / spike.cpp
1 #include "spike.h"
2
3 Spike::Spike(const Vector& pos, Direction dir)
4 {
5   sprite = sprite_manager->create("spike");
6   start_position = pos;
7   bbox.set_pos(Vector(0, 0));
8   bbox.set_size(32, 32);
9   set_direction(dir);
10 }
11
12 Spike::Spike(const lisp::Lisp& reader)
13 {
14   sprite = sprite_manager->create("spike");
15   reader.get("x", start_position.x);
16   reader.get("y", start_position.y);
17   bbox.set_size(32, 32);
18   int idir = 0;
19   reader.get("direction", idir);
20   set_direction((Direction) idir);
21 }
22
23 void
24 Spike::set_direction(Direction dir)
25 {
26   spikedir = dir;
27   switch(spikedir) {
28     case NORTH:
29       sprite->set_action("north");
30       break;
31     case SOUTH:
32       sprite->set_action("south");
33       break;
34     case WEST:
35       sprite->set_action("west");
36       break;
37     case EAST:
38       sprite->set_action("east");
39       break;
40     default:
41       break;
42   }
43 }
44
45 void
46 Spike::write(lisp::Writer& writer)
47 {
48   writer.start_list("spike");
49   writer.write_float("x", start_position.x);
50   writer.write_float("y", start_position.y);
51   writer.write_int("direction", spikedir);
52   writer.end_list("spike");
53 }
54
55 void
56 Spike::kill_fall()
57 {
58   // you can't kill a spike
59 }
60
61 void
62 Spike::active_action(float )
63 {
64 }