Commit 705d03f5 by BellCodeEditor

save project

parent b91b9318
Showing with 19 additions and 1 deletions
...@@ -19,12 +19,30 @@ down=pygame.image.load('down.png') ...@@ -19,12 +19,30 @@ down=pygame.image.load('down.png')
x,y=240,120 x,y=240,120
tgb=[(180,90),(180,120),(210,120),(x,y)] tgb=[(180,90),(180,120),(210,120),(x,y)]
setheading = "right"
snake_head = "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:
# 接收到退出事件后退出程序 # 接收到退出事件后退出程序
exit() exit()
elif event.type == locals.KEYDOWN:
if event.key == locals.K_RIGHT setheading !='left':
setheading = 'right'
snake_head = right
if event.key == locals.K_RIGHT setheading !='right':
setheading = 'left'
snake_head = left
if event.key == locals.K_RIGHT setheading !='down':
setheading = 'up'
snake_head = up
if event.key == locals.K_RIGHT setheading !='up':
setheading = 'down'
snake_head = down
x+=30 x+=30
tgb.append((x,y)) tgb.append((x,y))
tgb.pop(0) tgb.pop(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