Commit bbc26642 by BellCodeEditor

save project

parent 916ac598
Showing with 4 additions and 3 deletions
......@@ -39,6 +39,7 @@ while True:
snake_head=right
if event.key==locals.K_LEFT and setheading!='right':
setheading='left'
snake_head=left
if event.key==locals.K_UP and setheading!='down':
setheading='up'
......@@ -58,8 +59,8 @@ while True:
position.append((x,y))
if x==apple_x and y==apple_y:
num1=random.randint(0,22)
num2=random.randint(0,16)
num1=random.randint(1,22)
num2=random.randint(1,16)
apple_x=num1*30-30
apple_y=num2*30-30
score+=10
......@@ -67,7 +68,7 @@ while True:
position.pop(0)
screen.blit(background, (0, 0)) #将背景图画上去
screen.blit(right,position[-1]) #将贪吃蛇画上去
screen.blit(snake_head,position[-1]) #将贪吃蛇画上去
for i in range(len(position)-1):
screen.blit(body,position[i]) #将贪吃蛇画上去
screen.blit(food, (apple_x, apple_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