GameStateEnd.hpp
上传用户:zhj2929
上传日期:2022-07-23
资源大小:28772k
文件大小:4k
- #ifndef _GAME_STATES_END_H_
- #define _GAME_STATES_END_H_
- #include "GameState.h"
- #include "../../JGE/include/JDistortionMesh.h"
- #define GAMESCREEN_WIDTH 512
- #define GAMESCREEN_HEIGHT 480
- class GameStateEnd:public GameState
- {
- private:
- JTexture* bgTexture;//背景图片
- int i;
- JLBFont* mPrint;
- float x, y;
- int number;
- int rendspeed;
- //Mesh特效
- JDistortionMesh* dis;
- int nRows;
- int nCols;
- float meshx;
- float meshy;
- public:
- GameStateEnd(GameApp* app): GameState(app)
- {
- bgTexture = NULL;
- dis =NULL;
- }
- virtual ~GameStateEnd()
- {
- }
- virtual void Create()
- {
- mEngine->LoadMP3("music/ending.mp3");
- if(i==4)
- {
- bgTexture = mEngine->LoadTexture("backgroud/end4.png", true);
- }
- else if(i==3)
- {
- bgTexture = mEngine->LoadTexture("backgroud/end3.png", true);
- }
- else if(i==2)
- {
- bgTexture = mEngine->LoadTexture("backgroud/end2.png", true);
- }
- else
- {
- bgTexture = mEngine->LoadTexture("backgroud/end1.png", true);
- }
- nRows=16;
- nCols=16;
- dis = new JDistortionMesh(bgTexture, 0.0f, 0.0f, GAMESCREEN_WIDTH, GAMESCREEN_HEIGHT, nCols, nRows);
- mPrint=new JLBFont("f3",16,true);
- }
-
- virtual void Destroy()
- {
- if (bgTexture)
- mEngine->FreeTexture(bgTexture);
- if (mPrint)
- delete mPrint;
- if (dis) delete dis;
- }
-
- virtual void Start()
- {
- mEngine->PlayMP3();
- x=200.0f;
- y=200.0f;
- number=1;
- rendspeed=500;
- meshx=0.0f;
- meshy=0.0f;
- }
- virtual void End()
- {
- mEngine->EnableVSync(false);
- mEngine->StopMP3();
- mEngine->FreeMP3();
- }
- virtual void Update()
- {
- float dt = mEngine->GetDelta();
-
- static float t=0.0f;
- int i, j, col;
- t+=dt;
- for(i=0;i<nRows;i++)
- for(j=1;j<nCols-1;j++)
- {
- dis->SetDisplacement(j,i,cosf(t*5+j/2)*5,0);
- col=int((cosf(t*5+(i+j)/2)+1)*35);
- dis->SetColor(j,i,0xFF<<24 | col<<16 | col<<8 | col);
-
- }
- rendspeed--;
- if(number==0)
- {
- mApp->LoadGameStateSplash();
- mApp->SetNextState(GAME_STATE_SPLASH);
- return;
- }
- }
- virtual void Render()
- {
- mEngine->ClearScreen(ARGB(255,255,255,255));
-
- //背景的渲染
- dis->Render(meshx, meshy);
- mPrint->SetColor(ARGB(255,255,255,255));
- if(number==1&&rendspeed)
- {
- x=200;
- mPrint->printf(x,y,"%s", "Game Over!");
- }
- else if(number==2&&rendspeed)
- {
- x=150;
- mPrint->printf(x, y,"%s", "Code:Second team");
- }
- else if(number==3&&rendspeed)
- {
- x=100;
- mPrint->printf(x, y,"%s", "Team Member:Snow Angel");
- }
- else if(number==4&&rendspeed)
- {
- x=200;
- mPrint->printf(x, y,"%s", "Hersey");
- }
- else if(number==5&&rendspeed)
- {
- x=150;
- mPrint->printf(x, y,"%s", "Yang Bo");
- }
- else if(number==6&&rendspeed)
- {
- x=200;
- mPrint->printf(x, y,"%s", "Cathy");
- }
- else if(number==7&&rendspeed)
- {
- x=200;
- mPrint->printf(x, y,"%s", "Ring");
- }
- else if(number==8&&rendspeed)
- {
- x=200;
- mPrint->printf(x, y,"%s", "One");
- }
- else if(number==9&&rendspeed)
- {
- x=100;
- mPrint->printf(x, y,"%s", "Thanks for Your Support!");
- }
- else if(number==0)
- {
- }
- if(!rendspeed)
- {
- rendspeed=500;
- if(number==1)
- {
- number=2;
- }
- else if(number==2)
- {
- number=3;
- }
- else if(number==3)
- {
- number=4;
- }
- else if(number==4)
- {
- number=5;
- }
- else if(number==5)
- {
- number=6;
- }
- else if(number==6)
- {
- number=7;
- }
- else if(number==7)
- {
- number=8;
- }
- else if(number==8)
- {
- number=9;
- }
- else if(number==9)
- {
- number=0;
- }
- }
- }
- virtual void setI(int j)
- {
- i=j;
- }
- };
- #endif