SOme changes on Labelclass
This commit is contained in:
@@ -1,18 +1,19 @@
|
|||||||
import pygame
|
import pygame
|
||||||
|
|
||||||
class Label:
|
class Label:
|
||||||
def __init__(self, surface:pygame.Surface, is_rect=False, pos=tuple) -> None:
|
def __init__(self, is_rect=False, pos=tuple, size=tuple, mainsurface=pygame.Surface) -> None:
|
||||||
self._surface = surface
|
self._surface = pygame.Surface(size)
|
||||||
|
self._mainsurface = mainsurface
|
||||||
self._is_rect = is_rect
|
self._is_rect = is_rect
|
||||||
self._pos = pos
|
self._pos = pos
|
||||||
|
self._size = size
|
||||||
|
|
||||||
def input_label(self):
|
def get_surface(self):
|
||||||
pass
|
return self._surface
|
||||||
|
|
||||||
def draw(self):
|
def draw(self):
|
||||||
if(self._is_rect):
|
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:
|
else:
|
||||||
print("Zeichne Surface!")
|
print("Zeichne Surface!")
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ def percent_from_screen(base:int, percent:int) -> int:
|
|||||||
|
|
||||||
game = Game.Game()
|
game = Game.Game()
|
||||||
User = User.User()
|
User = User.User()
|
||||||
|
input_label = Label.Label(True, (50,50), (100,25), PLAYGROUND)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -106,10 +107,11 @@ spawn_fruit = True
|
|||||||
game_started = False
|
game_started = False
|
||||||
text = ""
|
text = ""
|
||||||
|
|
||||||
game.change_state("started")
|
game.change_state("menu")
|
||||||
|
|
||||||
while active == True:
|
while active == True:
|
||||||
MAINSCREEN.fill((55,148,38))
|
MAINSCREEN.fill((55,148,38))
|
||||||
|
PLAYGROUND.fill((244,244,244))
|
||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
if (event.type == pygame.QUIT):
|
if (event.type == pygame.QUIT):
|
||||||
print("Programm wird geschlossen!")
|
print("Programm wird geschlossen!")
|
||||||
@@ -135,6 +137,7 @@ while active == True:
|
|||||||
player.change_direction("left")
|
player.change_direction("left")
|
||||||
|
|
||||||
if(game.get_state("menu")):
|
if(game.get_state("menu")):
|
||||||
|
pass
|
||||||
if(event.type == pygame.KEYDOWN):
|
if(event.type == pygame.KEYDOWN):
|
||||||
print(event.unicode)
|
print(event.unicode)
|
||||||
text += event.unicode
|
text += event.unicode
|
||||||
@@ -145,11 +148,10 @@ while active == True:
|
|||||||
|
|
||||||
text_out = my_font.render(text, True, SCHWARZ, None)
|
text_out = my_font.render(text, True, SCHWARZ, None)
|
||||||
|
|
||||||
|
input_label.draw()
|
||||||
|
|
||||||
pygame.draw.line(MAINSCREEN, SCHWARZ, (0,38), (MAINSCREEN_SIZE[0], 38), 2)
|
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))
|
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)
|
#pygame.draw.rect(surface_menu, (0,0,0), (0,0,400,500), 1, 7)
|
||||||
#PLAYGROUND.blit(surface_menu, (20,20))
|
#PLAYGROUND.blit(surface_menu, (20,20))
|
||||||
|
|||||||
Reference in New Issue
Block a user