def __init__(self, mass=None, **kwargs): """Instanciate a collidable with mass (defaults to INFINITY).""" self.intersections = [] self.mass = mass self.last_collide_time = -1 if mass is None: self.mass = util.INFINITY Collidables.append(self) super().__init__(**kwargs) physics.update_intersections(self)
def __init__(self, path, resources_path): """Take a file at path, and extract level details.""" # TODO: Load this in as a file width, height = 640, 480 self.boundary = Rect(size=(width, height)) image = pygame.image.load(os.path.join(resources_path, "jetpack_guy.PNG")) shape = Rect(image.get_rect()).shape # shape = generate_circle(8, 50) self.player = entities.Player(image=image, shape=shape, position=Level._PlayerPosition, velocity=Level._PlayerVelocity) self.width, self.height = width, height self.level_2() #self.ground = entities.Ground(shape=[], render_shape=[]) #self.regenerate_ground() physics.update_intersections(self.ground)
def recalculate_intersections(self, exclude = None): for intersection in self.intersections: if intersection.ent is not exclude and intersection.oth is not exclude: intersection.invalid = True self.intersections = [intersection for intersection in self.intersections if not intersection.invalid] physics.update_intersections(self, exclude)