Commit da32943f by BellCodeEditor

save project

parent 9930e17a
Showing with 29 additions and 2 deletions
import pygame import pygame
from pygame import locals
# 初始化pygame,为使用pygame做准备 # 初始化pygame,为使用pygame做准备
pygame.init() pygame.init()
# 创建一个窗口 # 创建一个窗口
screen = pygame.display.set_mode((660,480)) screen = pygame.display.set_mode((660,480))
\ No newline at end of file
# 加载背景
bg = pygame.image.load('bg.png')
apple = pygame.image.load('apple.png')
snake_right = pygame.image.load('right.png')
snake_body = pygame.image.load('body.png')
# 重复循环
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
exit()
# 添加背景
screen.blit(bg,(0,0))
# 添加角色
screen.blit(apple,(540,330)) # 苹果
screen.blit(snake_right,(270,120)) # 蛇头
# 添加蛇身体
screen.blit(snake_body,(240,120))
screen.blit(snake_body,(210,120))
screen.blit(snake_body,(210,90))
# 刷新图像
pygame.display.update()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment