Start Your Game
Part of the Projects section of Coddy's Pygame journey. Lesson 30 of 31.
You have made a game of every kind in this journey: falling blocks, a space shooter, a runner, a platformer, Snake, Pong and a dungeon. Now make your own. Every one of them followed the same plan:
- 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 slime.
- 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. Your whole toolbox is open: pictures from assets/images, sounds and music, game states, a text map for each level. Shapes work too: 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, a small game drawn with shapes, 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. Draw it as a picture from
assets/imagesor as a shape: both pass.
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()
All lessons in Projects
Practice on your own: Pygame playground