Commit 732ad609 by BellCodeEditor

save project

parent 657e71aa
Showing with 32 additions and 4 deletions
......@@ -3,22 +3,50 @@ from pygame import locals
# 初始化pygame,为使用硬件做准备
pygame.init()
x,y=240,120
x,y=240,150
# 创建一个窗口
screen = pygame.display.set_mode((660, 480))
b=[(270,150),(270,120),(x,y)]
b=[(300,150),(270,150),(x,y)]
# 背景
background = pygame.image.load('bg.png')
right = pygame.image.load('right.png')
ri = pygame.image.load('right.png')
le = pygame.image.load('left.png')
up = pygame.image.load('up.png')
do = pygame.image.load('down.png')
food = pygame.image.load('apple.png')
c="right"
d=right
a=pygame.time.Clock()
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
# 接收到退出事件后退出程序
exit()
# 将背景图画上去\
if event.type==locals.KEYDOWN:
if event.key==locals.K_w and c!="down":
c="up"
d=up
if event.type==locals.KEYDOWN:
if event.key==locals.K_s and c!="up":
c="down"
d=do
if event.type==locals.KEYDOWN:
if event.key==locals.K_w and c!="left":
c="right"
d=ri
if event.type==locals.KEYDOWN:
if event.key==locals.K_w and c!="right":
c="left"
d=le
if c=="left":
x+=30
if c=="right":
x-=30
if c=="up":
y-=30
else
y+=30
# 将背景图画上去\
b.append((x,y))
b.pop(0)
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