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