Refer To Pongv1.Py Code Pygame
Refer To Pongv1.Py Code Pygame
library that allows for interaction of the program and gets an output
for graphics and events
from pygame, also importing a sub library called locals
brackets where the arguments are placed b/c we dont need input from outside of the
function
colon means the following lines are going to be a block of code
function block is indented under main
must call this function in the end
need to create events to allow program to shut down when a certain task or objective is
accomplished (prevents crash)
separate main while loop into 3 different phases in order to make sure everything is being
called in the proper order
for:
-
repitition control structure (loop) that goes through all contents of a list (elements)
assigns the elements of pygame.event.get() by sequence to the object (in this case, event)
and runs the code indented
o if statement embedded: pygame.quit deinitializes program and window, and sets
the object running to False, which stops the loop
pygame.event.get():
pygame.display.flip() switches screens; used b/c screen.fill((0,0,0)) fills a second screen with
black, and the function flips screen to other
-
place pygame.quit() at the end of the loop so that the last frame is rendered before
shutting down the game
Next, need 3 objects: the ball (pong), human controlled paddle, and AI controlled paddle -> use
classes
def __init__(self):
-