def init_boxs_pixel_x_y_relative_BOARD():
boxs = []
for i in range(NUMBOXHORIZONTAL):
vert_boxs = []
x = BOXMARGINWIDTH
x += i * (BOXWIDTH + GAPBETBOXS)
for j in range(NUMBOXVERTIVAL):
y = BOXMARGINHEIGHT
y += j * (BOXHEIGHT + GAPBETBOXS)
box = Box(x,y,BOXWIDTH,BOXHEIGHT)
box.boxx = i
box.boxy = j
box.num = i + NUMBOXVERTIVAL*j
vert_boxs.append(box)
boxs.append(vert_boxs)
boxs[NUMBOXHORIZONTAL-1][NUMBOXVERTIVAL-1].is_blank = True
return boxs
def init_font(font_path,font_size,words,words_color,bg_color,):
font_obj = pygame.font.Font(font_path,font_size)
text_surf = font_obj.render(words,True,words_color,bg_color)
return text_surf
def draw_font(text_surf,container,left,top):
text_rect = text_surf.get_rect()
text_rect.left = left
text_rect.top = top
container.blit(text_surf,text_rect)
def draw_bar(BAR,lives):
BAR = pygame.Surface((BARWIDTH,BARHEIGHT))
BAR.fill(BLACK)
text_surf = init_font(FONTPATH,16,"LIVES:",GREEN,BLUE)
draw_font(text_surf,BAR,20,0)
text_surf = init_font(FONTPATH,16,str(lives),GREEN,BLUE)
draw_font(text_surf,BAR,80,0)
DISPLAYSURF.blit(BAR,(BARLEFT,BARTOP))
def draw_boxs(BOARD,boxs):
global DISPLAYSURF,BLANK
for i in range(NUMBOXHORIZONTAL):
for j in range(NUMBOXVERTIVAL):
if boxs[i][j].is_blank==False:
draw_a_box(boxs,i,j)
def draw_a_box(boxs,boxx,boxy,adjx=0,adjy=0):
DISPLAYSURF.blit(boxs[boxx][boxy ].surf,(XRBW(boxs[boxx][boxy].x)+adjx,YRBW(boxs[boxx][boxy].y)+adjy))
textSurf = BASICFONT.render(str(boxs[boxx][boxy].num), True, TEXTCOLOR)
textRect = textSurf.get_rect()
textRect.center = XRBW(boxs[boxx][boxy].x) + int(BOXWIDTH / 2) + adjx, YRBW(boxs[boxx][boxy].y) + int(BOXHEIGHT / 2) + adjy
DISPLAYSURF.blit(textSurf, textRect)