示例#1
0
文件: game.c 项目: jc429/276game
void Quit(){
	if(GameState==VERSUS){
		GoToMenu();
	}else{
		if(pause)
			GamePause();
		endgame = 1;
	}
}
示例#2
0
void GameManager::AI()
{
	CheckKey();
	if (GameStart() && !GamePause() && !GameOver())
	{
		Produce(_T("Enemy"));
		Produce(_T("Cloud"));
		Produce(_T("Angela"));
		CheckCollision();
		MoveIt();
		Fire();
		TrashRecycle();
	}
}
示例#3
0
文件: game.c 项目: jc429/276game
/*notice the default arguments for main.  SDL expects main to look like that, so don't change it*/
int main(int argc, char *argv[])
{
	
	debuginputs = 1,bsize = 5;

	/*defaults for placeholder reasons*/
	c1 = DEBUG;
	c2 = DEBUG;
	stage = ST_PLATFORM;
	/**/
	pause = 0;
	pausequeue = 0;
	fpress = 0;

	Init_All();
/*	SaveCFG(&f2,"res/test.txt");*/
	do
	{   
		UpdateMouse();
		if(pausequeue==1){
			pausequeue=0;
			GamePause();
		}
		pausetimer--;
		InputControl();
		if(GameState==VERSUS){
			DrawVersus();
			UpdateVersus();
		}else if(GameState==MAIN_MENU){
			DrawMainMenu();
			UpdateMenu();
		}else if(GameState==C_SELECT){
			DrawCharSel();
			UpdateCharSel();
		}else if(GameState==C_CREATOR){
			DrawCharCr();
			UpdateCharCr();
		}
		NextFrame();		
		if(endgame){
			done = 1;
		}
			
		ResetBuffer();
	}while(!done);
	exit(0);		/*technically this will end the program, but the compiler likes all functions that can return a value TO return a value*/
	return 0;
}
示例#4
0
void GameManager::Draw(CDC *cDC)
{
	if (GameStart())
	{
		if (GamePause() == TRUE)
		{
			Draw_Text(cDC, _T("按下回车恢复游戏"), Point(Game_Width / 2, Game_Height / 2));
		}
		else if (GameOver() == TRUE) {
			Draw_Text(cDC, _T("游戏结束"), Point(Game_Width / 2, Game_Height / 2));
		}
		else
		{
			for (int i = Index_Background; i <= Index_Angela; ++i) //Index_Cloud
			{
				CList<GameObject*, GameObject*> *now = GetList(i);
				POSITION pos = now->GetHeadPosition();
				while (pos != NULL)
				{
					now->GetNext(pos)->Draw(cDC);
				}
			}
			if (God()) {
				Draw_Text(cDC, _T("无敌模式已开启,按下F键关闭"), Point(110, 50));
			}
			else {
				Draw_Text(cDC, _T("无敌模式未开启,按下G键开启"), Point(118, 50));
			}
			Draw_Text(cDC, _T("生命值"), PlayerHP(), Point(60, 10));
			Draw_Text(cDC, _T("星星值"), PlayerStars(), Point(48, 30));

		}
	}
	else {

		Draw_Text(cDC,_T("按下回车键开始游戏"),Point(Game_Width/2, Game_Height/2));
	}
}
示例#5
0
void GameLayer::menuCallback_Pause(cocos2d::Ref* pSender)
{
	GamePause();
}
示例#6
0
文件: game.c 项目: jc429/276game
void InputControl(){
	p1prev = p1input;
	p2prev = p2input;
	SDL_PumpEvents();
	p1input = 0;
	p2input = 0;
	keys = SDL_GetKeyState(NULL);
	if(keys[SDLK_SPACE]){
		if(pausetimer<=0)
			GamePause();
	}
	if(keys[SDLK_LALT]&&!fpress){ /*if paused advance one frame*/
		if(!pausequeue&&pause){
			pausequeue=1;
			GamePause();
		}
		fpress = 1;
	}else if(!keys[SDLK_LALT]){
		fpress = 0;
	}
	if(keys[SDLK_ESCAPE])
		Quit();


	
	if(keys[SDLK_a])
		p1input |= 1<<7;
	if(keys[SDLK_d])
		p1input |= 1<<6;
	if(keys[SDLK_w])
		p1input |= 1<<5;
	if(keys[SDLK_s])
		p1input |= 1<<4;
	if(keys[SDLK_z])
		p1input |= 1<<3;
	if(keys[SDLK_x])
		p1input |= 1<<2;
	if(keys[SDLK_c])
		p1input |= 1<<1;
	if(keys[SDLK_v])
		p1input |= 1;


	if(keys[SDLK_LEFT])
		p2input |= 1<<7;
	if(keys[SDLK_RIGHT])
		p2input |= 1<<6;
	if(keys[SDLK_UP])
		p2input |= 1<<5;
	if(keys[SDLK_DOWN])
		p2input |= 1<<4;
	if(keys[SDLK_p])
		p2input |= 1<<3;
	if(keys[SDLK_o])
		p2input |= 1<<2;
	if(keys[SDLK_i])
		p2input |= 1<<1;
	if(keys[SDLK_u])
		p2input |= 1;


	if(debuginputs){
		for(i=0;i<8;i++){
			for(int m=0;m<4;m++){
				if(f1.inputs[m] & 1<<i)
					for(k=0;k<bsize;k++)
						for(l=0;l<bsize;l++)
								DrawPixel(screen,255,0,0,5+k+(bsize+1)*(8-i),(m+1)*(bsize+1)+l); 
				else 
					for(k=0;k<bsize;k++)
						for(l=0;l<bsize;l++)
							DrawPixel(screen,0,180,180,5+k+(bsize+1)*(8-i),(m+1)*(bsize+1)+l); 
			}
		}
		for(i=0;i<8;i++){
			for(int m=0;m<4;m++){
				if(f2.inputs[m] & 1<<i)
					for(k=0;k<bsize;k++)
						for(l=0;l<bsize;l++)
							DrawPixel(screen,255,0,0,955+k+(bsize+1)*(8-i),(m+1)*(bsize+1)+l); 
				else 
					for(k=0;k<bsize;k++)
						for(l=0;l<bsize;l++)
							DrawPixel(screen,0,180,180,955+k+(bsize+1)*(8-i),(m+1)*(bsize+1)+l);
			}
		}
	}

}
示例#7
0
void GameManager::CheckKey()
{
	if (GameStart() && !GamePause() && !GameOver() )
	{
		if (GetKey('w') || GetKey('W') || GetKey(VK_UP)) { MovePlane(Up); }
		if (GetKey('s') || GetKey('S') || GetKey(VK_DOWN)) { MovePlane(Down); }
		if (GetKey('a') || GetKey('A') || GetKey(VK_LEFT)) { MovePlane(Left); }
		if (GetKey('d') || GetKey('D') || GetKey(VK_RIGHT)) { MovePlane(Right); }
		if (!(GetKey('a') || GetKey('A') || GetKey(VK_LEFT)) && !(GetKey('d') || GetKey('D') || GetKey(VK_RIGHT)) ) { MovePlane(Stay); }

		//功能检测
		if (GetKey('G') || GetKey('g'))
		{
			OnGod();
		}

		if (GetKey('F') || GetKey('f'))
		{
			OffGod();
		}

		if (GameManager::GetKey(VK_SPACE))//!GetPlayer()->Kill()
		{
			Player* p = GetPlayer();
			if (p->FireStatus())
			{
				Play(_T("Player_Shot"));
				Produce(_T("Weapon"), Point(p->X() + p->Width() / 2 - 3, p->Y() - 4), p->WeaponID());
			}
		}

		if (GetKey('Q') || GetKey('q'))
		{
			Player* p = GetPlayer();
			if (p->FireStatus())
			{
				Produce(_T("Weapon"), Point(p->X() + p->Width() / 2 - 3, p->Y() - 4),11, GetList(Index_Enemy));
			}
		}
		if (GetKey('Z') || GetKey('z'))
		{
			CList<GameObject*, GameObject*> *now = GetList(Index_Angela);
			POSITION pos = now->GetHeadPosition();
			while (pos != NULL)
			{
				Angela* angela_ = static_cast<Angela*>(now->GetNext(pos));
				if (angela_->Op() == 1) {
					angela_->SetX(GetPlayer()->X() - 80);
					angela_->SetY(GetPlayer()->Y());
					angela_->Op(3, angela_->Position(), GetPlayer()->Position(), GetPlayer()->SpeedX(), GetPlayer()->SpeedY());
				}
				else if (angela_->Op() == 2)
				{
					angela_->SetX(GetPlayer()->X() + 80);
					angela_->SetY(GetPlayer()->Y());
					angela_->Op(3, angela_->Position(), GetPlayer()->Position(), GetPlayer()->SpeedX(), GetPlayer()->SpeedY());
				}
				
			}
		}
		if (GetKey('X') || GetKey('x'))
		{
			CList<GameObject*, GameObject*> *now = GetList(Index_Angela);
			POSITION pos = now->GetHeadPosition();
			while (pos != NULL)
			{
				Angela* angela_ = static_cast<Angela*>(now->GetNext(pos));
				if (angela_->Op() == 1) 
				{
					angela_->Op(1,  angela_->Position(), GetPlayer()->Position(), 0,0);
				}
				else if (angela_->Op() == 2)
				{
					angela_->Op(2,  angela_->Position(), GetPlayer()->Position(), 0,0);
				}
				

			}
		}
		if (GameManager::GetKey(VK_ESCAPE))
		{
			PauseGame();
		}
	}

	if (GameManager::GetKey(VK_RETURN))
	{
		if (GameStart() && GamePause() )
		{
			ResumeGame();
		}
		else if(!GameStart())
		{
			StartGame();
			Play(_T("Mission_Begin"));
		}
	}
}