polish Resourcer documentation
[Tsunagari.git] / src / window.h
blob2ddaff0fb80c27ed2411360dd347dc4dbbffd637
1 /*********************************
2 ** Tsunagari Tile Engine **
3 ** window.h **
4 ** Copyright 2011-2012 OmegaSDG **
5 *********************************/
7 #ifndef WINDOW_H
8 #define WINDOW_H
10 #include <map>
11 #include <string>
12 #include <utility>
14 #include <boost/scoped_ptr.hpp>
15 #include <Gosu/Window.hpp> // for Gosu::Window
17 #include "common.h"
19 namespace Gosu {
20 class Button;
23 class Resourcer;
24 class World;
26 //! GameWindow Class
27 /*!
28 This class is structurally the main class of the Tsunagari Tile Engine.
29 It handles input and drawing.
31 class GameWindow : public Gosu::Window
33 public:
34 static const GameWindow& getWindow();
36 //! GameWindow Constructor
37 GameWindow();
39 //! GameWindow Destructor
40 virtual ~GameWindow();
42 //! GameWindow Initializer
43 bool init(char* argv0);
45 //! Width of the window in pixels.
46 int width() const;
48 //! Height of the window in pixels.
49 int height() const;
51 //! Gosu Callback
52 void buttonDown(const Gosu::Button btn);
54 //! Gosu Callback
55 void buttonUp(const Gosu::Button btn);
57 //! Gosu Callback
58 void draw();
60 //! Gosu Callback
61 bool needsRedraw() const;
63 //! Gosu Callback
64 void update();
66 //! Syncronized time value used throughout the engine
67 int time() const;
69 private:
70 //! Calculate time passed since engine state was last updated
71 void calculateDt();
73 //! Process persistent keyboard input
74 void handleKeyboardInput();
76 boost::scoped_ptr<Resourcer> rc;
77 boost::scoped_ptr<World> world;
79 //! Last time engine state was updated.
80 int lastTime;
82 //! Milliseconds that have passed since engine last updated.
83 int dt; // delta time
85 //! Milliseconds that have passed since game started. Loops on overflow.
86 int now;
88 //! Call the garbage colelctor once a second.
89 int currentSecond;
91 struct keystate {
92 bool consecutive, initiallyResolved;
93 int since;
96 std::map<Gosu::Button, keystate> keystates;
99 #endif