def test_applying_move_component_with_one_node_to_actor(self): actor = Actor() node = MoveComponentNode(Vector3D(10, 0, 0), 2) actor.add_component(MoveComponent([node])) actor.end_tick() assert actor.move_vector == Vector3D(10, 0, 0)
def test_applying_move_component_with_many_nodes_to_actor(self): actor = Actor() node1 = MoveComponentNode(Vector3D(10, 0, 0), 2) node2 = MoveComponentNode(Vector3D(0, 5, 0), 2) actor.add_component(MoveComponent([node1, node2])) actor.end_tick() actor.end_tick() actor.end_tick() assert actor.move_vector == Vector3D(0, 5, 0)
def test_keep_last_applied_move_component_node(self): actor = Actor() node1 = MoveComponentNode(Vector3D(10, 0, 0), 2) node2 = MoveComponentNode(Vector3D(0, 5, 0), 2) actor.add_component(MoveComponent([node1, node2])) actor.end_tick() actor.end_tick() actor.end_tick() actor.end_tick() assert actor.move_vector == Vector3D(0, 5, 0)
def from_center_static_go_down_up_down_twice_then_ram(cls): return MoveComponent([ MoveComponentNode(Vector3D(-5, 0, 0), 3), ] + [ MoveComponentNode(Vector3D(0, -8, 0), 2), MoveComponentNode(Vector3D(0, 8, 0), 4), MoveComponentNode(Vector3D(0, -8, 0), 2), MoveComponentNode(Vector3D(0, 0, 0), 2) ] + [ MoveComponentNode(Vector3D(0, -8, 0), 2), MoveComponentNode(Vector3D(0, 8, 0), 4), MoveComponentNode(Vector3D(0, -8, 0), 2), ] + [MoveComponentNode(Vector3D(-12, 0, 0), 999)])
def __init__(self): super().__init__() body = Polygon([Point3D(0, 0, 0), Point3D(3, 1, 0), Point3D(3, -1, 0)]) self.add_component(PolygonComponent(body)) self.position = Point3D(10, 10, 0) self.add_component(ColorComponent(RGB(0.2, 0.2, 1))) movement_node_list = [ MoveComponentNode(Vector3D(-5, 0, 0), 1), MoveComponentNode(Vector3D(0, -5, 0), 1), MoveComponentNode(Vector3D(5, 0, 0), 1), MoveComponentNode(Vector3D(0, 5, 0), 1), ] * 50 self.add_component(MoveComponent(movement_node_list)) particle_emitter = ParticleEmitterComponent(RotatingParticle, 10, Vector3D(-6, 0, 0), speed_variability=0, direction_variability=0) shoot_pattern_node_list = [ ShootPatternComponentNode(particle_emitter, 0.3), ShootPatternComponentNode(None, 0.3) ] * 999 self.add_component(ShootPatternComponent(shoot_pattern_node_list))
def from_center_go_straight(cls): return MoveComponent([MoveComponentNode(Vector3D(-5, 0, 0), 999)])
def from_bottom_go_up_down_straight(cls): return MoveComponent([ MoveComponentNode(Vector3D(-4, 6, 0), 3), MoveComponentNode(Vector3D(-4, -6, 0), 1.5), MoveComponentNode(Vector3D(-5, 0, 0), 999) ])