Commit e1378931 by BellCodeEditor

save project

parent 44ff4a1e
Showing with 15 additions and 8 deletions
......@@ -23,7 +23,7 @@ ax,ay=300,360
setheading = "right"
snake_head = right
score = 0
score=0
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -54,8 +54,12 @@ while True:
y += 30
position.append((x, y))
if x==ax and y ==ay:
ax = random.randint(0,660)
ay = random.randint(0,480)
num1 = random.randint(0,21)
ax = num1*30
num2 = random.randint(0,15)
ay = num2*30
score+=1
else:
position.pop(0)
# 将背景图画上去
......@@ -69,10 +73,14 @@ while True:
# 将果实画上去
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()
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