diff --git a/PyGame/Calculator/calc.py b/PyGame/Calculator/calc.py index ddefdef..53d749e 100644 --- a/PyGame/Calculator/calc.py +++ b/PyGame/Calculator/calc.py @@ -34,6 +34,8 @@ class Button: is_number: bool = False flashing: bool = False unflash_on: float = 0.0 + center_x: int = 0 + center_y: int = 0 keypad_map = { str(pygame.K_KP_0): pygame.K_0, @@ -125,13 +127,13 @@ def flash_button(b): def draw_buttons(): for key, b in buttons.items(): - center_x = button_origin_x + (b.column * button_spacing) - center_y = button_origin_y + (b.row * button_spacing) - center = (center_x, center_y) + b.center_x = button_origin_x + (b.column * button_spacing) + b.center_y = button_origin_y + (b.row * button_spacing) + center = (b.center_x, b.center_y) pygame.draw.circle(screen, yellow, center, 50, 2) b_text = cheesy_font.render(b.label, True, white) - text_x = center_x - (b_text.get_width() // 2) - text_y = center_y - (b_text.get_height() // 2) + text_x = b.center_x - (b_text.get_width() // 2) + text_y = b.center_y - (b_text.get_height() // 2) if b.label == "*": text_y += 15 screen.blit(b_text, (text_x, text_y))