Commit a93b45e3 by BellCodeEditor

save project

parent ed5ec3f1
Showing with 5 additions and 3 deletions
......@@ -8,6 +8,7 @@ pygame.init()
screen = pygame.display.set_mode((660, 480))
FPSCLOCK = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
my_font=pygame.font.Font
# 背景
background = pygame.image.load('bg.png')
right = pygame.image.load('right.png') # 头 朝右
......@@ -45,13 +46,14 @@ while True:
snake_head = down
# 设置贪吃蛇的头部坐标
if setheading == "right":
if x<0 or x>630 or y<0 or y>450:
if setheading == "light"
x += 30
elif setheading == "left":
x -= 30
elif setheading == "up":
y -= 30
else:
else:setheading =="donw"
y += 30
if x==apple_x and y==apple_y:
apple_x = 30*random.randint(1,22)
......@@ -65,7 +67,7 @@ while True:
# 将贪吃蛇的身体画上去
info = "score:"+str(score)
text = my_font.render(info,true,(0,0,0))
screen.blit(text,(540,10))
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