Added mass spawn of entities
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import pygame
|
||||
import pygame_menu
|
||||
import random as rnd
|
||||
|
||||
pygame.init()
|
||||
MAINSCREEN = pygame.display.set_mode((640,480))
|
||||
@@ -85,6 +86,8 @@ class GameObject():
|
||||
#print(GameObject.get_rect())
|
||||
if(self.get_rect().x == GameObject.get_rect().x and self.get_rect().y == GameObject.get_rect().y):
|
||||
"""TODO: Hitbox with Objectsize"""
|
||||
|
||||
if(pygame.rect.Rect.colliderect(self.__rectobjekt, GameObject.get_rect())):
|
||||
print("Kollision")
|
||||
pass
|
||||
|
||||
@@ -94,6 +97,16 @@ class GameObject():
|
||||
"""TODO: Delete obeject function"""
|
||||
|
||||
|
||||
def spawn_entities(x:int):
|
||||
Objects = list()
|
||||
for y in range(x):
|
||||
Objects.append(GameObject("TEST", rnd.randint(1,640), rnd.randint(1,480)))
|
||||
|
||||
for x in Objects:
|
||||
print(x)
|
||||
return tuple(Objects)
|
||||
|
||||
|
||||
object1 = GameObject("Testobject", 50, 50)
|
||||
object2 = GameObject("Testobject2", 100, 100)
|
||||
|
||||
@@ -101,6 +114,7 @@ background = pygame.surface.Surface((640,480))
|
||||
|
||||
x = 360
|
||||
invert = False
|
||||
spawned_enteties = spawn_entities(10)
|
||||
#Fenster-Hauptschleife
|
||||
while active == True:
|
||||
MAINSCREEN.fill((255,255,255))
|
||||
@@ -129,6 +143,10 @@ while active == True:
|
||||
#rect1.move(ballpos_x, ballpos_y)
|
||||
ballpos_x -= 10
|
||||
|
||||
for y in spawned_enteties:
|
||||
print(y)
|
||||
y.draw()
|
||||
y.move(rnd.randint(1,15))
|
||||
|
||||
object1.draw()
|
||||
object1.move(10)
|
||||
|
||||
Reference in New Issue
Block a user