4 #include "badguy/bouncing_snowball.h"
5 #include "badguy/snowball.h"
6 #include "badguy/mrbomb.h"
7 #include "badguy/mriceblock.h"
8 #include "badguy/mrrocket.h"
10 Dispenser::Dispenser(const lisp::Lisp& reader)
12 reader.get("x", start_position.x);
13 reader.get("y", start_position.y);
14 reader.get("cycle", cycle);
15 reader.get("badguy", badguy);
16 bbox.set_size(32, 32);
17 sprite = sprite_manager->create("dispenser");
18 sprite->set_action("working");
22 Dispenser::write(lisp::Writer& writer)
24 writer.start_list("dispenser");
26 writer.write_float("x", start_position.x);
27 writer.write_float("y", start_position.y);
28 writer.write_float("cycle", cycle);
29 writer.write_string("badguy", badguy);
31 writer.end_list("dispenser");
37 dispense_timer.start(cycle, true);
42 Dispenser::collision_squished(Player& player)
44 //TODO: Should it act like a normal tile when killed?
45 sprite->set_action("broken");
46 dispense_timer.start(0);
48 kill_squished(player);
53 Dispenser::active_action(float )
55 if (dispense_timer.check()) {
60 //TODO: Add launching velocity to certain badguys
61 // Add randomizer (themed to match tileset)
63 Dispenser::launch_badguy()
65 //FIXME: Does is_offscreen() work right here?
66 if (!is_offscreen()) {
67 if (badguy == "snowball")
68 Sector::current()->add_object(new SnowBall(get_pos().x, get_pos().y+32, dir));
69 else if (badguy == "bouncingsnowball")
70 Sector::current()->add_object(new BouncingSnowball(get_pos().x, get_pos().y+32, dir));
71 else if (badguy == "mrbomb")
72 Sector::current()->add_object(new MrBomb(get_pos().x, get_pos().y+32, dir));
73 else if (badguy == "mriceblock")
74 Sector::current()->add_object(new MrIceBlock(get_pos().x, get_pos().y+32, dir));
75 else if (badguy == "mrrocket")
76 Sector::current()->add_object(new MrRocket(get_pos().x, get_pos().y+32, dir));
77 else if (badguy == "random")
82 IMPLEMENT_FACTORY(Dispenser, "dispenser")