Commit 057220fa by BellCodeEditor

save project

parent b53c3a4e
Showing with 6 additions and 4 deletions
...@@ -40,6 +40,8 @@ while True: ...@@ -40,6 +40,8 @@ while True:
setheading = "up" setheading = "up"
if event.key == locals.K_DOWN and setheading !="up": if event.key == locals.K_DOWN and setheading !="up":
setheading = "down" setheading = "down"
if x<0 or x>630 or y<0 or y>450:
exit()
if setheading == "right": if setheading == "right":
x+=30 x+=30
snake_hard = right snake_hard = right
...@@ -58,7 +60,7 @@ while True: ...@@ -58,7 +60,7 @@ while True:
b = random.randint(1,16) b = random.randint(1,16)
apple_x = a*30-30 apple_x = a*30-30
apple_y = b*30-30 apple_y = b*30-30
score+=10 score+=9999999999999999999999999999999999999999999999999999999999999
else: else:
positine.pop(0) positine.pop(0)
# 将背景图画上去 # 将背景图画上去
...@@ -72,8 +74,8 @@ while True: ...@@ -72,8 +74,8 @@ 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 = my_font.render(info,True,(0,0,0)) text = my_font.render(info,True,(0,0,0))
screen.blit(text,(540,10)) screen.blit(text,(0,10))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
# 设置帧数 # 设置帧数
FPSCLOCK = pygame.time.Clock();FPSCLOCK.tick(6) FPSCLOCK = pygame.time.Clock();FPSCLOCK.tick(3)
\ No newline at end of file \ 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