Commit 9a6ceb94 by BellCodeEditor

save project

parent 9243b2b2
Showing with 16 additions and 8 deletions
......@@ -2,6 +2,8 @@ import pygame
from pygame import locals
import random
score=0
# 初始化pygame,为使用硬件做准备
pygame.init()
......@@ -54,15 +56,19 @@ while True:
y -= 30
else:
y += 30
my_font=pygame.font.Font("neuropol.ttf",18)
my_font.render("neuropol.ttf",True,(30,40,10))
screen.blit(text,(0,0))
position.append((x, y))
if x==apple_x and y==apple_y:
apple_x=random.randint(0,21)*30
apple_y=random.randint(0,15)*30
else:
position.pop(0)
score+=10
aplee_x=random.randint(0,660)
aplee_y=random.randint(0,480)
position.pop(0)
if x<0 or x>630 or y<0 or y>450:
exit()
# 将背景图画上去
screen.blit(background, (0, 0))
# 将贪吃蛇的头画上去
......@@ -71,8 +77,9 @@ while True:
for i in range(len(position)-1):
screen.blit(body, position[i])
# 将果实画上去
screen.blit(food, (apple_x,apple_y))
# 刷新画面
pygame.display.update()
FPSCLOCK.tick(6)
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