Commit 79a12948 by BellCodeEditor

save project

parent 67631707
Showing with 7 additions and 2 deletions
...@@ -17,14 +17,14 @@ body = pygame.image.load('body.png') # 身体 ...@@ -17,14 +17,14 @@ 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') # 头 朝下
font = pygame.font.Font()
x, y = 240, 120 x, y = 240, 120
position = [(180, 90), (180, 120), (210, 120), (x, y)] position = [(180, 90), (180, 120), (210, 120), (x, y)]
apx = 360 apx = 360
apy = 300 apy = 300
setheading = "right" setheading = "right"
snake_head = right snake_head = right
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:
...@@ -59,6 +59,7 @@ while True: ...@@ -59,6 +59,7 @@ while True:
c = random.randint(1,16) c = random.randint(1,16)
apx = q*30 apx = q*30
apy = c*30 apy = c*30
score
else: else:
position.pop(0) position.pop(0)
# 将背景图画上去 # 将背景图画上去
...@@ -72,5 +73,8 @@ while True: ...@@ -72,5 +73,8 @@ while True:
# 将果实画上去 # 将果实画上去
screen.blit(food, (apx, apy)) screen.blit(food, (apx, apy))
# 刷新画面 # 刷新画面
score ='Score:'+str(score)
t=font.render(score,true,(12,0,12))
screen.blit(text,(600,20))
pygame.display.update() pygame.display.update()
FPSCLOCK.tick(10) FPSCLOCK.tick(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