Commit f9c9ce55 by BellCodeEditor

save project

parent b324b0fb
Showing with 6 additions and 0 deletions
......@@ -9,6 +9,7 @@ pygame.init()
screen = pygame.display.set_mode((660, 480))
FPSCLOCK = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
my_font = pygame.font.Font('neuropol.ttf',18)
# 背景
background = pygame.image.load('bg.png')
right = pygame.image.load('right.png') # 头 朝右
......@@ -24,6 +25,7 @@ position = [(180, 90), (180, 120), (210, 120), (x, y)]
setheading = "right"
snake_head = right
score = 0
while True:
for event in pygame.event.get():
......@@ -45,6 +47,8 @@ while True:
snake_head = down
# 设置贪吃蛇的头部坐标
if x<0 or x>630 or y<0 or y >450 :
exit()
if setheading == "right":
x += 30
elif setheading == "left":
......@@ -65,6 +69,8 @@ while True:
# 将贪吃蛇的头画上去
screen.blit(snake_head, position[-1])
# 将贪吃蛇的身体画上去
text = my_font.render('Score:'+str(score),True,(44, 64, 137))
screen.blit(text,(530,10))
for i in range(len(position)-1):
screen.blit(body, position[i])
......
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