#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)
sprite = sprite_manager->create("images/objects/door/door.sprite");
sprite->set_action("closed");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
+ bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
}
Door::Door(int x, int y, std::string sector, std::string spawnpoint)
sprite = sprite_manager->create("images/objects/door/door.sprite");
sprite->set_action("closed");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
+ bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
}
Door::~Door()
writer.write_float("y", bbox.p1.y);
writer.write_float("width", bbox.get_width());
writer.write_float("height", bbox.get_height());
-
+
writer.write_string("sector", target_sector);
writer.write_string("spawnpoint", target_spawnpoint);
-
+ sound_manager->preload("sounds/door.wav");
writer.end_list("door");
}
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:
void
Door::draw(DrawingContext& context)
{
- sprite->draw(context, bbox.p1, LAYER_TILES);
+ sprite->draw(context, bbox.p1, LAYER_BACKGROUNDTILES+1);
}
void
// 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;