SOme changes on Labelclass

This commit is contained in:
2024-02-13 19:59:14 +01:00
parent 187803d3f7
commit 2e9bbc7d19
2 changed files with 13 additions and 10 deletions

View File

@@ -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!")

View File

@@ -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))