Commit d34ba274 by BellCodeEditor

auto save

parent 9dec2d84
Showing with 9 additions and 1 deletions
......@@ -3,7 +3,7 @@ from pygame import locals
import random
# 初始化pygame,为使用硬件做准备
pygame.init()
score=0
# 创建一个窗口
screen = pygame.display.set_mode((660, 480))
FPSCLOCK = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
......@@ -16,6 +16,7 @@ body = pygame.image.load('body.png') # 身体
left = pygame.image.load('left.png') # 头 朝左
up = pygame.image.load('up.png') # 头 朝上
down = pygame.image.load('down.png') # 头 朝下
ziti= pygame.font.Font('neuropol.ttf',20)
x, y = 240, 120
position = [(180, 90), (180, 120), (210, 120), (x, y)]
......@@ -24,6 +25,7 @@ apple_y=300
setheading = "right"
snake_head = right
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -53,6 +55,7 @@ while True:
else:
y += 30
if x==apple_x and y==apple_y:
score=score+10
applex=random.randint(1,22)
appley=random.randint(1,16)
apple_x=(applex-1)*30
......@@ -73,6 +76,10 @@ while True:
# 将果实画上去
screen.blit(food, (apple_x, apple_y))
info='score'+str(score)
wenzi=ziti.render(info,True,(255,255,255))
screen.blit(wenzi,(540,10))
# 刷新画面
pygame.display.update()
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