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