1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
//\====================================================================================
//\ Author: Declan.Corcoran
//\ About : SplashScreenState.cpp -
//\
//\ Creates the SplashScreenState source file. This cpp defines the Splash Screen that
//\ is to be used just before the game takes you into the menu state.
//\
//\ This cpp file defines the waiting period until the transition occurs
//\====================================================================================
#include "DeltaTime.h"
#include "Scene_SplashScreen.h"
#include "SceneManager.h"
#include "Sprite.h"
#include "InputHandler.h"
#include "Texture.h"
#include "ScreenResolution.h"
#include "Weather.h"
#include "Font.h"
#include <string>
#include <vector>
//#include "AnimatedSprite.h"
// DECLAN FOR FUCK SAKE, DON'T USE ANY MAGIC NUMBERS; I GOT IT WORKING FOR YOU, BUT I'M NOT GONNA LEAVE YOU WITH NO WORK TO DO ;)
Scene_SplashScreen::Scene_SplashScreen(SceneManager* p_Scene)
{
m_pSceneManager = p_Scene;
m_pSprite = new Sprite( "SplashScreen.JPG", "BackGround" );
m_pWeather = new Weather();
}
Scene_SplashScreen::~Scene_SplashScreen()
{
delete m_pSprite;
delete m_pWeather;
}
void Scene_SplashScreen::OnLoad()
{
m_pSprite->OnLoad();
m_pWeather->OnLoad();
m_pWeather->StartWeather( "Rain", 6, false );
m_v2BackGroundPos = Vector2(0,0);
m_v2BackGroundSize = Vector2( 4096, 768.f);
m_pSprite->SetSize( m_v2BackGroundSize.X, m_v2BackGroundSize.Y );
m_fFrameWaiting = 0;
m_fWaitTimeAmount = 10.01f; // Seconds
m_pInputHandler = InputHandler::GetInstance();
}
void Scene_SplashScreen::OnUnload()
{
m_pSprite->OnUnload();
m_pWeather->OnUnload();
}
void Scene_SplashScreen::Update()
{
ScreenScroll();
DeltaTime* pDT = DeltaTime::GetInstance();
m_pWeather->Update(Vector2(0,0));
m_fFrameWaiting += pDT->GetDeltaTime();
if( m_fFrameWaiting >= m_fWaitTimeAmount )
{
m_pSceneManager->ChangeState( SceneManager::eMENU_STATE );
}
if(m_pInputHandler->GetKeyState( SDLK_SPACE ) || m_pInputHandler->GetKeyState( SDLK_RETURN))
{
m_pSceneManager->ChangeState( SceneManager::eMENU_STATE );
}
}
void Scene_SplashScreen::Draw()
{
m_pSprite->Draw( m_v2BackGroundPos.X, m_v2BackGroundPos.Y, m_v2BackGroundSize.X, m_v2BackGroundSize.Y, false );
m_pWeather->Draw();
if( (m_v2BackGroundPos.X + m_v2BackGroundSize.X) < ScreenResolution::GetInstance()->GetScreenWidth() )
{
m_pSprite->Draw( (m_v2BackGroundPos.X + m_v2BackGroundSize.X), m_v2BackGroundPos.Y, m_v2BackGroundSize.X, m_v2BackGroundSize.Y, false );
}
//////////////////////////////////////
// Title Screen //
//////////////////////////////////////
Font* pFont = Font::GetInstance();
DeltaTime* pDT = DeltaTime::GetInstance();
if( (m_fFrameWaiting += pDT->GetDeltaTime()) < 2)
{
pFont->SetFont_Width_Height( 40, 30 );
pFont->SetFont_Colour( 0, 0, 0 );
pFont->SetFont_Opacity( 200 );
pFont->SetFont_Position( 128, 50 );
pFont->PrintFont( "Forest Of Serenity");
}
else if ( (m_fFrameWaiting += pDT->GetDeltaTime()) > 4)
{
pFont->SetFont_Width_Height( 40, 30 );
pFont->SetFont_Colour( 50, 50, 50);
pFont->SetFont_Opacity( 200 );
pFont->SetFont_Position( 128, 50 );
pFont->PrintFont( "Forest Of Serenity");
}
}
void Scene_SplashScreen::ScreenScroll()
{
m_v2BackGroundPos.X -= 300 * DeltaTime::GetInstance()->GetDeltaTime();
}
|