Commit 08566a88 by BellCodeEditor

save project

parent 1d161ee1
Showing with 29 additions and 4 deletions
...@@ -7,11 +7,13 @@ grid_size = 20 # 格子大小 ...@@ -7,11 +7,13 @@ grid_size = 20 # 格子大小
grid_num_width = 15 # 横向格子数量 grid_num_width = 15 # 横向格子数量
grid_num_height = 25 # 纵向格子数量 grid_num_height = 25 # 纵向格子数量
FPS = 30 FPS = 30
zuo_biao=[2,7]
T=[(0,-1),(0,0),(0,1),(-1,0)]#(0,-1),(0,0),(0,1),(-1,0)
# 创建窗口 # 创建窗口
screen = pygame.display.set_mode((460, 500)) screen = pygame.display.set_mode((460, 500))
pygame.display.set_caption("俄罗斯方块") pygame.display.set_caption("RCRAFT")
clock = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数) clock = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)(qwq) key==k
# 载入素材 # 载入素材
background = pygame.image.load('bg.png') background = pygame.image.load('bg.png')
font = pygame.font.Font('STKAITI.TTF', 60) # 字体 font = pygame.font.Font('STKAITI.TTF', 60) # 字体
...@@ -20,11 +22,34 @@ while True: ...@@ -20,11 +22,34 @@ while True:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == locals.QUIT: if event.type == locals.QUIT:
exit() exit()
if event.type==locals.KEYDOWN:
if event.key==locals.K_RIGHT:
if zuo_biao[1]<15:
zuo_biao[1]+=1
if event.key==locals.K_LEFT:
if zuo_biao[1]>1:
zuo_biao[1]-=1
if event.key==locals.K_DOWN:
if zuo_biao[0]<25:
zuo_biao[0]+=1
if event.key==locals.K_UP:
if zuo_biao[0]>1:
zuo_biao[0]-=1
# 将背景图画上去 # 将背景图画上去
??? screen.blit(background,(0,0))
shi_ji_T=[]
for i in T:
ju_ti=(i[0]+zuo_biao[0],i[1]+zuo_biao[1])
shi_ji_T.append(ju_ti)
for ii in shi_ji_T:
pygame.draw.rect(screen,(250,0,0),(ii[1]*20-20,ii[0]*20-20,20,20),0)
pygame.draw.rect(screen,(250,250,250),(ii[1]*20-20,ii[0]*20-20,20,20),1)
# 得分 # 得分
??? zhi_hou=font.render(str(score),False,(54,188,250))
screen.blit(zhi_hou,(350,70))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
clock.tick(FPS) 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