Commit 53176449 by BellCodeEditor

save project

parent 8aba018b
Showing with 16 additions and 4 deletions
......@@ -3,24 +3,36 @@ from pygame import locals
# 初始化pygame,为使用硬件做准备
pygame.init()
FPSCLOCK = pygame.time.Clock()
FPSCLOCK=pygame.time.Clock()
x=240
y=120
# 创建一个窗口
screen = pygame.display.set_mode((660, 480))
position = [(180,90),(180,120),(210,120),(240,120)]
screen = pygame.display.set_mode((660, 480))
setheading = "right"
# 背景
background = pygame.image.load('bg.png')
right = pygame.image.load('right.png')
food = pygame.image.load('apple.png')
body = pygame.image.load('body.png')
x,y = 240,120
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
# 接收到退出事件后退出程序
exit()
if event.type == locals.KEYDOWN:
if event.key == locals.K_RIGHT and setheading != "left":
setheading = "right"
if event.key == locals.K_LEFT and setheading != "right":
setheading = "left"
if event.key == locals.K_UP and setheading != "down":
setheading = "up"
if event.key == locals.K_DOWN and setheading != "up":
setheading = "down"
x = x + 30
position.append((x,y))
position.pop(0)
......
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