Esempio n. 1
0
void Render(Paddle p1, Paddle p2, Ball b, GLuint wins){
	glClear(GL_COLOR_BUFFER_BIT);
	glMatrixMode(GL_MODELVIEW);


	p1.Draw();
	p2.Draw();
	b.Draw();

	if (b.x + b.size < p1.x - p1.w){
		DrawSprite(wins, 1.1, 0.8, 0.1, 0.08, 0);
	}
	else if (b.x - b.size > p2.x + p2.w){
		DrawSprite(wins, -1.1, 0.8, 0.1, 0.08, 0);
	}
}
Esempio n. 2
0
/**************************************************************************//**
* @author Paul Blasi, Caitlin Taggart
*
* @par Description:
* The display callback. Draws each of the objects and displays score for each
* player. If the game is currently paused, it also draws a translucent box
* over the play area and the text "Paused".
*
*****************************************************************************/
void Display(void) 
{
	int length;
	
	glClear(GL_COLOR_BUFFER_BIT);
    
    BALL.Draw();
    LEFT_PLAYER.Draw();
    RIGHT_PLAYER.Draw();
    LEFT_WALL.Draw();
    RIGHT_WALL.Draw();
    TOP_WALL.Draw();
    BOTTOM_WALL.Draw();
    NET.Draw();

	string right_score = to_string(RIGHT_PLAYER.Score);
	string left_score = to_string(LEFT_PLAYER.Score);


	glColor4fv(WHITE);

	length = glutBitmapLength(GLUT_BITMAP_TIMES_ROMAN_24, (const unsigned char*)left_score.c_str());
	glRasterPos2i(50 - (200.0 / SCREEN_WIDTH * length / 2.0), 90);
	glutBitmapString(GLUT_BITMAP_TIMES_ROMAN_24, (const unsigned char*)left_score.c_str());

	length = glutBitmapLength(GLUT_BITMAP_TIMES_ROMAN_24, (const unsigned char*)right_score.c_str());
	glRasterPos2i(150 - (200.0 / SCREEN_WIDTH * length / 2.0), 90);
	glutBitmapString(GLUT_BITMAP_TIMES_ROMAN_24, (const unsigned char*)right_score.c_str());

    if (PAUSED)
    {
		float alphaBlack[4] = { 0.0, 0.0, 0.0, .60 };
		Paddle temp;
		temp = Paddle(Point(100, 50), 200, 100, alphaBlack);
		temp.Draw();

		glColor4fv(WHITE);
		length = glutBitmapLength(GLUT_BITMAP_TIMES_ROMAN_24, (const unsigned char*)"PAUSED");
		glRasterPos2i(100 - (200.0/SCREEN_WIDTH * length / 2.0), 50);
		glutBitmapString(GLUT_BITMAP_TIMES_ROMAN_24, (const unsigned char*)"PAUSED");
    }	

    //glFlush();
    glutSwapBuffers();
}