Commit e8bb276d by BellCodeEditor

save project

parent 835fbf24
Showing with 4 additions and 0 deletions
......@@ -4,6 +4,7 @@ import random
# 初始化pygame,为使用硬件做准备
pygame.init()
# 创建一个窗口
screen = pygame.display.set_mode((660, 480))
FPSCLOCK = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
......@@ -26,6 +27,7 @@ setheading = "right"
snake_head = right
score=0
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
# 接收到退出事件后退出程序
......@@ -73,6 +75,8 @@ while True:
apple_y=num2*30-30
else:
position.pop(0)
if x < 0 or x > 630 or y < 0 or y > 450:
exit()
info="Score"+str(score)
text=my_font.render(info,True,(0,0,0))
screen.blit(text,(540,10))
......
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