Commit b1adcb5c by BellCodeEditor

save project

parent 538dcffc
Showing with 12 additions and 10 deletions
......@@ -6,7 +6,7 @@ pygame.init()
# 创建一个窗口
screen = pygame.display.set_mode((660, 480))
p=pygame.time.Clock()
# 背景
background = pygame.image.load('bg.png')
right = pygame.image.load('right.png')
......@@ -16,9 +16,9 @@ left= pygame.image.load('left.png')
up= pygame.image.load('up.png')
down= pygame.image.load('down.png')
right_a='right'
right_b='right'
right_b=right
x,y=240,120
abab=[(210,120),(180,120),(180,90),(x,y)]
abab=[(150,120),(180,120),(210,120),(x,y)]
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -40,13 +40,14 @@ while True:
if right_a=='right':
x+=30
if right_a=='left':
x+=30
x-=30
if right_a=='up':
x+=30
y-=30
if right_a=='down':
x+=30
abab.append((x,y))
abab.pop(0)
y+=30
x+=30
abab.append((x,y))
abab.pop(0)
# 将背景图画上去
screen.blit(background, (0, 0))
# 将贪吃蛇画上去
......@@ -60,4 +61,5 @@ while True:
# 将果实画上去
screen.blit(food, (360, 300))
# 刷新画面
pygame.display.update()
\ No newline at end of file
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