Commit ec5bc27f by BellCodeEditor

save project

parent 5e82d83d
Showing with 16 additions and 1 deletions
...@@ -18,6 +18,7 @@ FPSCLock=pygame.time.Clock() ...@@ -18,6 +18,7 @@ FPSCLock=pygame.time.Clock()
setheading = "right" setheading = "right"
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == locals.QUIT: if event.type == locals.QUIT:
exit() exit()
...@@ -30,6 +31,20 @@ while True: ...@@ -30,6 +31,20 @@ while True:
setheading = "up" setheading = "up"
if event.key == locals.K_DOWN and setheading != "left": if event.key == locals.K_DOWN and setheading != "left":
setheading = "down" setheading = "down"
if setheading == "right":
x+=30
elif setheading == "left":
x-=30
elif setheading == "up":
y+=30
else:
y-=30
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
# 将贪吃蛇画上去 # 将贪吃蛇画上去
...@@ -46,7 +61,7 @@ while True: ...@@ -46,7 +61,7 @@ while True:
screen.blit(food, (360, 300)) screen.blit(food, (360, 300))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
x=x+30
FPSCLock.tick(3) FPSCLock.tick(3)
......
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