/*] Copyright (c) 2009-2010, Charles McGarvey [************************** **] All rights reserved. * * vi:ts=4 sw=4 tw=75 * * Distributable under the terms and conditions of the 2-clause BSD license; * see the file COPYING for a complete text of the license. * **************************************************************************/ #include #include #include #include "GameLayer.hh" #include "TitleLayer.hh" void TitleLayer::addedToCore() { mFadeIn.init(0.0, 1.0); mFadeIn.reset(0.1); mGameLayer = GameLayer::alloc(); } void TitleLayer::update(Mf::Scalar t, Mf::Scalar dt) { mFadeIn.update(t, dt); } void TitleLayer::draw(Mf::Scalar alpha) const { glClearColor(0.0, 0.0, mFadeIn.getState(alpha), 1.0); glClear(GL_COLOR_BUFFER_BIT); } bool TitleLayer::handleEvent(const Mf::Event& event) { switch (event.type) { case SDL_KEYUP: if (event.key.keysym.sym == SDLK_ESCAPE) { break; } Mf::LayerP titleLayer = Mf::core.pop(this); Mf::Lerp interp(0.1); interp.init(0.0, 1.0); Mf::Transition::Ptr transition = Mf::Transition::alloc(mGameLayer, titleLayer, interp); Mf::core.push(transition); return true; } return false; }