Commit 288a30c6 by BellCodeEditor

save project

parent 313b2bfb
Showing with 8 additions and 7 deletions
......@@ -16,6 +16,7 @@ right= pygame.image.load('right.png')
x,y=240,120
position=[(180,90),(180,120),(210,120),(x,y)]
s="right"
d=right
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -24,30 +25,30 @@ while True:
if event.type==locals.KEYDOWN:
if event.key==locals.K_RIGHT and s!='left':
s="right"
d=right
if event.key==locals.K_LEFT and s!='right':
s="left"
d=left
if event.key==locals.K_UP and s!='down':
s="up"
d=up
if event.key==locals.K_DOWN and s!='up':
s="down"
d=down
if s == "right":
x+=30
screen.blit(right,(x,y))
if s == "up":
y+=30
screen.blit(up,(x,y))
if s == "down":
y-=30
screen.blit(down,(x,y))
if s == "down":
y+=30
if s == "left":
x-=30
screen.blit(left,(x,y))
position.append((x,y))
position.pop(0)
# 将背景图画上去
screen.blit(background, (0, 0))
# 将贪吃蛇画上
screen.blit(right, (x,y))
screen.blit(d, (x,y))
# 将贪吃蛇的身体画上去
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