Skip to content

Commit

Permalink
Working on input
Browse files Browse the repository at this point in the history
  • Loading branch information
hkeeble committed Apr 18, 2014
1 parent 6620cb6 commit 31c8c80
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
5 changes: 5 additions & 0 deletions include/Game.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,13 @@ namespace IrrGame
GameState state;
InputHandler keyboard;
World world; /*!< The game world currently loaded. */
bool drawDebugHUD;

void HandleDebugHUD();

#ifdef _DEBUG
DebugHUD dbgHUD; /*!< The debugging HUD. */
#endif // _DEBUG
};
}
#endif // IRRGAME_H
8 changes: 8 additions & 0 deletions include/InputHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@

using namespace irr;

enum class KeyState
{
Pressed, /*!< Key has just been pressed. */
Released, /*!< Key has just been released. */
Down, /*!< Key is held down. */
Up /*!< Key is up. */
};

class InputHandler : public IEventReceiver
{
public:
Expand Down
21 changes: 19 additions & 2 deletions src/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace IrrGame
iVideoDriver = nullptr;
iGUIEnv = nullptr;
dbgHUD = DebugHUD();
drawDebugHUD = true;
}

void Game::Init()
Expand Down Expand Up @@ -79,8 +80,10 @@ namespace IrrGame
world.Render();
iGUIEnv->drawAll();

dbgHUD.Update(cfg, 0);
dbgHUD.Render();
HandleDebugHUD(); // Handles the debug HUD, only draws in debug build

if(keyboard.IsKeyDown(KEY_ESCAPE))
state = EXIT;

iVideoDriver->endScene();
}
Expand Down Expand Up @@ -109,4 +112,18 @@ namespace IrrGame
if(iDevice)
FreeIDevice();
}

void Game::HandleDebugHUD()
{
#ifdef _DEBUG
if(drawDebugHUD)
{
dbgHUD.Update(cfg, 0);
dbgHUD.Render();
}

if(keyboard.IsKeyDown(KEY_TAB))
drawDebugHUD = !drawDebugHUD;
#endif // _DEBUG
}
}

0 comments on commit 31c8c80

Please sign in to comment.