diff --git a/main.py b/main.py index b3e2b12..21a7c84 100644 --- a/main.py +++ b/main.py @@ -170,8 +170,12 @@ def main(): environment.ground, environment.offset) # if perlin, offset = 0, if basic, offset = environment.offset - #creature_instance.render(screen) - for creature in creatures: + if creature.limbs[0].body.position.y > SCREEN_HEIGHT: + # kill the creature + creatures.remove(creature) + if creature.limbs[0].body.position.x < environment.death_ray.get_x(): + # kill the creature + creatures.remove(creature) creature.render(screen) clock.tick(60) diff --git a/src/agent.py b/src/agent.py index 5c31f38..1ba7585 100644 --- a/src/agent.py +++ b/src/agent.py @@ -7,8 +7,8 @@ from src.environment import Environment from src.render_object import RenderObject -from src.agent_parts_old.limb import Limb, LimbType, limb_factory -from src.agent_parts_old.creature import Creature, creature_factory +from src.agent_parts.limb import Limb, LimbType, limb_factory +from src.agent_parts.creature import Creature, creature_factory class Agent(ABC): diff --git a/src/environment.py b/src/environment.py index 8698dc6..9a309bd 100644 --- a/src/environment.py +++ b/src/environment.py @@ -36,6 +36,7 @@ def __init__(self, screen, space): self.offset = 0 self.offset_speed = 1 + self.death_ray = DeathRay(20) def ground_factory(self, ground_type: GroundType) -> Ground: @@ -61,9 +62,12 @@ def update(self): self.ground.update(self.offset) # self.ground.move_segments(self.offset/100) self.starting_xx += 1 + self.death_ray.move(0.1) + def render(self): self.ground.render() + self.death_ray.render(self.screen) def run(self): @@ -106,5 +110,25 @@ def run(self): def draw_mark(surface, color, coord): pg.draw.circle(surface, color, coord, 3) +class DeathRay: + x: int + + def __init__(self, x: int): + self.x = x + + def update(self, x: int): + self.x = x + + def render(self, screen): + pg.draw.line(screen, RED, (self.x, 0), (self.x, SCREEN_HEIGHT), 2) + + def move(self, offset: int): + self.x += offset + + def get_x(self): + return self.x + + +