Пример #1
0
static void DrawPlayers_Free( float fade ) {
	const qhandle_t fontHandle = MenuFontToHandle( JP_GetScoreboardFont() );
	const float fontScale = 0.45f, lineHeight = 14.0f;
	float x = 0, y = 128.0f;
	const int playerCount = PlayerCount( TEAM_FREE );

	// dirty hack, 7 players means 4 on left, so +1 then /2 (8/2==4) will give a good number (4 left, 3 right)
	//	similarly, 8 players means 4 on left, so +1 then /2 (9/2==4) will give a good number (4 left, 4 right)
	ListPlayers_Free( fade, x, y, fontScale, fontHandle, lineHeight, 0, (playerCount + 1) / 2 );
	ListPlayers_Free( fade, x + SCREEN_WIDTH / 2.0f, y, fontScale, fontHandle, lineHeight, (playerCount + 1) / 2, playerCount / 2 );

	DrawSpectators( fade );
}
Пример #2
0
static void DrawPlayers_Team( float fade ) {
	const qhandle_t fontHandle = MenuFontToHandle( JP_GetScoreboardFont() );
	const float fontScale = 0.5f, lineHeight = 14.0f;
	float x = 0, y = 128.0f;

	if ( cgs.scores1 >= cgs.scores2 ) {
		ListPlayers_Team( fade, x, y, fontScale, fontHandle, lineHeight, TEAM_RED );
		ListPlayers_Team( fade, x + SCREEN_WIDTH / 2.0f, y, fontScale, fontHandle, lineHeight, TEAM_BLUE );
	}
	else {
		ListPlayers_Team( fade, x, y, fontScale, fontHandle, lineHeight, TEAM_BLUE );
		ListPlayers_Team( fade, x + SCREEN_WIDTH / 2.0f, y, fontScale, fontHandle, lineHeight, TEAM_RED );
	}

	DrawSpectators( fade );
}
Пример #3
0
void Game::SpectatorsCheers(){
	Point2d corner;
	// The cheering will last for 2 seconds
	if (clock() - cheer_start < 2000 && cheer_start != 0){
		frames_to_cheer++;
		if (frames_to_cheer == FRAMES_TO_CHEER_LIMIT){
			// The changes of colors for the spectators will 
			// happen once on FRAMES_TO_CHEER_LIMIT frames, 
			// which in our case is 10
			(m_last_scored == 0)?corner.set(-21.0f, 16.5f):corner.set(-21.0f, -1.0f);
			RemoveSpectators(m_last_scored);
			DrawSpectators(corner, m_last_scored);
			frames_to_cheer = 0;
		}
	}
}
Пример #4
0
/* The game is Initialized here: the players and the field. */ 
void Game::Init(){
	float xball, yball;
	ball = new Circle(10, BALL_CIRCLE_RAY);
	// Positions of player1
	player1_pos.push_back(Point2d(0.0f, 15.0f));
	player1_pos.push_back(Point2d(7.8f, 13.0f)); 
	player1_pos.push_back(Point2d(-5.7f, 3.5f)); 
	player1_pos.push_back(Point2d(-0.3f, 1.3f)); 
	player1_pos.push_back(Point2d(-7.0f, -8.0f));
	player1_pos.push_back(Point2d(7.5f, -11.0f));
	std::vector<Point2d>::iterator it;
	for(it = player1_pos.begin(); it != player1_pos.end(); ++it){
		// We have to keep every circle we create in a vector
		// to be able to make transformations with them later
		Circle circle(10, PLAYER_CIRCLE_RAY);
		circle.SetColor(RGBcolor(0.06f, 0.21f, 1.0f));
		circle.SetArmsColor(RGBcolor(0.2f, 0.40f, 1.0f));
		circle.DrawArms(m_system, *it);
		circle.DrawCircle(m_system, *it); 
		player1.push_back(circle);
	}

	// Positions of player2
	player2_pos.push_back(Point2d(0.0f, -14.5f)); 
	player2_pos.push_back(Point2d(-7.8f, -13.0f));
	player2_pos.push_back(Point2d(4.5f, -3.5f));
	player2_pos.push_back(Point2d(-0.3f, -1.3f));
	player2_pos.push_back(Point2d(7.0f, 8.0f));
	player2_pos.push_back(Point2d(-7.8f, 11.0f));
	for(it = player2_pos.begin(); it != player2_pos.end(); ++it){
		// Same as earlier on player1
		Circle circle(10, PLAYER_CIRCLE_RAY);
		circle.SetColor(RGBcolor(0.86f, 1.0f, 0.31f));
		circle.SetArmsColor(RGBcolor(0.89f, 0.54f, 0.05f));
		circle.DrawArms(m_system, *it);
		circle.DrawCircle(m_system, *it);
		
		player2.push_back(circle);
	}
	
	// Initialize the ball
	ball->SetColor(RGBcolor(0.0f, 0.0f, 0.0f));
	// Pick randomly the team and the player which holds the ball
	srand((unsigned int)time(NULL));
	m_team = rand() % 2;
	m_player = rand() % 6;
	if (m_team == 0){
		xball = player1_pos[m_player].x;
		yball = player1_pos[m_player].y - PLAYER_CIRCLE_RAY - BALL_CIRCLE_RAY;
	}
	else if (m_team == 1){
		xball = player2_pos[m_player].x; 
		yball = player2_pos[m_player].y + PLAYER_CIRCLE_RAY + BALL_CIRCLE_RAY; 
	}
	ball_position.set(xball, yball);
	ball->DrawCircle(m_system, ball_position);
	DrawSpectators();

	// Draw also the field
	field = new Field(m_system);
	field->DrawField();
	state = HOLD;

}
Пример #5
0
void Game::DrawSpectators(){
	DrawSpectators(Point2d(-21.0f, 16.5f), 0);
	DrawSpectators(Point2d(-21.0f, -1.0f), 1);
}