#include "video/drawing_context.hpp"
#include "lisp/lisp.hpp"
#include "lisp/writer.hpp"
+#include "audio/sound_manager.hpp"
Door::Door(const lisp::Lisp& reader)
: state(CLOSED)
writer.write_string("sector", target_sector);
writer.write_string("spawnpoint", target_spawnpoint);
-
+ sound_manager->preload("sounds/door.wav");
writer.end_list("door");
}
case CLOSED:
break;
case OPENING:
+ // if door has finished opening, start timer and keep door open
if(sprite->animation_done()) {
state = OPEN;
sprite->set_action("open");
- stay_open_timer.start(1.0);
+ stay_open_timer.start(1.0);
}
break;
case OPEN:
+ // if door was open long enough, start closing it
if (stay_open_timer.check()) {
state = CLOSING;
sprite->set_action("closing", 1);
}
break;
case CLOSING:
+ // if door has finished closing, keep it shut
if(sprite->animation_done()) {
state = CLOSED;
sprite->set_action("closed");
}
void
-Door::event(Player& who, EventType type)
+Door::event(Player& , EventType type)
{
switch (state) {
case CLOSED:
+ // if door was activated, start opening it
if (type == EVENT_ACTIVATE) {
state = OPENING;
+ sound_manager->play("sounds/door.wav");
sprite->set_action("opening", 1);
}
break;
break;
case OPEN:
{
+ // if door is open and was touched by a player, teleport the player
Player* player = dynamic_cast<Player*> (&other);
if (player) {
state = CLOSING;