lesje-python/pong_2.py
2022-12-06 18:01:23 +01:00

31 lines
928 B
Python

import pygame
import sys
# Some constants that we use in the program
BACKGROUND_COLOR = (255, 255, 255)
SCREEN_SIZE = (500, 500) # Screen size is 500 x 500
# This class will represent our game
class Game:
# This function will be called when the class is first created
def __init__(self):
pygame.init()
self.window = pygame.display.set_mode(SCREEN_SIZE)
pygame.display.set_caption("Hello world")
# This function will render the contents of the screen
def start(self):
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
# Fill the screen with the background color and update the screen
self.window.fill(BACKGROUND_COLOR)
pygame.display.flip()
# Create the game object and start the game
game = Game()
game.start()