Commit d8832cc9 by BellCodeEditor

save project

parent dea25bef
ls.png

2.07 KB

ls1.png

1.99 KB

ls2.png

1.98 KB

ls3.png

2.03 KB

...@@ -6,25 +6,27 @@ from pygame import locals ...@@ -6,25 +6,27 @@ from pygame import locals
pygame.init() pygame.init()
ys_x=360 ys_x=360
ys_y=300 ys_y=300
# 创建一个窗口 # 创建一个窗口
screen = pygame.display.set_mode((660, 480)) screen = pygame.display.set_mode((660, 480))
FPSCLOCK = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数) FPSCLOCK = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
# 背景 # 背景
background = pygame.image.load('bg.png') background = pygame.image.load('bg.png')
right = pygame.image.load('right.png') # 头 朝右 right = pygame.image.load('ls1.png') # 头 朝右
food = pygame.image.load('ys.png') # 食物 苹果 food = pygame.image.load('ys.png') # 食物 苹果
body = pygame.image.load('body.png') # 身体 body = pygame.image.load('body.png') # 身体
left = pygame.image.load('left.png') # 头 朝左 left = pygame.image.load('ls2.png') # 头 朝左
up = pygame.image.load('up.png') # 头 朝上 up = pygame.image.load('ls.png') # 头 朝上
down = pygame.image.load('down.png') # 头 朝下 down = pygame.image.load('ls3.png') # 头 朝下
my_font=pygame.font.Font('neuropol.ttf',18)
x, y = 240, 120 x, y = 240, 120
position = [(180, 90), (180, 120), (210, 120), (x, y)] position = [(180, 90), (180, 120), (210, 120), (x, y)]
ys_x=360
ys_y=300
setheading = "right" setheading = "right"
snake_head = right snake_head = right
score=0
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == locals.QUIT: if event.type == locals.QUIT:
...@@ -73,6 +75,10 @@ while True: ...@@ -73,6 +75,10 @@ while True:
# 将果实画上去 # 将果实画上去
screen.blit(food, (ys_x, ys_y)) screen.blit(food, (ys_x, ys_y))
info='Score:'+str(score)
text=my_font.render(inf,Ttue,(0,0,0))
screen.blit(text,510,0)
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPSCLOCK.tick(5) FPSCLOCK.tick(5)
\ 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