Skip to content

Commit

Permalink
Center text of a button and change screen color between pause and runnig
Browse files Browse the repository at this point in the history
  • Loading branch information
RickMMA committed Feb 6, 2024
1 parent 851a94b commit 117ab04
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions menu_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,14 @@ def render(self):

f = self.font.render(self.text, True, WHITE)
f_size = f.get_size()
print(f_size)
DISPLAYSURFACE.blit(f, (self.x + f_size[0]//2, self.y + f_size[1]//2))
# draw_text(self.text, self.font, WHITE, (self.x, self.y))
btn_width = self.button.get_width()
btn_height = self.button.get_height()

# Center text
# TODO: make conditional to choose pos of text
x = ((btn_width//2) - (f_size[0]//2)) + self.x
y = ((btn_height//2) - (f_size[1]//2)) + self.y
DISPLAYSURFACE.blit(f, (x, y))



Expand All @@ -121,11 +126,13 @@ def run():

btn1 = Button(DISPLAYSURFACE, pos = (SCREEN_WIDTH/2, SCREEN_HEIGHT/2), text = "Jugar")
while True:
DISPLAYSURFACE.fill((220, 220, 220))


if GAME_STATE == False:
DISPLAYSURFACE.fill((220, 220, 220))
draw_text("EL BIDEOJUEGO ESTÁ PAUSADO PUTO", FONT, BLACK, (160, 250))
else:
DISPLAYSURFACE.fill((20, 120, 20))
draw_text("HOLA IGÜEPUTAS!!", FONT, BLACK, (160, 250))

btn1.render()
Expand Down

0 comments on commit 117ab04

Please sign in to comment.