]> Dogcows Code - chaz/yoink/blobdiff - src/Hud.cc
foundational changes; tying up some loose ends
[chaz/yoink] / src / Hud.cc
index a7e141e1ef8a7d57138ffb1fc9a2dff80421e2e7..90f5dd9418dd90f85bb25bc72ef631d0af5ebf90 100644 (file)
 
 *******************************************************************************/
 
+#include <Moof/Engine.hh>
 #include <Moof/OpenGL.hh>
+#include <Moof/Video.hh>
 
 #include "Hud.hh"
 
-#include <iostream>
-
 
 ProgressBar::ProgressBar(const Tilemap& tilemap, Tilemap::Index index) :
        mProgress(0.0),
@@ -118,12 +118,14 @@ void ProgressBar::draw(Mf::Scalar alpha) const
 }
 
 
-Hud::Hud() :
+Hud::Hud(GameLayer::State& state) :
+       mState(state),
        mBar1(Tilemap("StatusBars"), 0),
        mBar2(Tilemap("StatusBars"), 2),
        mFont("Font")
 {
-       resize(800, 600);
+       Mf::VideoP video = Mf::Engine::getInstance().getVideo();
+       resize(video->getWidth(), video->getHeight());
 }
 
 
@@ -145,7 +147,14 @@ void Hud::resize(int width, int height)
 }
 
 
-void Hud::draw(Mf::Scalar alpha) const
+void Hud::update(Mf::Engine& engine, Mf::Scalar t, Mf::Scalar dt)
+{
+       mState.interp.update(t, dt);
+       setBar1Progress(mState.interp.getState(dt));
+       setBar2Progress(1.0 - mState.interp.getState(dt));
+}
+
+void Hud::draw(Mf::Engine& engine, Mf::Scalar alpha) const
 {
        glMatrixMode(GL_PROJECTION);
        glPushMatrix();
@@ -171,10 +180,19 @@ void Hud::draw(Mf::Scalar alpha) const
        glPopMatrix();
 }
 
-bool Hud::handleEvent(Mf::Event& event)
+bool Hud::handleEvent(Mf::Engine& engine, const Mf::Event& event)
 {
        switch (event.type)
        {
+               case SDL_KEYUP:
+                       if (event.key.keysym.sym == SDLK_h)
+                       {
+                               // don't want the hud anymore
+                               engine.pop(this);
+                               return true;
+                       }
+                       break;
+
                case SDL_VIDEORESIZE:
                        resize(event.resize.w, event.resize.h);
                        break;
This page took 0.018893 seconds and 4 git commands to generate.