Commit fff053cf by BellCodeEditor

save project

parent 0e61655e
Showing with 24 additions and 3 deletions
......@@ -12,14 +12,35 @@ background = pygame.image.load('bg.png')
right = pygame.image.load('right.png')
food = pygame.image.load('apple.png')
body = pygame.image.load('body.png')
down = pygame.image.load('down.png')
left = pygame.image.load('left.png')
up = pygame.image.load('up.png')
x,y=240,120
postion=[(180,90),(180,120),(210,120),(x,y)]
sb="right"
dsb=right
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
# 接收到退出事件后退出程序
exit()
if event.type==locals.KEYDOWN:
if event.key==locals.K_RIGHT and sb!="left":
sb="right"
dsb=right
x+=30
if event.key==locals.K_LEFT and sb!="right":
sb="left"
dsb=left
x-=30
if event.key==locals.K_UP and sb!="down":
sb="up"
dsb=up
y-=30
if event.key==locals.K_DOWN and sb!="up":
sb="down"
dsb=down
y+=30
postion.append((x,y))
postion.pop(0)
screen.blit(background, (0, 0))
......@@ -34,4 +55,4 @@ while True:
x=x+30
# 刷新画面
pygame.display.update()
weee.tick(30)
\ No newline at end of file
weee.tick(3)
\ 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