From: Marek Moeckel Date: Wed, 24 Nov 2004 17:45:26 +0000 (+0000) Subject: made badguy dispenser cycle configurable in level file X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=8def1b51aa9d94b719ce975b88cd58c936d7c06e;p=supertux.git made badguy dispenser cycle configurable in level file SVN-Revision: 2171 --- diff --git a/data/levels/test/bonusblock.stl b/data/levels/test/bonusblock.stl index 0ffa4c016..11dd329ee 100644 --- a/data/levels/test/bonusblock.stl +++ b/data/levels/test/bonusblock.stl @@ -10,7 +10,7 @@ (background (image "arctis.jpg") (speed 0.5)) (secretarea (x 400) (y 128) (message "You found a secret area!")) - (dispenser (x 500) (y 128) (badguy "snowball")) + (dispenser (x 500) (y 128) (badguy "snowball") (cycle 3)) (spawn-points (name "main") (x 100) diff --git a/src/badguy/dispenser.cpp b/src/badguy/dispenser.cpp index 84f7e2a04..e9e45ec2e 100644 --- a/src/badguy/dispenser.cpp +++ b/src/badguy/dispenser.cpp @@ -3,12 +3,11 @@ #include "dispenser.h" #include "badguy/bouncing_snowball.h" -#define DISPENSE_TIME 3 - Dispenser::Dispenser(LispReader& reader) { reader.read_float("x", start_position.x); reader.read_float("y", start_position.y); + reader.read_float("cycle", cycle); reader.read_string("badguy", badguy); bbox.set_size(32, 32); sprite = sprite_manager->create("snowball"); @@ -21,6 +20,7 @@ Dispenser::write(LispWriter& writer) writer.write_float("x", get_pos().x); writer.write_float("y", get_pos().y); + writer.write_float("cycle", cycle); writer.write_string("badguy", badguy); writer.end_list("dispenser"); @@ -29,7 +29,7 @@ Dispenser::write(LispWriter& writer) void Dispenser::activate() { - dispense_timer.start(DISPENSE_TIME, true); + dispense_timer.start(cycle, true); } bool diff --git a/src/badguy/dispenser.h b/src/badguy/dispenser.h index 571954f1b..76abc28bf 100644 --- a/src/badguy/dispenser.h +++ b/src/badguy/dispenser.h @@ -16,6 +16,7 @@ public: protected: bool collision_squished(Player& player); + float cycle; std::string badguy; Timer2 dispense_timer; };