Commit e1378931 by BellCodeEditor

save project

parent 44ff4a1e
Showing with 16 additions and 9 deletions
...@@ -23,7 +23,7 @@ ax,ay=300,360 ...@@ -23,7 +23,7 @@ ax,ay=300,360
setheading = "right" setheading = "right"
snake_head = right snake_head = right
score = 0 score=0
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:
...@@ -54,9 +54,13 @@ while True: ...@@ -54,9 +54,13 @@ while True:
y += 30 y += 30
position.append((x, y)) position.append((x, y))
if x==ax and y ==ay: if x==ax and y ==ay:
ax = random.randint(0,660) num1 = random.randint(0,21)
ay = random.randint(0,480) ax = num1*30
position.pop(0) num2 = random.randint(0,15)
ay = num2*30
score+=1
else:
position.pop(0)
# 将背景图画上去 # 将背景图画上去
...@@ -69,10 +73,14 @@ while True: ...@@ -69,10 +73,14 @@ while True:
# 将果实画上去 # 将果实画上去
screen.blit(food, (ax, ay)) screen.blit(food, (ax, ay))
info = "Score" +str(score)
text = qq.render(info,True,(0,0,0))
screen.blit(text ,(540,10))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPSCLOCK.tick(3) FPSCLOCK.tick(4)
info ="Score" + str(score)
text = qq.render(info, True, (0,0,0))
screen.blit(text,(540,10))
\ 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