Commit 790ed27c by BellCodeEditor

save project

parent 253362f1
Showing with 5 additions and 4 deletions
......@@ -7,7 +7,7 @@ pygame.init()
# 创建一个窗口
screen = pygame.display.set_mode((660, 480))
FPSCLOCK = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
score=0
# 背景
background = pygame.image.load('bg.png')
right = pygame.image.load('right.png') # 头 朝右
......@@ -24,7 +24,7 @@ apple_x=360
apple_y=300
setheading = "right"
snake_head = right
score=0
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -69,13 +69,14 @@ while True:
# 将贪吃蛇的头画上去
screen.blit(snake_head, position[-1])
# 将贪吃蛇的身体画上去
if
if x<0 or x>630 or y<0 or y>450:
exit()
# 将果实画上去
screen.blit(food, (360, 300))
info="Score:"+str(score)
text=my_font.render(info,True,(0,0,0))
screen.blit(text,(540,10))
screen.blit(text,(540,100))
if x<0 or x>630 or y<0 or y>630:
exit()
# 刷新画面
......
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