]> Dogcows Code - chaz/yoink/blob - src/Hud.hh
30c01363435a73becfe351528b1d07f0514fa0bb
[chaz/yoink] / src / Hud.hh
1
2 /*] Copyright (c) 2009-2010, Charles McGarvey [**************************
3 **] All rights reserved.
4 *
5 * vi:ts=4 sw=4 tw=75
6 *
7 * Distributable under the terms and conditions of the 2-clause BSD license;
8 * see the file COPYING for a complete text of the license.
9 *
10 **************************************************************************/
11
12 #ifndef _HUD_HH_
13 #define _HUD_HH_
14
15 /**
16 * @file Hud.hh
17 * Heads-up Display
18 */
19
20 #include <moof/drawable.hh>
21 #include <moof/math.hh>
22 //#include <moof/rectangle.hh>
23 #include <moof/sprite.hh>
24
25 #include "GameState.hh"
26
27
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.032463 seconds and 3 git commands to generate.