Start Your Game
Lesson 39 of 40 in Coddy's Make Games with Pygame course.
You have made four games. Now make your own. Here is the plan every game in this course followed:
- A window and the game loop: events, update, draw, flip, tick.
- Something the player moves with keys.
- Something that moves by itself: falling blocks, a ball, a snake.
- A rule that ends the game: a collision, a score, a timer.
- Text that tells the player how they are doing.
Pick an idea. A spaceship that dodges asteroids. A car that drives between lanes. A cat that catches fish. Shapes are enough: a rectangle can be anything once it moves like that thing.
This lesson is steps 1 and 2. The example on the Solution tab is Rock Dodge, where a blue paddle will dodge falling rocks.
Challenge
EasyStart your game:
- Give the window your game's title, and a size of at least 320 by 240.
- Add a player the arrow keys move, kept inside the window.
Any game passes: the checks only look for a window, a player that moves when an arrow is held, and a loop that ends when the window closes.
Try it yourself
import pygame
pygame.init()
screen = pygame.display.set_mode((480, 360))
pygame.display.set_caption("My Game")
clock = pygame.time.Clock()
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
screen.fill((30, 30, 46))
pygame.display.flip()
clock.tick(60)
pygame.quit()
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Make Games with Pygame
Practice on your own: Pygame playground