Пример #1
0
update_status ModuleUserInterface::Update()
{
	if (App->player->IsEnabled() && App->player2->IsEnabled())
	{
		if (App->board->CheckWinL() || App->player2->LoseCondition == true)
		{
			WinLose();
			if (check_time == 0)check_time = SDL_GetTicks();
		}

		else if (App->board->CheckWinR() || App->player->LoseCondition == true)
		{
			LoseWin();
			if (check_time == 0)check_time = SDL_GetTicks();
		}


		if (check_time != 0)
		{

			if (SDL_GetTicks() - check_time >= 2000)
			{
				check_time = 0;
				App->fade->FadeToBlack(App->level_1, App->menu_screen, 1);
			}

		}
	}


	return UPDATE_CONTINUE;
}
Пример #2
0
// Updates functions and positions every frame //
void UpdateGame(bool &play, DynamObject &redPaddle, DynamObject &bluePaddle, DynamObject &ball, 
	int &redScore, int &blueScore, float &ballInitX, float &ballInitY, int &ballDir, bool &winLose, bool &quit)
{
	if(winLose == false)
	{
		StartBall(play, ball, ballDir);
		BallCollisionWalls(ball, redScore, blueScore, ballInitX, ballInitY, play, ballDir);
		BallCollisionPaddles(ball, redPaddle, bluePaddle, play);
		PaddleMovement(redPaddle);
		AIBehaviour(bluePaddle, ball);
		UpdateBall(ball);
	}
	WinLose(redScore, blueScore, winLose, quit);
	
}
Пример #3
0
//-----------------------------------------------------------------
// Name: FrameAdvance()
// Desc: Called to signal that we are now rendering the next frame.
//-----------------------------------------------------------------
void CTetris::FrameAdvance( )
{
	static float fTotalFallTime = 0.f;
	
	m_FrameTimer.Tick((float)FPS);
	m_FallTimer.Tick();
	fTotalFallTime += m_FallTimer.GetTimeElapsed();
	
	ClearOldBlockFromBoard( );//clears the block from the board
	if( fTotalFallTime >= m_fCurrFallDelay )
	{   //######################### NOTE: My idea ######################################################
		//#1. Timer runs out                                                                           #
		//#2. check to see if block can move down                                                      #
		//#   a. if so move block down 1 row. done.                                                    #
		//#   b. if not check for row completion                                                       #
		//#      i. if nothing completed, done.                                                        #
		//#      ii. if completed, clear those rows                                                    #
		//#      iii. and everything above that row drops one row down.                                #
		//#           1. if more then one row is completed. Handle in order that you find compelted    #
		//#              meaning, ever row above the completion row moves down one row. and by the time# 
		//#              it reaches a non-complete row it's Y coordinate stores the amount n times that#
		//#              it has to move down                                                           #
		//#   c. start timer.                                                                          #
		//#   d. pick new block                                                                        #
		//#   e. start over.                                                                           #
		//##############################################################################################
		
		if( !MoveTetrad( ) ) //meaning it can't move down
		{
			RenderBlockintoBoard(); //Render the block into the board before you pick a new one
			CheckRowCompletion();
			switch ( WinLose() )
			{
			case WIN :  DisplayWin(*this);   break;
			case LOSE : DisplayLose(*this); m_bExit = true; break;
			}
			PickTetrad( ); //Picks new block and sets up possition
			m_fCurrFallDelay = m_fFallDelay[m_nLevel];
		}
		fTotalFallTime = 0.f;
	}
	
	while(m_bPause) { ProcessInput(); Sleep(10);}
	Scoreing();
	ProcessInput( ); //Gets user input and orientates block
	RenderBlockintoBoard(); //Puts block on the board
	DisplayBoard(*this);
}