2024-03-23 13:46:48 +01:00
|
|
|
import pygame
|
|
|
|
import displayControler as dCon
|
|
|
|
import Colors
|
|
|
|
|
|
|
|
|
|
|
|
class Ui:
|
|
|
|
def __init__(self,screen):
|
|
|
|
self.screen=screen
|
|
|
|
self.font='freesansbold.ttf' #Feel free to change it :D
|
2024-04-13 01:39:39 +02:00
|
|
|
self.font_size=int(16)
|
2024-03-23 13:46:48 +01:00
|
|
|
def render_text(self,string_to_print):
|
|
|
|
font=pygame.font.Font(self.font,self.font_size)
|
|
|
|
text=font.render(string_to_print,True,Colors.BLACK,Colors.WHITE)
|
|
|
|
textRect=text.get_rect()
|
2024-04-13 01:51:52 +02:00
|
|
|
textRect.center=(dCon.getGameWidth() // 2,dCon.getScreenHeihgt() // 2)
|
2024-04-13 01:39:39 +02:00
|
|
|
self.screen.blit(text,textRect)
|
|
|
|
|
|
|
|
def render_text_to_console(self,string_to_print):
|
|
|
|
font=pygame.font.Font(self.font,self.font_size)
|
|
|
|
self.break_string_to_console(string_to_print)
|
|
|
|
line=10
|
|
|
|
for string in self.to_print:
|
|
|
|
text=font.render(string,True,Colors.BLACK,Colors.WHITE)
|
|
|
|
textRect=text.get_rect()
|
|
|
|
textRect.center=(dCon.getGameWidth()+350/2,line)
|
|
|
|
textRect.scale_by(x=350,y=100)
|
|
|
|
self.screen.blit(text,textRect)
|
2024-04-13 01:51:52 +02:00
|
|
|
line=line+18
|
2024-04-13 01:39:39 +02:00
|
|
|
|
|
|
|
def break_string_to_console(self,string_to_print):
|
|
|
|
self.to_print=string_to_print.split(" ")
|