AI_PROJECT/Ui.py

42 lines
1.6 KiB
Python
Raw Normal View History

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
if(dCon.NUM_Y<7):
self.font_size=int(15)
self.line=20
self.first_line=20
if(dCon.NUM_Y>=7):
self.font_size=int(30)
self.line=30
self.first_line=30
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()
textRect.center=(dCon.getGameWidth() // 2,dCon.getScreenHeihgt() // 2)
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)
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,self.line)
textRect.scale_by(x=350,y=100)
self.screen.blit(text,textRect)
self.line=self.line+self.first_line
def clear_console(self):
self.line=self.first_line
pygame.draw.rect(self.screen,(0,0,0) , pygame.Rect(dCon.returnConsoleCoordinate(), 0, dCon.getConsoleWidth(), dCon.getScreenHeihgt()), 0)
def break_string_to_console(self,string_to_print):
self.to_print=string_to_print.split(" ")