Commit da71385b by BellCodeEditor

save project

parent 60065b65
Showing with 4 additions and 30 deletions
......@@ -3,8 +3,7 @@ from pygame import locals
x,y=240,120
way='right'
snake_head=right
# 初始化pygame,为使用硬件做准备
pygame.init()
......@@ -15,11 +14,8 @@ screen = pygame.display.set_mode((660, 480))
# 背景
background = pygame.image.load('bg.png')
right = pygame.image.load('right.png')
food = pygame.image.oad('apple.png')
food = pygame.image.load('apple.png')
body = pygame.image.load('body.png')
up= pygame.image.load('up.png')
down= pygame.image.load('down.png')
left= pygame.image.load('left.png')
while True:
ccc=pygame.time.Clock()
......@@ -28,26 +24,6 @@ while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
# 接收到退出事件后退出程序
if event.type==locals.KEY_DOWN:
if locals.KEY_DOWN and way !=up
if locals.KEY_UP and way !=down
if locals.KEY_LEFT and way !=right
if locals.KEY_RIGHT and way !=left
if way='right':
x+=30
elif way='left':
x-=30
elif way='down':
y+=30
else:
way='up':
y-=30
exit()
# 将背景图画上去
screen.blit(background, (0, 0))
......@@ -59,10 +35,7 @@ else:
screen.blit(body, (180, 90))
# 将果实画上去
screen.blit(food, (360, 300))
x+=30
# 刷新画面
pygame.display.update()
\ No newline at end of file
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