gameapp.cpp

来自「一个控制台VC++2005版的俄罗斯方块源码」· C++ 代码 · 共 70 行

CPP
70
字号
#include"Gameapp.h"

GameApp::GameApp()
{
	/*curState=LOGO;
	oldState=LOGO;
	pCurrent=new CLogo;*/
	strcpy(scoreStr,"分数:");
	strcpy(levelStr,"等级:");
	strcpy(nextStr,"下一方块:");
	frameColor=128;
	backColor=15;
}

GameApp::~GameApp()
{
}

void GameApp::Load()
{
		if(curState!=oldState)
		{
			switch(curState) 
			{
			case MENU:
				if(oldState==LOGO)
				{
				ClearBuffer(0,0,WIDTH,HEIGHT,backColor);
				DrawFrame(0,0,20,HEIGHT-1,frameColor);
				DrawText( 27, 1, 12,nextStr);
				DrawText( 26, 10, 12,levelStr);
				DrawText( 26, 12, 12,scoreStr);	
				}
				delete pCurrent;
				pCurrent=new CMenu;
				break;
			case GAME:
				delete pCurrent;
				pCurrent=new CGame;
				break;
			case HELP:
				delete pCurrent;
				pCurrent=new CHelp;
				break;
			case OVER:
				delete pCurrent;
				pCurrent=new COver;
				break;
			}
			oldState=curState;
		}		
}

void GameApp::Run()
{
	while(true)
	{
		Sleep(40);
		curState=pCurrent->Logic(curState!=PAUSE);
		if(curState==EXIT)
		{
			break;
		}
		if(curState!=PAUSE)
		{
		Load();	
		}
	}
	delete pCurrent;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?