Add fade-in/fade-out support to the cutscene
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@11331 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
e3283be6f0
commit
4186cd6a83
@ -30,8 +30,8 @@
|
||||
#include "karts/kart_properties.hpp"
|
||||
#include "modes/overworld.hpp"
|
||||
#include "physics/physics.hpp"
|
||||
#include "states_screens/cutscene_gui.hpp"
|
||||
#include "states_screens/main_menu_screen.hpp"
|
||||
#include "states_screens/race_gui_base.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
#include "tracks/track_object.hpp"
|
||||
#include "tracks/track_object_manager.hpp"
|
||||
@ -56,6 +56,8 @@ void CutsceneWorld::init()
|
||||
{
|
||||
World::init();
|
||||
|
||||
dynamic_cast<CutsceneGUI*>(m_race_gui)->setFadeLevel(1.0f);
|
||||
|
||||
m_duration = -1.0f;
|
||||
|
||||
//const btTransform &s = getTrack()->getStartTransform(0);
|
||||
@ -136,6 +138,19 @@ void CutsceneWorld::update(float dt)
|
||||
{
|
||||
m_time += dt;
|
||||
|
||||
if (m_time < 2.0f)
|
||||
{
|
||||
dynamic_cast<CutsceneGUI*>(m_race_gui)->setFadeLevel(1.0f - m_time / 2.0f);
|
||||
}
|
||||
else if (m_time > m_duration - 2.0f)
|
||||
{
|
||||
dynamic_cast<CutsceneGUI*>(m_race_gui)->setFadeLevel((m_time - (m_duration - 2.0f)) / 2.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
dynamic_cast<CutsceneGUI*>(m_race_gui)->setFadeLevel(0.0f);
|
||||
}
|
||||
|
||||
World::update(dt);
|
||||
World::updateTrack(dt);
|
||||
|
||||
@ -227,3 +242,12 @@ RaceGUIBase::KartIconDisplayInfo* CutsceneWorld::getKartsDisplayInfo()
|
||||
void CutsceneWorld::moveKartAfterRescue(AbstractKart* kart)
|
||||
{
|
||||
} // moveKartAfterRescue
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void CutsceneWorld::createRaceGUI()
|
||||
{
|
||||
m_race_gui = new CutsceneGUI();
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ class CutsceneWorld : public World
|
||||
|
||||
void abortCutscene()
|
||||
{
|
||||
m_duration = 0.0f;
|
||||
m_duration = m_time + 2.0f;
|
||||
}
|
||||
|
||||
public:
|
||||
@ -71,10 +71,7 @@ public:
|
||||
virtual void kartHit(const int kart_id) OVERRIDE;
|
||||
virtual void update(float dt) OVERRIDE;
|
||||
|
||||
virtual void createRaceGUI() OVERRIDE
|
||||
{
|
||||
m_race_gui = NULL;
|
||||
}
|
||||
virtual void createRaceGUI() OVERRIDE;
|
||||
|
||||
virtual void enterRaceOverState() OVERRIDE;
|
||||
|
||||
|
47
src/states_screens/cutscene_gui.cpp
Normal file
47
src/states_screens/cutscene_gui.cpp
Normal file
@ -0,0 +1,47 @@
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2012 Marianne Gagnon
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "states_screens/cutscene_gui.hpp"
|
||||
|
||||
CutsceneGUI::CutsceneGUI()
|
||||
{
|
||||
m_fade_level = 0.0f;
|
||||
}
|
||||
|
||||
CutsceneGUI::~CutsceneGUI()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CutsceneGUI::renderGlobal(float dt)
|
||||
{
|
||||
if (m_fade_level > 0.0f)
|
||||
{
|
||||
irr_driver->getVideoDriver()->draw2DRectangle(video::SColor(m_fade_level*255, 0,0,0),
|
||||
core::rect<s32>(0, 0,
|
||||
UserConfigParams::m_width,
|
||||
UserConfigParams::m_height));
|
||||
}
|
||||
}
|
||||
|
||||
void CutsceneGUI::renderPlayerView(const AbstractKart *kart)
|
||||
{
|
||||
|
||||
}
|
||||
|
63
src/states_screens/cutscene_gui.hpp
Normal file
63
src/states_screens/cutscene_gui.hpp
Normal file
@ -0,0 +1,63 @@
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2012 Marianne Gagnon
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#ifndef HEADER_RACE_GUI_HPP
|
||||
#define HEADER_RACE_GUI_HPP
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <irrString.h>
|
||||
using namespace irr;
|
||||
|
||||
#include "config/player.hpp"
|
||||
#include "states_screens/race_gui_base.hpp"
|
||||
#include "utils/cpp2011.h"
|
||||
|
||||
class AbstractKart;
|
||||
class InputMap;
|
||||
class Material;
|
||||
class RaceSetup;
|
||||
|
||||
/**
|
||||
* \brief Handles the overlay for cutscenes
|
||||
* \ingroup states_screens
|
||||
*/
|
||||
class CutsceneGUI : public RaceGUIBase
|
||||
{
|
||||
private:
|
||||
|
||||
float m_fade_level;
|
||||
|
||||
public:
|
||||
|
||||
CutsceneGUI();
|
||||
~CutsceneGUI();
|
||||
|
||||
void setFadeLevel(float level) { m_fade_level = level; }
|
||||
|
||||
virtual void renderGlobal(float dt);
|
||||
virtual void renderPlayerView(const AbstractKart *kart);
|
||||
|
||||
virtual const core::dimension2du getMiniMapSize() const OVERRIDE
|
||||
{
|
||||
return core::dimension2du(1,1);
|
||||
}
|
||||
}; // RaceGUI
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user