Commit 6a85b7ee by BellCodeEditor

save project

parent 266d3640
Showing with 59 additions and 4 deletions
...@@ -16,7 +16,7 @@ clock = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数) ...@@ -16,7 +16,7 @@ clock = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
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) # 字体
weizhi = [2,8]#方块位置,2、weizhi[0]为行,8、weizhi[1]为列 weizhi = [2,8]#方块位置,2、weizhi[0]为行,8、weizhi[1]为列
curr_shape = [(-1,0),(0,0),(1,0),(1,1)]#括号(a,b)为元组,有序且不可调换顺序 curr_shape = [(-1,0),(0,0),(1,0),(1,1)]#括号(a,b)为元组,有序且不可调换顺序,在这里看作坐标
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == locals.QUIT: if event.type == locals.QUIT:
...@@ -39,14 +39,14 @@ while True: ...@@ -39,14 +39,14 @@ while True:
screen.blit(background,(0,0)) screen.blit(background,(0,0))
curr_pos = [] curr_pos = []
for cube in curr_shape: for cube in curr_shape:
pos = (cube[0]+weizhi[0],cube[1]+weizhi[1]) pos = (cube[0]+weizhi[0],cube[1]+weizhi[1]) #计算坐标位置
curr_pos.append(pos) curr_pos.append(pos)
#画方块 #画方块
for pos in curr_pos: for pos in curr_pos:
pygame.draw.rect(screen,(255,0,0),(pos[1]*20-20,pos[0]*20-20,20,20),0) pygame.draw.rect(screen,(255,0,0),(pos[1]*20-20,pos[0]*20-20,20,20),0)
#在屏幕中weizhi[1]*20-20(x坐标),weizhi[0]*20-20(y坐标)的位置画出红色且内部填充(width=0)的20宽20高的正方形 #在屏幕中pos[1]*20-20(x坐标),pos[0]*20-20(y坐标)的位置画出红色且内部填充(width=0)的20宽20高的正方形
pygame.draw.rect(screen,(255,255,255),(pos[1]*20-20,pos[0]*20-20,20,20),1) pygame.draw.rect(screen,(255,255,255),(pos[1]*20-20,pos[0]*20-20,20,20),1)
#在屏幕中weizhi[1]*20-20(x坐标),weizhi[0]*20-20(y坐标)的位置画出20宽20高的白色边框(width=1),为正方形的边框 #在屏幕中pos[1]*20-20(x坐标),pos[0]*20-20(y坐标)的位置画出20宽20高的白色边框(width=1),为正方形的边框
# 得分 # 得分
score_text = font.render(str(score),True,(0,0,0)) score_text = font.render(str(score),True,(0,0,0))
...@@ -54,3 +54,58 @@ while True: ...@@ -54,3 +54,58 @@ while True:
# 刷新画面 # 刷新画面
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