Commit 31a6171c by BellCodeEditor

save project

parent 368310fe
Showing with 12 additions and 2 deletions
......@@ -14,6 +14,7 @@ food = pygame.image.load('apple.png')
body = pygame.image.load('body.png')
x,y = 240, 120#设置头坐标
setheading = "right"
#设置贪吃蛇坐标
positine = [(210, 120),(180, 120),(180, 90),(x,y)]
while True:
......@@ -21,6 +22,15 @@ while True:
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+=30
positine.append((x,y))
......@@ -37,4 +47,4 @@ while True:
# 刷新画面
pygame.display.update()
# 设置帧数
FPSCLOCK = pygame.time.Clock();FPSCLOCK.tick(4)
\ No newline at end of file
FPSCLOCK = pygame.time.Clock();FPSCLOCK.tick(4)tick(3)
\ 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