Commit 215b544a by BellCodeEditor

save project

parent 7a515728
Showing with 9 additions and 0 deletions
......@@ -4,6 +4,7 @@ import random
# 初始化pygame,为使用硬件做准备
pygame.init()
x,y=240,120
sb=0
head="right"
apple_x=360
apple_y=300
......@@ -19,6 +20,7 @@ down = pygame.image.load('down.png')
up = pygame.image.load('up.png')
food = pygame.image.load('apple.png')
body = pygame.image.load('body.png')
my=pygame.font.Font('neuropol.ttf',18)
p=[(180,90),(180,120),(210,120),(240,120)]
while True:
for event in pygame.event.get():
......@@ -48,6 +50,7 @@ while True:
head="up"
p.append((x,y))
if apple_x==x and apple_y==y:
sb+=10
s=random.randint(1,22)
b=random.randint(1,16)
apple_x=s*30-30
......@@ -59,6 +62,7 @@ while True:
screen.blit(background, (0, 0))
# 将贪吃蛇画上去
if head=='right':
screen.blit(right, (x, y))
elif head=='left':
......@@ -73,5 +77,9 @@ while True:
# 将果实画上去
screen.blit(food, (apple_x, apple_y))
info="score:"+str(sb)
text=my.render(info,True,(0,0,0))
screen.blit(text,(540,0))
# 刷新画面
pygame.display.update()
\ 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