Commit 9968e41f by BellCodeEditor

auto save

parent ea7c485c
Showing with 12 additions and 3 deletions
import pygame
from pygame import locals
import random
import pygame
from pygame import locals
import random
import sys
import time
# 初始化pygame,为使用硬件做准备
pygame.init()
......@@ -21,7 +26,7 @@ down = pygame.image.load('down.png') # 头 朝下
x, y = 240, 120
position = [(180, 90), (180, 120), (210, 120), (x, y)]
random
#random
setheading = "right"
snake_head = right
......@@ -47,7 +52,11 @@ while True:
if event.key == locals.K_DOWN and setheading != "up":
setheading = 'down'
snake_head = down
if (x>630 or x<0 or y>450 or y<0) or ((x,y) in position[:-1]):
screen.blit(over,(60,60))
pygame.display.flip()
time.sleep(10)
# 设置贪吃蛇的头部坐标
if setheading == "right":
x += 30
......@@ -68,7 +77,7 @@ while True:
apple_y = 30*nun2-30
else:
position.pop(0)
if x < 0 and x > 630 and y < 0 and y > 450
# 将背景图画上去
screen.blit(background, (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