From 1920bdb5c09af67676fb0b0767abab799b808abc Mon Sep 17 00:00:00 2001 From: Christoph Sommer Date: Tue, 27 Jun 2006 16:12:13 +0000 Subject: [PATCH] Fixed unused variable, added some comments SVN-Revision: 3786 --- src/trigger/door.cpp | 7 ++++++- src/trigger/door.hpp | 10 +++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/trigger/door.cpp b/src/trigger/door.cpp index f21d01c11..d45073fd3 100644 --- a/src/trigger/door.cpp +++ b/src/trigger/door.cpp @@ -82,6 +82,7 @@ Door::update(float ) 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"); @@ -89,12 +90,14 @@ Door::update(float ) } 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"); @@ -110,10 +113,11 @@ Door::draw(DrawingContext& context) } 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; sprite->set_action("opening", 1); @@ -138,6 +142,7 @@ Door::collision(GameObject& other, const CollisionHit& hit) break; case OPEN: { + // if door is open and was touched by a player, teleport the player Player* player = dynamic_cast (&other); if (player) { state = CLOSING; diff --git a/src/trigger/door.hpp b/src/trigger/door.hpp index af7d218f6..9186129c7 100644 --- a/src/trigger/door.hpp +++ b/src/trigger/door.hpp @@ -51,11 +51,11 @@ private: CLOSING }; - DoorState state; - std::string target_sector; - std::string target_spawnpoint; - Sprite* sprite; - Timer stay_open_timer; + DoorState state; /**< current state of the door */ + std::string target_sector; /**< target sector to teleport to */ + std::string target_spawnpoint; /**< target spawnpoint to teleport to */ + Sprite* sprite; /**< "door" sprite to render */ + Timer stay_open_timer; /**< time until door will close again */ }; #endif -- 2.11.0