Lesson 07 Let’s Running-Man ! 🕺🏻¶
Create Running Man on pygame window¶
This is the initial code provided for you:
import pygame
# Initialize pygame
pygame.init()
# Constants
WIDTH,HEIGHT=800,600
SAND = (255,255,255)
# Game setup
# window size
screen = pygame.display.set_mode((WIDTH,HEIGHT))
# window caption
pygame.display.set_caption("Chrome Dino Game")
# Create a Frame Rate object
clock = pygame.time.Clock()
# Load Running Man Images and append to a list:
##
# Game loop
running = True
while running:
screen.fill(SAND)
# screen.blit(image, (30, 363 ))
# To place an image on the screen
##
pygame.draw.rect(screen, (0, 0, 0), (0, 420, 800, 5)) # 地上黑线
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
pygame.display.flip()
clock.tick(30)
pygame.quit()
PPT Slides¶