Commit f711a782 by BellCodeEditor

save project

parent 9a9e421e
Showing with 21 additions and 2 deletions
import pygame
import random as r
from pygame import locals
pygame.init() # 初始化
......@@ -7,6 +8,20 @@ grid_size = 20 # 格子大小
grid_num_width = 15 # 横向格子数量
grid_num_height = 25 # 纵向格子数量
FPS = 30
sqare=[]
mo=[[(120,20),(120,40)(140,40),(140,60)],[(120,20),(140,20),(160,20),(180,20)],[(120,20),(120,40),(140,20),(140,40)]]
grass=(21,219,58)
white=(255,255,255)
red=(255,0,0)
blue=(0,0,255)
green=(0,255,0)
orchid=(218,112,214)
crimson=(220,20,60)
fuchsia=(255,0,255)
slate=(112,128,144)
aqua=(0,255,255)
color=[grass,red,blue,green,orchid,crimson,fuchsia,slate,aqua]
for i in r.choice(mo):
# 创建窗口
screen = pygame.display.set_mode((460, 500))
......@@ -15,7 +30,8 @@ clock = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
# 载入素材
background = pygame.image.load('bg.png')
font = pygame.font.Font('STKAITI.TTF', 60) # 字体
grass=(21,219,58)
white=(255,255,255)
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -27,6 +43,9 @@ while True:
score_text=font.render(str(score),True,(0,255,200))
screen.blit(score_text,(350,70))
# 刷新画面
sqare.append([120,20,grass])
for i in sqare:
pygame.draw.rect(screen,i[2],(i[0],i[1],20,20),0)
pygame.draw.rect(screen,white,(i[0],i[1],20,20),1)
pygame.display.update()
clock.tick(FPS)
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