diff --git a/CHANGELOG.md b/CHANGELOG.md index fa91008..e3b2532 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,10 @@ # ChangeLog +# v0.7.0 2022-06-22 +- Agrega método LittleGameEngine.contains() para obtener todos los GameObjects que contienen a un punto dado + # 2022-06-22 -- Crea clase ImagesManager para el manejo de imagen +- Crea clase ImageManager para el manejo de imagen - Crea clase SoundManager para el manejo de sonidos - Crea clase Fontmanager para el manejo de fonts - Manejo de imágenes, sonido y fonts se llevan a las clases señaladas diff --git a/setup.py b/setup.py index f664821..f7f65b0 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ "name": "lge", "package_dir": {"": "src/rcr"}, "packages": ["lge"], - "version": "0.6.0", + "version": "0.7.0", } setup(**SETUP) diff --git a/src/rcr/lge/LittleGameEngine.py b/src/rcr/lge/LittleGameEngine.py index eddd998..514afd3 100644 --- a/src/rcr/lge/LittleGameEngine.py +++ b/src/rcr/lge/LittleGameEngine.py @@ -349,6 +349,22 @@ def collidesWith(self, gobj) -> list: return [] + def contains(self, layer:int, position:tuple): + """ + Obtiene todos los GameObjects de una capa dada que contienen un punto especificado + + **Parametros** + : *layer* : la capa a revisar + : *position: : el punto a revisar + + **Retorna** + : *list* : los GameObjects que contienen al punto + """ + x, y = position + return [o + for o in self.gLayers[layer] + if o.rect.contains(x, y)] + # ------ camera ------ def getCameraPosition(self) -> tuple: """ diff --git a/src/test/Benchmarks/Birds.py b/src/test/Benchmarks/Birds.py index fd24151..369b9af 100644 --- a/src/test/Benchmarks/Birds.py +++ b/src/test/Benchmarks/Birds.py @@ -42,8 +42,8 @@ def __init__(self): # agregamos pajaros ww, wh = self.lge.getCameraSize() for i in range(500): - x = random.random() * ww - y = 15 + random.random() * wh + x = random.randint(0, ww) + y = random.randint(15, wh) bird = Bird("bird", (x, y)) self.lge.addGObject(bird, 1) diff --git a/src/test/Benchmarks/Bouncing.py b/src/test/Benchmarks/Bouncing.py index 62ac8a3..78ba699 100644 --- a/src/test/Benchmarks/Bouncing.py +++ b/src/test/Benchmarks/Bouncing.py @@ -37,9 +37,9 @@ def __init__(self, fps): # los objetos a rebotar for i in range(200): - x = 50 + random.random() * 700 - y = 50 + random.random() * 150 - vx = -50 + random.random() * 100 + x = random.randint(50, 750) + y = random.randint(50, 200) + vx = random.randint(-50, 50) vy = 0 gobj = Ball(x, y, vx, vy) self.lge.addGObject(gobj, 1) diff --git a/src/test/Benchmarks/Particles.py b/src/test/Benchmarks/Particles.py index ccfb154..a2f35ae 100644 --- a/src/test/Benchmarks/Particles.py +++ b/src/test/Benchmarks/Particles.py @@ -36,10 +36,10 @@ def __init__(self): self.numParticles = 500 self.particles = [0] * self.numParticles for i in range(self.numParticles): - x = 300 + random.random() * 200 - y = 100 + random.random() * 100 - vx = -120 + random.random() * 240 - vy = -120 + random.random() * 240 + x = random.randint(300, 500) + y = random.randint(100, 200) + vx = random.randint(-120, 120) + vy = random.randint(-120, 120) m = 0.1 + random.random() self.particles[i] = Particle(x, y, vx, vy, m)