Commit b1adcb5c by BellCodeEditor

save project

parent 538dcffc
Showing with 8 additions and 5 deletions
...@@ -6,7 +6,7 @@ pygame.init() ...@@ -6,7 +6,7 @@ pygame.init()
# 创建一个窗口 # 创建一个窗口
screen = pygame.display.set_mode((660, 480)) screen = pygame.display.set_mode((660, 480))
p=pygame.time.Clock()
# 背景 # 背景
background = pygame.image.load('bg.png') background = pygame.image.load('bg.png')
right = pygame.image.load('right.png') right = pygame.image.load('right.png')
...@@ -16,9 +16,9 @@ left= pygame.image.load('left.png') ...@@ -16,9 +16,9 @@ left= pygame.image.load('left.png')
up= pygame.image.load('up.png') up= pygame.image.load('up.png')
down= pygame.image.load('down.png') down= pygame.image.load('down.png')
right_a='right' right_a='right'
right_b='right' right_b=right
x,y=240,120 x,y=240,120
abab=[(210,120),(180,120),(180,90),(x,y)] abab=[(150,120),(180,120),(210,120),(x,y)]
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:
...@@ -40,10 +40,11 @@ while True: ...@@ -40,10 +40,11 @@ while True:
if right_a=='right': if right_a=='right':
x+=30 x+=30
if right_a=='left': if right_a=='left':
x+=30 x-=30
if right_a=='up': if right_a=='up':
x+=30 y-=30
if right_a=='down': if right_a=='down':
y+=30
x+=30 x+=30
abab.append((x,y)) abab.append((x,y))
abab.pop(0) abab.pop(0)
...@@ -61,3 +62,4 @@ while True: ...@@ -61,3 +62,4 @@ while True:
screen.blit(food, (360, 300)) screen.blit(food, (360, 300))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
p.tick(2)
\ 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