Commit 66b7ca91 by BellCodeEditor

save project

parent cb0ff050
Showing with 15 additions and 5 deletions
import random
import pygame
from pygame import locals
score=0
# 初始化pygame,为使用硬件做准备
pygame.init()
......@@ -13,17 +14,23 @@ background = pygame.image.load('bg.png')
right = pygame.image.load('right.png')
food = pygame.image.load('apple.png')
body = pygame.image.load('body.png')
myfont=pygame.font.Font('neuropol.ttf',18)
if x==a_x and y==_y:
a_x=random.randint(0,21)*30
a_x=random.randint(0,15)*30
else:
po
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
# 接收到退出事件后退出程序
exit()
if x==a_x and y==_y:
a_x=random.randint(0,21)*30
a_x=random.randint(0,15)*30
score+=1
else:
pos.pop(0)
if x>0 or x<0
# 将背景图画上去
screen.blit(background, (0, 0))
# 将贪吃蛇画上去
......@@ -34,5 +41,7 @@ while True:
screen.blit(body, (180, 90))
# 将果实画上去
screen.blit(food, (360, 300))
text=myfont.render('Score:'+str(score),Ture,(0,0,0))
screen.blit(text,(540,10))
# 刷新画面
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