]> Dogcows Code - chaz/yoink/blob - src/Hud.hh
reformatting
[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/Layer.hh>
22 #include <Moof/Math.hh>
23 #include <Moof/Rectangle.hh>
24 #include <Moof/Texture.hh>
25
26 #include "GameState.hh"
27
28
29 // TODO this stuff is still just hacked up
30
31 class ProgressBar : public Mf::Drawable
32 {
33 public:
34
35 ProgressBar(const Mf::Texture& tilemap, Mf::Texture::TileIndex index);
36
37 void resize(const Mf::Rectangle& rect);
38
39 void setProgress(Mf::Scalar progress);
40
41 void draw(Mf::Scalar alpha = 0.0) const;
42
43 private:
44
45 Mf::Scalar mProgress;
46
47 Mf::Vector2 mVertices[8];
48 Mf::Scalar mWidth;
49
50 Mf::Texture mTilemap;
51 Mf::Scalar mTexCoords[8];
52 Mf::Scalar mMidCoords[2];
53 };
54
55
56 class Hud;
57 typedef boost::shared_ptr<Hud> HudP;
58
59 class Hud : public Mf::Layer
60 {
61 public:
62
63 Hud(GameState& state);
64
65 static HudP alloc(GameState& state)
66 {
67 return HudP(new Hud(state));
68 }
69
70 void setBar1Progress(Mf::Scalar progress)
71 {
72 // pass through
73 mBar1.setProgress(progress);
74 }
75
76 void setBar2Progress(Mf::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(Mf::Scalar t, Mf::Scalar dt);
87 void draw(Mf::Scalar alpha = 0.0) const;
88 bool handleEvent(const Mf::Event& event);
89
90 private:
91
92 GameState& mState;
93
94 ProgressBar mBar1;
95 ProgressBar mBar2;
96
97 unsigned mNumber;
98 Mf::Texture mFont;
99
100 Mf::Matrix4 mProjection;
101 };
102
103
104 #endif // _HUD_HH_
105
This page took 0.036067 seconds and 4 git commands to generate.