X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FYoinkApp.cc;h=7ec807bdb22de89f4c3a7d461e12b38063afec8d;hp=bf6d71ab8d462d81507ee6525be954287111a51e;hb=3cba2347188d70f5ee6e401774b8f86acfd1a3b9;hpb=4701bf580b75a7d77a460c6f14f9fc31fb109bbb diff --git a/src/YoinkApp.cc b/src/YoinkApp.cc index bf6d71a..7ec807b 100644 --- a/src/YoinkApp.cc +++ b/src/YoinkApp.cc @@ -32,6 +32,8 @@ #include +#include +#include #include #include #include @@ -107,7 +109,7 @@ 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(); @@ -117,7 +119,7 @@ YoinkApp::YoinkApp(int argc, char* argv[]) : state = 0.0; - heroine = CharacterPtr(new Character("RobotTrooper")); + heroine = Character::alloc("RobotTrooper"); heroine->getAnimation().startSequence("Run"); font = new TilemapFont; @@ -142,7 +144,7 @@ YoinkApp::~YoinkApp() delete font; delete testScene; - Mf::Dispatcher::instance().removeHandler(this); + Mf::Dispatcher::getInstance().removeHandler(this); } @@ -240,6 +242,7 @@ void YoinkApp::draw(Mf::Scalar alpha) //heroine->draw(alpha); + heroine->getAabb().draw(); hud.draw(); @@ -396,28 +399,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: @@ -445,11 +459,15 @@ void YoinkApp::handleEvent(const Mf::Event& event) int main(int argc, char* argv[]) { - std::cout << PACKAGE_STRING << std::endl + std::cout << std::endl << PACKAGE_STRING << std::endl << "Compiled " << __TIME__ " " __DATE__ << std::endl << "Send patches and bug reports to <" PACKAGE_BUGREPORT << ">." << std::endl << std::endl; +#if ! NDEBUG + Mf::setLogLevel(Mf::DEBUGGING); +#endif + int status = 0; try @@ -457,13 +475,14 @@ int main(int argc, char* argv[]) YoinkApp app(argc, argv); status = app.run(); } - catch (Mf::Engine::Exception e) + catch (Mf::Exception e) { - std::cerr << "Unhandled exception: " << e.what() << std::endl; + Mf::logError("unhandled exception: <<%s>>", e.what()); + Mf::logInfo("it's time to crash now :-("); status = 1; } - std::cout << "Goodbye..." << std::endl; + std::cout << std::endl << "Goodbye..." << std::endl << std::endl; return status; }