Commit 1c53cc1a by BellCodeEditor

save project

parent 478bd4c4
Showing with 11 additions and 3 deletions
...@@ -2,6 +2,10 @@ import pygame ...@@ -2,6 +2,10 @@ import pygame
from pygame import locals from pygame import locals
import random import random
# 初始化pygame,为使用硬件做准备 # 初始化pygame,为使用硬件做准备
a=0
b=0
c=0
pygame.init() pygame.init()
myfot=pygame.font.Font('neuropol.ttf',18) myfot=pygame.font.Font('neuropol.ttf',18)
# 创建一个窗口 # 创建一个窗口
...@@ -58,10 +62,12 @@ while True: ...@@ -58,10 +62,12 @@ while True:
newy=random.randint(1,16) newy=random.randint(1,16)
applex=newx*30-30 applex=newx*30-30
appley=newy*30-30 appley=newy*30-30
score+=10
else: else:
position.pop(0) position.pop(0)
score+=5 a+=5
b+=5
c+=5
position.append((x, y)) position.append((x, y))
...@@ -74,9 +80,10 @@ while True: ...@@ -74,9 +80,10 @@ while True:
screen.blit(body, position[i]) screen.blit(body, position[i])
infor='score'+str(score) infor='score'+str(score)
text=myfot.render(infor,True,(0,0,0)) text=myfot.render(infor,True,(a,b,c))
# 将果实画上去 # 将果实画上去
screen.blit(food, (applex, appley)) screen.blit(food, (applex, appley))
# 刷新画面 # 刷新画面
screen.blit(text,(530,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