X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FHud.cc;h=90f5dd9418dd90f85bb25bc72ef631d0af5ebf90;hp=a7e141e1ef8a7d57138ffb1fc9a2dff80421e2e7;hb=d11d8c63ab52c7f6eca2815e47cd6401e72f2c8c;hpb=a31d65a998121df0651c57bfb68782e2a07d2e2f diff --git a/src/Hud.cc b/src/Hud.cc index a7e141e..90f5dd9 100644 --- a/src/Hud.cc +++ b/src/Hud.cc @@ -26,12 +26,12 @@ *******************************************************************************/ +#include #include +#include #include "Hud.hh" -#include - 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;