Commit fea11fba by BellCodeEditor

auto save

parent 9775f282
Showing with 8 additions and 7 deletions
...@@ -28,6 +28,7 @@ snake_head=right ...@@ -28,6 +28,7 @@ snake_head=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:
...@@ -42,13 +43,13 @@ while True: ...@@ -42,13 +43,13 @@ while True:
setheading = "left" setheading = "left"
snake_head=left snake_head=left
if event.type == locals.KEYDOWN: if event.type == locals.KEYDOWN:
if event.key == locals.K_UP and setheading != "up": if event.key == locals.K_UP and setheading != "down":
setheading = "down"
snake_head=down
if event.type == locals.KEYDOWN:
if event.key == locals.K_DOWN and setheading != "down":
setheading = "up" setheading = "up"
snake_head=up snake_head=up
if event.type == locals.KEYDOWN:
if event.key == locals.K_DOWN and setheading != "up":
setheading = "down"
snake_head=down
if setheading == "right": if setheading == "right":
...@@ -57,14 +58,14 @@ while True: ...@@ -57,14 +58,14 @@ while True:
x -= 30 x -= 30
elif setheading == "up": elif setheading == "up":
y -= 30 y -= 30
elif: else:
y += 30 y += 30
shenti.append((x,y)) shenti.append((x,y))
shenti.pop(0) shenti.pop(0)
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
# 将贪吃蛇画上去 # 将贪吃蛇画上去
screen.blit(right,shenti[-1]) screen.blit(snake_head,shenti[-1])
# 将贪吃蛇的身体画上去 # 将贪吃蛇的身体画上去
for i in range(len(shenti)-1): for i in range(len(shenti)-1):
screen.blit(body,shenti[i]) screen.blit(body,shenti[i])
......
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