X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FYoinkApp.cc;h=626fe1aea9ab18e823c49635573a19dad9dfac8c;hp=a1c2dbbf8133f273e2aca98efdf2dc3f8db133ef;hb=a5f0d391406a68275b41448fc3f49e8d8396c497;hpb=bfa6212d09d8735d8fd5e2638188e4a99f21ada4 diff --git a/src/YoinkApp.cc b/src/YoinkApp.cc index a1c2dbb..626fe1a 100644 --- a/src/YoinkApp.cc +++ b/src/YoinkApp.cc @@ -107,10 +107,12 @@ YoinkApp::YoinkApp(int argc, char* argv[]) : music("NightFusion"), punchSound("RobotPunch") { - Mf::Dispatcher::instance().addHandler("video.context_recreated", + Mf::Dispatcher::getInstance().addHandler("video.context_recreated", boost::bind(&YoinkApp::contextRecreated, this, _1), this); setupGL(); + Mf::Scalar fade[2] = {0.0, 1.0}; + musicFade.init(fade, 0.0); music.play(); state = 0.0; @@ -136,11 +138,12 @@ YoinkApp::YoinkApp(int argc, char* argv[]) : YoinkApp::~YoinkApp() { + std::cerr << "yoinkapp destructor" << std::endl; //delete heroine; delete font; delete testScene; - Mf::Dispatcher::instance().removeHandler(this); + Mf::Dispatcher::getInstance().removeHandler(this); } @@ -176,7 +179,7 @@ void YoinkApp::setupGL() //glLineWidth(10.0f); } -void YoinkApp::contextRecreated(const Mf::Notification& note) +void YoinkApp::contextRecreated(const Mf::Notification* note) { // Whenever the context and a new one created, it probably won't contain our // state so we need to set that up again. @@ -187,6 +190,10 @@ void YoinkApp::contextRecreated(const Mf::Notification& note) void YoinkApp::update(Mf::Scalar t, Mf::Scalar dt) { //dt *= 0.2; + + musicFade.update(dt); + music.update(t, dt); + music.setGain(musicFade.getValue()); fadeIn.update(dt); @@ -390,24 +397,39 @@ void YoinkApp::handleEvent(const Mf::Event& event) if (event.key.keysym.sym == SDLK_ESCAPE) { stop(); + break; } else if (event.key.keysym.sym == SDLK_f) { getVideo().toggleFull(); + break; } else if (event.key.keysym.sym == SDLK_SPACE) { heroine->getAnimation().startSequence("Punch"); punchSound.play(); + break; } else if (event.key.keysym.sym == SDLK_r) { testScene->refresh(); + break; + } + else if (event.key.keysym.sym == SDLK_t) + { + Mf::Dispatcher::getInstance().dispatch("video.context_recreated"); + break; + } + else if (event.key.keysym.sym == SDLK_p) + { + music.togglePlayPause(); + break; } else if (event.key.keysym.sym == SDLK_l) { getVideo().toggleCursorGrab(); getVideo().toggleCursorVisible(); + break; } case SDL_KEYUP: @@ -415,7 +437,7 @@ void YoinkApp::handleEvent(const Mf::Event& event) case SDL_MOUSEMOTION: case SDL_MOUSEBUTTONDOWN: - camera.adjustFromInput(event); + camera.handleEvent(event); break; case SDL_QUIT: @@ -444,8 +466,9 @@ int main(int argc, char* argv[]) try { - YoinkApp app(argc, argv); - status = app.run(); + YoinkApp* app = new YoinkApp(argc, argv); + status = app->run(); + delete app; } catch (Mf::Engine::Exception e) {