Commit 1c9eaa36 by BellCodeEditor

save project

parent af7b93d5
Showing with 14 additions and 1 deletions
...@@ -13,11 +13,24 @@ FPS = pygame.time.Clock() ...@@ -13,11 +13,24 @@ FPS = pygame.time.Clock()
x , y = 240 , 120 x , y = 240 , 120
snakeList = [(180,90) , (180,120) , (210,120) , (x,y)] snakeList = [(180,90) , (180,120) , (210,120) , (x,y)]
setheading = "right" setheading = "right"
set_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()
x += 30 if event.type == locals.KEYDOWN:
if event.key == locals.K_RIGHT and setheading != 'left':
setheading = "right"
set_head = right
if event.key == locals.K_LEFT and setheading != 'right':
setheading = "left"
set_head = left
if event.key == locals.K_UP and setheading != 'down':
setheading = "up"
set_head = up
if event.key == locals.K_DOWN and setheading != 'up':
setheading = "down"
set_head = down
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
snakeList.pop(0) snakeList.pop(0)
snakeList.append((x,y)) snakeList.append((x,y))
......
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