CS 4554- Computer Graphics I: Assignment 1:Pong

Requirements

You are to implement the classic Pong game by making changes to the well-commented example given.
The requirements are to add collision detection of the ball with the walls and the paddle, change the ball movement so that it moves in the direction defined by the trajectory, prevent the paddle from moving outside the court, and logic to determine when the game is over.

You may augment the basic requirement in any way you would like.

Download the Pong.zip C++ Project file and modify it to meet the requirement.

Description:

The framework provided contains three walls, a paddle and a ball. The paddle moves up and down using the left click and mouse movement or using keyboard Up and Down Arrow Button. The ball is set to move at a constant speed and direction. There is no collision detection. Pressing 's' starts the game, pressing 'r' resets it. The initial Ball position is set to (100,240) and the paddle Y position is set to 240(at center).

Description of the Source Code(For new GLUT functions)

  • In the main() function
  • glutReshapeFunc(resize_scene); //Initialize the viewport when the window size changes.
  • glutKeyboardFunc(key_press); //handle when the key is pressed
  • glutMouseFunc(handle_mouse_click); //check the Mouse Button(Left, Right and Center) status(Up or Down)
  • glutMotionFunc(handle_mouse_motion); // Check the Current mouse position when mouse moves
  • glutSpecialFunc(special_key); //Special Keyboard Key fuction(For Arrow button and F1 to F10 button)
  • draw_border(void), draw_paddle(void), draw_ball(void)
  • The three functions will draw the border, paddle and ball at their appropriate location.
  • void move_ball(int game)
  • This is a continous update function that will be called every 30 milisecond.