Commit 511c42a1 by BellCodeEditor

save project

parent 59c76c3b
Showing with 20 additions and 1 deletions
...@@ -3,7 +3,7 @@ from pygame import locals ...@@ -3,7 +3,7 @@ from pygame import locals
# 初始化pygame,为使用硬件做准备 # 初始化pygame,为使用硬件做准备
pygame.init() pygame.init()
s="right"
# 创建一个窗口 # 创建一个窗口
screen = pygame.display.set_mode((660, 480)) screen = pygame.display.set_mode((660, 480))
x=240 x=240
...@@ -20,8 +20,27 @@ while True: ...@@ -20,8 +20,27 @@ while True:
if event.type == locals.QUIT: if event.type == locals.QUIT:
# 接收到退出事件后退出程序 # 接收到退出事件后退出程序
exit() exit()
if event.type==locals.KEYDOWN:
if event.key==locals.K_UP and s!="down":
s="up"
if event.key==locals.K_DOWN and s!="up":
s="down"
if event.key==locals.K_LEFT and s!="right":
s="left"
if event.key==locals.K_RIGHT and s!="left":
s="right"
x=x+30
if s=="right":
x=x+30 x=x+30
if s=="left":
x=x-30
if s=="up":
y=y-30
if s=="down":
y=y+30
zb.append((x,y)) zb.append((x,y))
zb.pop(0) zb.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