Spawnkollisionsprüfung in work

This commit is contained in:
2023-12-30 15:25:55 +01:00
parent 06de20158f
commit 3e2b906279

View File

@@ -133,19 +133,38 @@ class GameObject():
self.__hide = True
"""TODO: Delete obeject function"""
def start_game():
menu.disable()
return 0
def apply_name():
menu.disable()
#TODO: Add function for save name
pass
menu = pygame_menu.Menu("Snake v1.0", 400, 300,)
menu.add.text_input("Name: ", onreturn=apply_name)
menu.add.button('Play', start_game)
menu.add.button('Quit', pygame_menu.events.EXIT)
menu.mainloop(MAINSCREEN)
def spawn_entities(x:int):
Objects = list()
count = 0
for y in range(x):
Objects.append(GameObject("Entitiy-"+str(count), rand.randint(1,MAINSCREEN_SIZE[0]), rand.randint(1,MAINSCREEN_SIZE[1]), rand.randint(1,15)))
Entity = GameObject("Entitiy-"+str(count), rand.randint(1,MAINSCREEN_SIZE[0]), rand.randint(1,MAINSCREEN_SIZE[1]), rand.randint(1,15))
Objects.append(Entity)
for y in Objects:
y:GameObject
#if(pygame.rect.Rect.colliderect(y)):
# print("Kollision, neuberechnung")
count += 1
for x in Objects:
print(x)
return list(Objects)
Player = GameObject("Player", 10, 10, is_player=False)
Player = GameObject("Player", 10, 10, 10, is_player=False)
background = pygame.surface.Surface((640,480))
@@ -158,7 +177,7 @@ class Game():
x = 3600
invert = False
spawned_entities = spawn_entities(25) #Spawnt eine definierte Anzahl an GameObjekten
spawned_entities = spawn_entities(2) #Spawnt eine definierte Anzahl an GameObjekten
count_spawend_enities = len(spawned_entities)
#Fenster-Hauptschleife
while active == True:
@@ -183,7 +202,7 @@ while active == True:
Player.change_direction("left")
Player.draw()
Player.move(12)
Player.move(5)
count_hidden_entities = 0
for y in spawned_entities:
y:GameObject