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