Hey! I’ve been fiddling with the font drawing stuff and I had a small moment when I had to think how I wish to put various properties with different text elements on my screen, code is below (bolded part is which I want a clarification to). Since it read the whole function anyway line by line is it “alright” to recolor the next line texts as I have now put them (it seems to work)?
Edit: nevermind the bold didn’t work on
so I just marked the lines :P
def fontInit():
font_path = logic.expandPath('//assets/fonts/arialbd.ttf')
logic.font_id = blf.load(font_path)
scene = logic.getCurrentScene()
scene.post_draw = [writeStats]
def writeStats():
width = render.getWindowWidth()
height = render.getWindowHeight()
bgl.glMatrixMode(bgl.GL_PROJECTION)
bgl.glLoadIdentity()
bgl.gluOrtho2D(0, width, 0, height)
bgl.glMatrixMode(bgl.GL_MODELVIEW)
bgl.glLoadIdentity()
-this -> bgl.glColor4f(1.0, 0.0, 0.0, 1)
font_id = logic.font_id
blf.size(font_id, 40, 72)
blf.position(font_id, (width * 0.05), (height * 0.45), 0)
writeScore = str(own["score"])
blf.draw(font_id, writeScore)
blf.position(font_id, (width * 0.05), (height * 0.24), 0)
writeMultiplier = str(own["multiplier"])
blf.draw(font_id, writeMultiplier)
-this -> bgl.glColor4f(0.0, 0.0, 1.0, 1)
blf.size(font_id, 40, 72)
blf.position(font_id, (width * 0.05), (height * 0.90), 0)
titleScore = str(own["scoreTitle"])
blf.draw(font_id, titleScore)
blf.position(font_id, (width * 0.05), (height * 0.54), 0)
titleMultiplier = str(own["multiTitle"])
blf.draw(font_id, titleMultiplier)
