Commit 6d312817 by BellCodeEditor

save project

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