fix redraw at top-left of map
[Tsunagari.git] / src / window.h
blob9434d598b5d019c7534d01e871fcdecf722b64a8
1 /******************************
2 ** Tsunagari Tile Engine **
3 ** window.h **
4 ** Copyright 2011 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>
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 GameWindow& getWindow();
36 //! GameWindow Constructor
37 GameWindow(unsigned x, unsigned y, bool fullscreen);
39 //! GameWindow Destructor
40 virtual ~GameWindow();
42 //! GameWindow Initializer
43 bool init(ClientValues* conf);
45 //! Gosu Callback
46 void buttonDown(const Gosu::Button btn);
48 //! Gosu Callback
49 void buttonUp(const Gosu::Button btn);
51 //! Gosu Callback
52 void draw();
54 //! Gosu Callback
55 bool needsRedraw() const;
57 //! Gosu Callback
58 void update();
60 //! Syncronized time value used throughout the engine
61 int time();
63 private:
64 //! Calculate time passed since engine state was last updated
65 void calculateDt();
67 //! Process persistent keyboard input
68 void handleKeyboardInput();
70 boost::scoped_ptr<Resourcer> rc;
71 boost::scoped_ptr<World> world;
73 //! Last time engine state was updated.
74 int lastTime;
76 //! Milliseconds that have passed since engine last updated.
77 int dt; // delta time
79 //! Milliseconds that have passed since game started. Loops on overflow.
80 int now;
82 //! Call the garbage colelctor once a second.
83 int currentSecond;
85 struct keystate {
86 bool consecutive, initiallyResolved;
87 int since;
90 std::map<Gosu::Button, keystate> keystates;
93 #endif