Commit d6ac58a7 by BellCodeEditor

save project

parent 513e4bf0
Showing with 17 additions and 4 deletions
...@@ -6,19 +6,32 @@ pygame.init() ...@@ -6,19 +6,32 @@ pygame.init()
# 创建一个窗口 # 创建一个窗口
backgound = pygame.image.load('bg.png') backgound = pygame.image.load('bg.png')
right = pygame.image.load('right.png') right = pygame.image.load('right.png')
food = pygame.image.load('food.png') left = pygame.image.load('left.png')
body = pygame.image.load('boay.png') up = pygame.image.load('up.png')
down = pygame.image.load('down.png')
body = pygame.image.load('body.png')
food = pygame.image.load('food.png')
x,y = 240,120 x,y = 240,120
position = [(180,90),(180,120),(),(x,y)] position = [(180,90),(180,120),(210120),(x,y)]
pygame.display.set_mode((660,480)) pygame.display.set_mode((660,480))
while True: while True:
for event in pygame.event.get() for event in pygame.event.get()
print(event) print(event)
if event.type == locals.QUIT: if event.type == locals.QUIT:
exit() exit()
if event.key == locals.K_RIGHT and setheading!='left':
setheading = 'right'
snake.head = 'right'
if setheading == 'right':
x+=30
elif setheading == 'left':
x-=30
elif setheading == 'up':
y-=30
else:
y+=30
x-=30
position.append(x,y) position.append(x,y)
position.pop(0) position.pop(0)
screen.blit(backgound,(0,0)) screen.blit(backgound,(0,0))
......
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