Skip to content

Commit

Permalink
feat: death ray
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasfremming committed Nov 11, 2024
1 parent fb1f7a8 commit afc1421
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
8 changes: 6 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
24 changes: 24 additions & 0 deletions src/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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):

Expand Down Expand Up @@ -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





0 comments on commit afc1421

Please sign in to comment.