Commit 4dd4abd7 by BellCodeEditor

auto save

parent 9f6a14e6
Showing with 5 additions and 4 deletions
...@@ -41,9 +41,9 @@ while True: ...@@ -41,9 +41,9 @@ while True:
snake_head = up snake_head = up
if event.key == locals.K_DOWN and setheading != "up": if event.key == locals.K_DOWN and setheading != "up":
setheading = 'down' setheading = 'down'
snake_head = down snake_head = down#控制贪吃蛇
if x<0 or x>630 or y<0 or y>450: if x<0 or x>630 or y<0 or y>450:
exit() exit()#判断结束
# 设置贪吃蛇的头部坐标 # 设置贪吃蛇的头部坐标
if setheading == "right": if setheading == "right":
x += 30 x += 30
...@@ -60,7 +60,7 @@ while True: ...@@ -60,7 +60,7 @@ while True:
apple_y=random.randint(1,16)*30-30 apple_y=random.randint(1,16)*30-30
score+=10 score+=10
else: else:
position.pop(0) position.pop(0)#贪吃蛇身体增加
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
...@@ -73,7 +73,7 @@ while True: ...@@ -73,7 +73,7 @@ while True:
screen.blit(food, (apple_x, apple_y)) screen.blit(food, (apple_x, apple_y))
# 刷新画面 # 刷新画面
info="Score"+str(score) info="Score"+str(score)
text=myfont.render(info,True,(0,0,0)) text=myfont.render(info,True,(0,255,0))
screen.blit(text,(540,10)) screen.blit(text,(540,10))
pygame.display.update() pygame.display.update()
FPSCLOCK.tick(5) FPSCLOCK.tick(5)
\ 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