Commit 3498d26f by BellCodeEditor

save project

parent 8f9e56a8
Showing with 39 additions and 2 deletions
...@@ -12,13 +12,50 @@ background = pygame.image.load('bg.png') ...@@ -12,13 +12,50 @@ background = pygame.image.load('bg.png')
right = pygame.image.load('right.png') right = pygame.image.load('right.png')
food = pygame.image.load('apple.png') food = pygame.image.load('apple.png')
body = pygame.image.load('body.png') body = pygame.image.load('body.png')
left=pygame.image.load('left.pog')
down=pygame.image.load("down.png")
up=pygame.image.load("up.png")
dfg=pygame.time.Clock() dfg=pygame.time.Clock()
ghj=[(180,90),(180,120),(210,120),(x,y)] ghj=[(180,90),(180,120),(210,120),(x,y)]
asd="right"
qwe=right
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == locals.QUIT: if event.type == locals.QUIT:
# 接收到退出事件后退出程序 # 接收到退出事件后退出程序
exit() exit()
if event.type==locals.KEYDOWN:
if event.key==locals.K_DOWN and asd !="down":
asd="up"
qwe=up
if event.key==locals.K_RIGHT and asd !="right":
asd="left"
qwe=left
if event.key==locals.K_LEFT and asd !="left":
asd="right"
qwe=right
if event.key==locals.K_ and asd !="up":
asd="down"
qwe=down
if asd=="right":
x+=30
elif asd=="left":
x-=30
elif asd=="up":
y-=30
elif:
y+=30
x+=30# 将背景图画上去 x+=30# 将背景图画上去
ghj.append((x,y)) ghj.append((x,y))
ghj.pop(0) ghj.pop(0)
...@@ -37,4 +74,4 @@ while True: ...@@ -37,4 +74,4 @@ while True:
screen.blit(food, (360, 300)) screen.blit(food, (360, 300))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
dfg.tick(1) dfg.tick(1 )
\ No newline at end of file \ 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