Commit d85cc730 by BellCodeEditor

save project

parent f806a5c2
Showing with 9 additions and 2 deletions
import pygame
from pygame import locals
import random
import time
# 初始化pygame,为使用硬件做准备
pygame.init()
......@@ -18,6 +19,7 @@ left = pygame.image.load('left.png') # 头 朝左
up = pygame.image.load('up.png') # 头 朝上
down = pygame.image.load('down.png') # 头 朝下
w=pygame.font.Font('neuropol.ttf',18)
ff=pygame.font.Font('neuropol.ttf',70)
x, y = 240, 120
s,b=360,180
position = [(180, 90), (180, 120), (210, 120), (x, y)]
......@@ -64,6 +66,7 @@ while True:
position.pop(0)
# 将背景图画上去
qq='s:'+str(a)
xx='Game Over'
screen.blit(background, (0, 0))
# 将贪吃蛇的头画上去
screen.blit(snake_head, position[-1])
......@@ -72,8 +75,12 @@ while True:
screen.blit(ddd,(0,0))
for i in range(len(position)-1):
screen.blit(body, position[i])
if x<0 or x>630 or y<0 or y>450
if x<0 or x>630 or y<0 or y>450 or ((x,y) in position[:-1]):
sss=ff.render(xx,True,(0,0,0))
screen.blit(sss,(60,60))
pygame.display.flip()
time.sleep(3)
exit()
# 将果实画上去
screen.blit(food, (s,b))
# 刷新画面
......
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