Commit eda2160e by BellCodeEditor

save project

parent ec2823e0
Showing with 7 additions and 1 deletions
...@@ -5,6 +5,8 @@ import random ...@@ -5,6 +5,8 @@ import random
pygame.init() pygame.init()
x,y=240,120 x,y=240,120
head="right" head="right"
apple_x=360
apple_y=300
# 创建一个窗口 # 创建一个窗口
s="right" s="right"
screen = pygame.display.set_mode((660, 480)) screen = pygame.display.set_mode((660, 480))
...@@ -45,6 +47,9 @@ while True: ...@@ -45,6 +47,9 @@ while True:
y-=30 y-=30
head="up" head="up"
p.append((x,y)) p.append((x,y))
if apple_x==x and apple_y==y:
apple_x=random.randint(0,660)
apple_y=random.randint(0,480)
p.pop(0) p.pop(0)
t.tick(3) t.tick(3)
# 将背景图画上去 # 将背景图画上去
...@@ -64,6 +69,6 @@ while True: ...@@ -64,6 +69,6 @@ while True:
screen.blit(body,p[i]) screen.blit(body,p[i])
# 将果实画上去 # 将果实画上去
screen.blit(food, (360, 300)) screen.blit(food, (apple_x, apple_y))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
\ 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