From 2e9bbc7d19bcc010af8f701b505cdb5c327727b1 Mon Sep 17 00:00:00 2001 From: administrator Date: Tue, 13 Feb 2024 19:59:14 +0100 Subject: [PATCH] SOme changes on Labelclass --- modules/Labels.py | 13 +++++++------ pygame-test.py | 10 ++++++---- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/modules/Labels.py b/modules/Labels.py index 814c863..6d6349d 100644 --- a/modules/Labels.py +++ b/modules/Labels.py @@ -1,18 +1,19 @@ import pygame class Label: - def __init__(self, surface:pygame.Surface, is_rect=False, pos=tuple) -> None: - self._surface = surface + def __init__(self, is_rect=False, pos=tuple, size=tuple, mainsurface=pygame.Surface) -> None: + self._surface = pygame.Surface(size) + self._mainsurface = mainsurface self._is_rect = is_rect self._pos = pos - + self._size = size - def input_label(self): - pass + def get_surface(self): + return self._surface def draw(self): if(self._is_rect): - print("Zeichne ein Rechteck") + rect = pygame.draw.rect(self._mainsurface, (0,0,0), (self._pos[0],self._pos[1], self._size[0], self._size[1]), 1) else: print("Zeichne Surface!") diff --git a/pygame-test.py b/pygame-test.py index 51cef3d..92e84ee 100644 --- a/pygame-test.py +++ b/pygame-test.py @@ -72,6 +72,7 @@ def percent_from_screen(base:int, percent:int) -> int: game = Game.Game() User = User.User() +input_label = Label.Label(True, (50,50), (100,25), PLAYGROUND) @@ -106,10 +107,11 @@ spawn_fruit = True game_started = False text = "" -game.change_state("started") +game.change_state("menu") while active == True: MAINSCREEN.fill((55,148,38)) + PLAYGROUND.fill((244,244,244)) for event in pygame.event.get(): if (event.type == pygame.QUIT): print("Programm wird geschlossen!") @@ -135,6 +137,7 @@ while active == True: player.change_direction("left") if(game.get_state("menu")): + pass if(event.type == pygame.KEYDOWN): print(event.unicode) text += event.unicode @@ -145,11 +148,10 @@ while active == True: text_out = my_font.render(text, True, SCHWARZ, None) - - + input_label.draw() pygame.draw.line(MAINSCREEN, SCHWARZ, (0,38), (MAINSCREEN_SIZE[0], 38), 2) - PLAYGROUND.fill((244,244,244)) + PLAYGROUND.blit(text_out, (MAINSCREEN_SIZE[0]/2, MAINSCREEN_SIZE[1]/2)) #pygame.draw.rect(surface_menu, (0,0,0), (0,0,400,500), 1, 7) #PLAYGROUND.blit(surface_menu, (20,20))