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"
9 #include "badguy/poisonivy.h"
11 Dispenser::Dispenser(const lisp::Lisp& reader)
13 reader.get("x", start_position.x);
14 reader.get("y", start_position.y);
15 reader.get("cycle", cycle);
16 reader.get("badguy", badguy);
17 bbox.set_size(32, 32);
18 sprite = sprite_manager->create("dispenser");
19 sprite->set_action("working");
23 Dispenser::write(lisp::Writer& writer)
25 writer.start_list("dispenser");
27 writer.write_float("x", start_position.x);
28 writer.write_float("y", start_position.y);
29 writer.write_float("cycle", cycle);
30 writer.write_string("badguy", badguy);
32 writer.end_list("dispenser");
38 dispense_timer.start(cycle, true);
43 Dispenser::collision_squished(Player& player)
45 //TODO: Should it act like a normal tile when killed?
46 sprite->set_action("broken");
47 dispense_timer.start(0);
49 kill_squished(player);
54 Dispenser::active_action(float )
56 if (dispense_timer.check()) {
61 //TODO: Add launching velocity to certain badguys
62 // Add themed randomizer
63 // Fix initial direction (everyone but MrRocket walks the wrong direction)
65 Dispenser::launch_badguy()
67 //FIXME: Does is_offscreen() work right here?
68 if (!is_offscreen()) {
69 if (badguy == "snowball")
70 Sector::current()->add_object(new SnowBall(get_pos().x, get_pos().y+32, dir));
71 else if (badguy == "bouncingsnowball")
72 Sector::current()->add_object(new BouncingSnowball(get_pos().x, get_pos().y+32, dir));
73 else if (badguy == "mrbomb")
74 Sector::current()->add_object(new MrBomb(get_pos().x, get_pos().y+32, dir));
75 else if (badguy == "mriceblock")
76 Sector::current()->add_object(new MrIceBlock(get_pos().x, get_pos().y+32, dir));
77 else if (badguy == "mrrocket")
78 Sector::current()->add_object(new MrRocket(get_pos().x, get_pos().y+32, dir));
79 else if (badguy == "poisonivy")
80 Sector::current()->add_object(new PoisonIvy(get_pos().x, get_pos().y+32, dir));
81 else if (badguy == "random")
85 case 0: Sector::current()->add_object(new SnowBall(get_pos().x, get_pos().y+32, dir)); break;
86 case 1: Sector::current()->add_object(new BouncingSnowball(get_pos().x, get_pos().y+32, dir)); break;
87 case 2: Sector::current()->add_object(new MrBomb(get_pos().x, get_pos().y+32, dir)); break;
88 case 3: Sector::current()->add_object(new MrIceBlock(get_pos().x, get_pos().y+32, dir)); break;
89 case 4: Sector::current()->add_object(new MrRocket(get_pos().x, get_pos().y+32, dir)); break;
90 case 5: Sector::current()->add_object(new PoisonIvy(get_pos().x, get_pos().y+32, dir)); break;
96 IMPLEMENT_FACTORY(Dispenser, "dispenser")