Commit 223618c8 by BellCodeEditor

save project

parent edf0c706
Showing with 12 additions and 8 deletions
...@@ -17,11 +17,10 @@ body = pygame.image.load('body.png') # 身体 ...@@ -17,11 +17,10 @@ body = pygame.image.load('body.png') # 身体
left = pygame.image.load('left.png') # 头 朝左 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') # 头 朝下
adf=pygame.image. adf=pygame.font.Font('neuropol.ttf',18)
x, y = 240, 120 x, y = 240, 120
position = [(180, 90), (180, 120), (210, 120), (x, y)] position = [(180, 90), (180, 120), (210, 120), (x, y)]
sco=0
setheading = "right" setheading = "right"
snake_head = right snake_head = right
...@@ -54,7 +53,8 @@ while True: ...@@ -54,7 +53,8 @@ while True:
else: else:
y += 30 y += 30
position.append((x, y)) position.append((x, y))
if x==appw_x and y==appw_y: if x==appw_x and y==appw_y:
sco+=10
while True: while True:
appw_x=random.randint(0,630) appw_x=random.randint(0,630)
appw_y=random.randint(0,450) appw_y=random.randint(0,450)
...@@ -62,6 +62,9 @@ while True: ...@@ -62,6 +62,9 @@ while True:
break break
else: else:
position.pop(0) position.pop(0)
if x<0 or x>630 or y<0 or y>450:
exit()
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
# 将贪吃蛇的头画上去 # 将贪吃蛇的头画上去
...@@ -71,9 +74,10 @@ while True: ...@@ -71,9 +74,10 @@ while True:
screen.blit(body, position[i]) screen.blit(body, position[i])
# 将果实画上去 # 将果实画上去
fo='Screen'+str(sco)
su=adf.render(fo,True,(0,255,0))
screen.blit(su,(510,40))
screen.blit(food, (appw_x, appw_y)) screen.blit(food, (appw_x, appw_y))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPSCLOCK.tick(3) FPSCLOCK.tick(30)
\ 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