📄 gamestatelogo.hpp
字号:
//-------------------------------------------------------------------------------------
//
// This is part of MarioDemo, a platformer demo for JGE++
//
// Copyright (C) 2006 James Hui (a.k.a. Dr.Watson)
//
// 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 2 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
//
// Bugs and comments can be forwarded to jhkhui@yahoo.com.
//
//-------------------------------------------------------------------------------------
#ifndef _GAME_STATES_LOGO_H_
#define _GAME_STATES_LOGO_H_
#include "GameState.h"
#define SPLASH_DELAY 2000.0f
#define SPLASH_DELAY_2 1000.0f
class MeshEffect;
class GameStateLogo: public GameState
{
private:
JTexture* mSplashTex;
JQuad* mSplashQuad;
int mMode;
int mStage;
float mAlpha;
float mTimer;
float mDelta;
float mMax;
float mMaxDelta;
MeshEffect* mEffect;
public:
GameStateLogo(GameApp* app): GameState(app)
{
mEffect = NULL;
}
virtual ~GameStateLogo()
{
}
virtual void Create()
{
mSplashTex = mEngine->LoadTexture("Res/Untitled-3.png", true);
mSplashQuad = new JQuad(mSplashTex, 0.0f, 0.0f, 640.0f, 480.0f);
mEffect = new MeshEffect(mSplashTex, 0, 0, 640, 480);
}
virtual void Destroy()
{
if (mSplashQuad)
delete mSplashQuad;
if (mSplashTex)
mEngine->FreeTexture(mSplashTex);
if (mEffect)
delete mEffect;
}
virtual void Start()
{
mMode = 0;
mStage = 0;
mAlpha = 0.0f;
mMax = 16.0f;
mMaxDelta = 16.0f/SPLASH_DELAY;
mDelta = 255/SPLASH_DELAY;
mEffect->SetMax(mMax);
mEffect->SetAlpha(mAlpha);
mEffect->SetPosition(0, 0);
mEngine->EnableVSync(true);
}
virtual void End()
{
mEngine->EnableVSync(false);
}
virtual void Update()
{
float dt = mEngine->GetDelta();
if(mEngine->GetButtonState(PSP_CTRL_START))
{
mMode = 2;
return;
}
if (mEngine->GetButtonState(PSP_CTRL_CROSS)) // skip everything...
{
mMode = 3;
mApp->SetNextState(GAME_STATE_SPLASH);
return;
}
if (mMode==0)
{
mAlpha += mDelta*dt;
if (mAlpha > 255.0f)
{
mAlpha = 255.0f;
mMode = 1;
mTimer = 0.0f;
}
mMax -= mMaxDelta*dt;
if (mMax<0.0f)
mMax = 0.0f;
}
else if (mMode==1)
{
mTimer += dt;
if (mTimer > SPLASH_DELAY_2)
mMode = 2;
mMax = 0.0f;
}
else if (mMode==2)
{
mAlpha -= mDelta*dt;
if (mAlpha < 0.0f)
{
mAlpha = 0.0f;
mStage++;
mMode = 3;
mApp->SetNextState(GAME_STATE_SPLASH);
}
mMax += mMaxDelta*dt;
if (mMax>100.0f)
mMax = 100.0f;
}
else
return;
mEffect->SetMax(mMax);
mEffect->SetAlpha(mAlpha);
mEffect->Update(dt);
}
virtual void Render()
{
mEngine->ClearScreen(ARGB(255,255,255,255));
if (mMode == 3) return;
mEffect->Render();
}
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -