Bouncing Ball
Bouncing Ball
SOURCE CODE:
import pygame
# initialize pygame
pygame.init()
# define colors
red = (255, 0, 0)
black = (0, 0, 0)
# define ball
ball_obj = pygame.draw.circle(
surface=screen, color=red, center=[100, 100],
radius=40)
# define speed of ball
# speed = [X direction speed, Y direction speed]
speed = [1, 1]
# game loop
while True:
# event loop
for event in pygame.event.get():
# check if a user wants to exit the game or not
if event.type == pygame.QUIT:
exit()
# update screen
pygame.display.flip()
OUTPUT: