Commit b49f2494 by BellCodeEditor

save project

parent fdd98d87
Showing with 7 additions and 1 deletions
import pygame import pygame
import random import random
from pygame import locals from pygame import locals
a=0
# 初始化pygame,为使用硬件做准备 # 初始化pygame,为使用硬件做准备
pygame.init() pygame.init()
...@@ -17,6 +17,7 @@ body = pygame.image.load('body.png') # 身体 ...@@ -17,6 +17,7 @@ body = pygame.image.load('body.png') # 身体
left = pygame.image.load('left.png') # 头 朝左 left = pygame.image.load('left.png') # 头 朝左
up = pygame.image.load('up.png') # 头 朝上 up = pygame.image.load('up.png') # 头 朝上
down = pygame.image.load('down.png') # 头 朝下 down = pygame.image.load('down.png') # 头 朝下
f=pygame.font.Font('neuropol.ttf',20)
x, y = 240, 120 x, y = 240, 120
a_x,a_y=300,360 a_x,a_y=300,360
...@@ -68,9 +69,13 @@ while True: ...@@ -68,9 +69,13 @@ while True:
if a_x==x and a_y==y: if a_x==x and a_y==y:
a_x=30*random.randint(0,21) a_x=30*random.randint(0,21)
a_y=30*random.randint(0,15) a_y=30*random.randint(0,15)
a+=10
else: else:
position.pop(0) position.pop(0)
s=f.render('score:'+str(a),True,(0,0,0))
screen.blit(s,(510,10))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPSCLOCK.tick(3) FPSCLOCK.tick(3)
\ 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