]> Dogcows Code - chaz/yoink/blob - src/Hud.hh
fixed documentation about where to find licenses
[chaz/yoink] / src / Hud.hh
1
2 /*] Copyright (c) 2009-2011, Charles McGarvey [*****************************
3 **] All rights reserved.
4 *
5 * Distributable under the terms and conditions of the 2-clause BSD license;
6 * see the file COPYING for a complete text of the license.
7 *
8 *****************************************************************************/
9
10 #ifndef _HUD_HH_
11 #define _HUD_HH_
12
13 #include <moof/drawable.hh>
14 #include <moof/math.hh>
15 //#include <moof/rectangle.hh>
16 #include <moof/sprite.hh>
17
18 #include "GameState.hh"
19
20
21 /**
22 * \file Hud.hh
23 * Heads-up Display
24 */
25
26
27 // forward declarations
28 class rectangle;
29
30 // TODO this stuff is still just hacked up
31
32 class ProgressBar : public moof::drawable
33 {
34 public:
35
36 ProgressBar(const moof::sprite& tilemap, int index);
37
38 void resize(const moof::rectangle& rect);
39
40 void setProgress(moof::scalar progress);
41
42 void draw(moof::scalar alpha = 0.0) const;
43
44 private:
45
46 moof::scalar mProgress;
47
48 moof::vector2 mVertices[8];
49 moof::scalar mWidth;
50
51 moof::sprite mTilemap;
52 moof::scalar mTexCoords[8];
53 moof::scalar mMidCoords[2];
54 };
55
56
57 class Hud;
58 typedef boost::shared_ptr<Hud> HudP;
59
60 class Hud
61 {
62 public:
63
64 static HudP alloc(GameState& state)
65 {
66 return HudP(new Hud(state));
67 }
68 Hud(GameState& state);
69
70
71 void setBar1Progress(moof::scalar progress)
72 {
73 // pass through
74 mBar1.setProgress(progress);
75 }
76
77 void setBar2Progress(moof::scalar progress)
78 {
79 // pass through
80 mBar2.setProgress(progress);
81 }
82
83 void setNumber(unsigned value);
84
85 void resize(int width, int height);
86
87 void update(moof::scalar t, moof::scalar dt);
88 void draw(moof::scalar alpha = 0.0) const;
89 bool handle_event(const moof::event& event);
90
91 private:
92
93 GameState& state_;
94
95 ProgressBar mBar1;
96 ProgressBar mBar2;
97
98 unsigned mNumber;
99 moof::sprite mFont;
100
101 moof::matrix4 mProjection;
102 };
103
104
105 #endif // _HUD_HH_
106
This page took 0.036255 seconds and 4 git commands to generate.