Commit 6d312817 by BellCodeEditor

save project

parent bf0636ef
Showing with 9 additions and 5 deletions
......@@ -6,8 +6,6 @@ pygame.init()
x, y=240, 120
F=pygame.time.Clock()
J=[(180, 90),(180, 120),(210, 120),(x,y)]
s='right'
h=right
# 创建一个窗口
screen = pygame.display.set_mode((660, 480))
......@@ -20,6 +18,9 @@ down = pygame.image.load('down.png')
food = pygame.image.load('apple.png')
body = pygame.image.load('body.png')
h=right
s='right'
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -41,17 +42,20 @@ while True:
if s=='rihgt':
x += 30
elif s=='left':
x -= 30
elif s=='up':
y -= 30
else:
y += 30
J.append((x,y))
J.pop(0)
# 将背景图画上去
screen.blit(background, (0, 0))
# 将贪吃蛇画上去
screen.blit(right, J[-1])
screen.blit(h, J[-1])
# 将贪吃蛇的身体画上去
for i in range(len(J)-1):
screen.blit(body, J[i])
# screen.blit(body, (180, 120))
# screen.blit(body, (180, 90))
# 将果实画上去
screen.blit(food, (360, 300))
# 刷新画面
......
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