Commit 2f1b1cab by BellCodeEditor

save project

parent eb4f2176
Showing with 4 additions and 6 deletions
import pygame
from pygame import locals
from time import sleep
headPosX = 240
......@@ -7,24 +8,19 @@ headPosX = 240
pygame.init()
# 创建一个窗口
screen = pygame.display.set_mode((1920, 1080))
screen = pygame.display.set_mode((660, 480))
# 背景
background = pygame.image.load('bg.png')
right = pygame.image.load('right.png')
left = pygame.image.load('left.png')
up = pygame.image.load('up.png')
down = pygame.image.load('down.png')
food = pygame.image.load('apple.png')
body = pygame.image.load('body.png')
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
# 接收到退出事件后退出程序
exit()
if event.type == locals.KEY
# 将背景图画上去
screen.blit(background, (0, 0))
# 将贪吃蛇画上去
......@@ -37,6 +33,7 @@ while True:
screen.blit(food, (360, 300))
headPosX += 30
sleep(0.5)
# 刷新画面
pygame.display.update()
\ No newline at end of file
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