-Added way to clear console -Support different dimmension of grid for console
This commit is contained in:
parent
e0397b95a7
commit
a696da09de
18
Ui.py
18
Ui.py
@ -7,7 +7,15 @@ class Ui:
|
||||
def __init__(self,screen):
|
||||
self.screen=screen
|
||||
self.font='freesansbold.ttf' #Feel free to change it :D
|
||||
self.font_size=int(16)
|
||||
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)
|
||||
@ -18,14 +26,16 @@ class Ui:
|
||||
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.center=(dCon.getGameWidth()+350/2,self.line)
|
||||
textRect.scale_by(x=350,y=100)
|
||||
self.screen.blit(text,textRect)
|
||||
line=line+18
|
||||
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(" ")
|
||||
|
@ -1,6 +1,6 @@
|
||||
CUBE_SIZE = 64
|
||||
NUM_X = 10
|
||||
NUM_Y = 5
|
||||
NUM_X = 6
|
||||
NUM_Y = 3
|
||||
|
||||
#returns true if tractor can move to specified slot
|
||||
def isValidMove(x, y):
|
||||
@ -14,6 +14,9 @@ def isValidMove(x, y):
|
||||
def getGameWidth():
|
||||
return NUM_X * CUBE_SIZE
|
||||
|
||||
def returnConsoleCoordinate():
|
||||
return NUM_X * CUBE_SIZE
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user