Commit 8a5fe3ff by BellCodeEditor

save project

parent 96914d1c
Showing with 10 additions and 2 deletions
import pygame
from pygame import locals
import random
score=0
# 初始化pygame,为使用硬件做准备
pygame.init()
my_font=""
# 创建一个窗口
screen = pygame.display.set_mode((660, 480))
FPSCLOCK = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
......@@ -58,8 +58,11 @@ while True:
sy=random.randint(1,15)
ax=sx*30-30
ay=sy*30-30
score+=30
else:
position.pop(0)
if x<0 or x>630 or y<0 or y>450:
exit()
position.append((x, y))
# 将背景图画上去
......@@ -72,6 +75,10 @@ while True:
# 将果实画上去
screen.blit(food, (ax,ay))
info='score'+str(score)
text=my_font.render(info,True,(0,0,0))
screen.blit(text,(540,10))
# 刷新画面
pygame.display.update()
FPSCLOCK.tick(3)
\ 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