Commit dbd13726 by BellCodeEditor

save project

parent 6de78f3a
Showing with 24 additions and 2 deletions
......@@ -9,7 +9,7 @@ x,y = 240,120
# 创建一个窗口
screen = pygame.display.set_mode((660, 480))
FPSCLOCK = pygame.time.Clock()
position[(210,120),(180,120),(180,90),(x,y)]
position=[(210,120),(180,120),(180,90),(x,y)]
# 背景
background = pygame.image.load('bg.png')
right = pygame.image.load('right.png')
......@@ -22,13 +22,23 @@ while True:
# 接收到退出事件后退出程序
exit()
# 将背景图画上去
if setheading == locals.K_LEFT and sethding != "left":
setheading ='left'
if setheading == locals.K_UP and sethding != "right":
setheading ='up'
if setheading == locals.K_DOWN and sethding != "down":
setheading = 'down'
if setheading == locals.K_RIGHT and sethding != "left":
setheading = 'right'
x +=30
position.append((x,y))
position.pop(0)
screen.blit(background, (0, 0))
# 将贪吃蛇画上去
screen.blit(right,(x, y))
for i in range(len(position)-1):
screen.blit(body, position[-1])
screen.blit(body, position[i])
# 将贪吃蛇的身体画上去
#screen.blit(body, (210, 120))
#screen.blit(body, (180, 120))
......@@ -43,3 +53,14 @@ while True:
if setheading =='left' :
x = x-30
elif setheading =='down':
y = y+30
elif setheading == 'up':
y = y-30
else:
y = x+30
\ 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