Commit 8312a34b by BellCodeEditor

save project

parent 672e21f2
Showing with 19 additions and 5 deletions
......@@ -53,6 +53,7 @@ while True:
if event.key == locals.K_DOWN and setheading != "up":
setheading = "down"
snake_tou = down
# 蛇头根据方向变换
if snake_tou == right:
x += 30
......@@ -62,20 +63,32 @@ while True:
y -= 30
else:
y += 30
# 根据位置更改列表
position.append((x,y))
position.pop(0)
# FPSCLOCK方法
FPSCLOCK.tick(3)
# 将背景图画上去
# 渲染背景
screen.blit(background, (0, 0))
# 将贪吃蛇画上去
# 渲染蛇头
screen.blit(snake_tou,position[-1])
# 将贪吃蛇的身体画上去
# 渲染蛇身
# 通过列表遍历渲染蛇身
for i in range(len(position)-1):
screen.blit(body,position[i])
# 以下为调试方法
#screen.blit(body, (x-30, y))
#screen.blit(body, (x-60, y))
#screen.blit(body, (x-60, y-30))
# 将果实画上去
# 渲染食物
screen.blit(food, (360,180))
# 刷新画面
# 更新画面
pygame.display.update()
\ 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