Creating The Game Window and Basic Elements
Creating The Game Window and Basic Elements
We have already created a basic game window in the first step. Now, let's refine it by adding more
elements.
import pygame
import sys
# Initialize Pygame
pygame.init()
# Define colors
while True:
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
# Fill the screen with white
screen.fill(WHITE)
pygame.display.flip()
Next, we add a block and a paddle to the game. The block will be a simple rectangle.
import pygame
import sys
# Initialize Pygame
pygame.init()
# Define colors
RED = (255, 0, 0)
while True:
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
screen.fill(WHITE)
pygame.display.flip()