Commit ae109f66 by BellCodeEditor

save project

parent 64cc0855
Showing with 6 additions and 27 deletions
import pygame
from pygame import locals
background=
x,y=240,120
# 初始化pygame,为使用硬件做准备
pygame.init()
......@@ -8,39 +8,18 @@ re=pygame.time.Clock();re.tick(3)# 创建一个窗口
screen = pygame.display.set_mode((660, 480))
se=[(180,90),(180, 120),(210, 120),(x,y)]
S='right'
ss=right
# 背景
# 背景
background = pygame.image.load('bg.png')
right = pygame.image.load('right.png')
food = pygame.image.load('apple.png')
body = pygame.image.load('body.png')
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
# 接收到退出事件后退出程序
exit()
if event.type==locals.KEPDOWN:
if event.key==locals.K_RIGHT and s !='left':
s='right'
ss=right
if event.key==locals.K_UP and s !='down':
s='up'
ss=up
if event.key==locals.K_DOWN and s !='up':
s='down'
ss=down
if event.key==locals.K_LEFT and s !='right':
s='left'
ss=left
if s=='right'
x+=30
else s=='up':
y-=30
else s=='down':
y+=30
else s=='left':
x-=30
x+=30
se.append((x,y))
se.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