Commit 65afc8c4 by BellCodeEditor

save project

parent c024a6db
Showing with 40 additions and 13 deletions
......@@ -7,6 +7,9 @@ grid_size = 20 # 格子大小
grid_num_width = 15 # 横向格子数量
grid_num_height = 25 # 纵向格子数量
FPS = 30
r=[8,2]
n=[(-1,0),(0,0),(0,-1),(1,0)]
# 创建窗口
screen = pygame.display.set_mode((460, 500))
......@@ -15,27 +18,51 @@ clock = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
# 载入素材
background = pygame.image.load('bg.png')
font = pygame.font.Font('STKAITI.TTF', 60) # 字体
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
exit()
if event.type == locals.KEYDOWN:
if event.key == locals.K_UP:
if r[1]>0:
r[1]-=1
if event.key == locals.K_DOWN:
if r[1]+1<25:
r[1]+=1
if event.key == locals.K_LEFT:
if r[0]>0:
r[0]-=1
if event.key == locals.K_RIGHT:
if r[0]+1<15:
r[0]+=1
if event.key == locals.K_s:
n=[(-1,0),(0,0),(0,-1),(-1,-1)]
if event.key == locals.K_d:
n=[(-1,0),(0,0),(1,0),(2,0)]
if event.key == locals.K_a:
n=[(-1,0),(0,0),(0,-1),(1,0)]
if event.key == locals.K_f:
n=[(0,2),(0,0),(0,1),(1,2)]
if event.key == locals.K_g:
n=[(0,2),(0,0),(0,1),(-1,2)]
if event.key == locals.K_h:
n=[(-1,0),(0,0),(0,1),(1,1)]
if event.key == locals.K_j:
n=[(1,0),(0,0),(0,1),(-1,1)]
# 将背景图画上去
screen.blit(background,(0,0))
pygame.draw.rect(screen,(255,0,0),(140,20,20,20),0)
pygame.draw.rect(screen,(200,30,30),(140,20,20,20),1)
c=[]
for cube in n:
pos=(cube[0]+r[0],cube[1]+r[1])
c.append(pos)
for cube in c:
pygame.draw.rect(screen,(255,0,0),(20*cube[0],20*cube[1],20,20),0)
pygame.draw.rect(screen,(200,30,30),(20*cube[0],20*cube[1],20,20),1)
# 得分
sss=font.render(str(score),True,(0,0,0))
......
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