Can you use this as start and then expand it when more time?
Start program loop
Initialize variables
Defalut locations for pong and player pads
Rounds to zero
Start game loop
Set up screen
Clear it
Print field, pong and pads
Calculate pong location
IF pong is out of field
End game loop
IF pong touches border
Calculate angle for movement
IF pong wont touch anything
move its position by "1 movement"
Read keyboard
IF Player1 moves
Calculate Player1 new location
If new location is possible, set it as player position
IF Player2 moves
Calculate Player2 new location
If new location is possible, set it as player position
Change values of Rounds etc. variables
End game loop
Check who is touched pong last time
Declare him as winner
Ask if one more game
If "yes" then LOOP
End game loop
E.K.Virtanen
www.ascii-world.com
Oh crab, forgot code tags
Start program loop
Initialize variables
Defalut locations for pong and player pads
Rounds to zero
Start game loop
Set up screen
Clear it
Print field, pong and pads
Calculate pong location
IF pong is out of field
End game loop
IF pong touches border
Calculate angle for movement
IF pong wont touch anything
move its position by "1 movement"
Read keyboard
IF Player1 moves
Calculate Player1 new location
If new location is possible, set it as player position
IF Player2 moves
Calculate Player2 new location
If new location is possible, set it as player position
Change values of Rounds etc. variables
End game loop
Check who is touched pong last time
Declare him as winner
Ask if one more game
If "yes" then LOOP
End game loop
E.K.Virtanen
www.ascii-world.com
Here's something similar to E.K.Virtanen's solution, but which fits better to the code i presented.
Set up window and load images Initialize needed variables such as position of ball and players // Main loop While not escape pressed // Read keyboard if keyup pressed move yPlayer up if keydown pressed move yPlayer down // Move ball according to hspeed and vspeed // Move computer opponent if ball above opponent move opponent up if ball below opponent move opponent down // Draw graphics draw playfield draw ball draw player draw opponent if ball collide with player or opponent change ball horizontal direction if ball collide with borders change ball vertical direction if ball out of screen reset ball add point to player who touched ball last end loop