Commit a93cf6b7 by BellCodeEditor

save project

parent 44927bda
Showing with 15 additions and 3 deletions
...@@ -54,16 +54,27 @@ while True: ...@@ -54,16 +54,27 @@ while True:
y -= 30 y -= 30
else: else:
y += 30 y += 30
if x>630:
x=0
elif x<0:
x=630
elif y>450:
y=0
elif y<0:
y=450
position.append((x, y)) position.append((x, y))
if (x,y) in position[0:-1]:
break
if x==apple_X and y==apple_Y: if x==apple_X and y==apple_Y:
apple_X=30*randint(0,21) apple_X=30*randint(0,21)
apple_Y=30*randint(0,14) apple_Y=30*randint(0,14)
Score+=10 Score+=10
else: else:
position.pop(0) position.pop(0)
if x>630 or x<0 or y>450 or y<0: # if x>630 or x<0 or y>450 or y<0:
over_txt=over.render("Game Over",True,(0,0,0)) # over_txt=over.render("Game Over",True,(0,0,0))
break # break
out_score="Score:"+str(Score) out_score="Score:"+str(Score)
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
...@@ -80,6 +91,7 @@ while True: ...@@ -80,6 +91,7 @@ while True:
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPSCLOCK.tick(ticktime) FPSCLOCK.tick(ticktime)
over_txt=over.render("Game Over",True,(0,0,0))
screen.blit(over_txt,(175,200)) screen.blit(over_txt,(175,200))
for i in range(6): for i in range(6):
pygame.display.update() pygame.display.update()
......
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