예제 #1
0
 def __init__(self, lifespan=10, hit_damage=1):
     super().__init__(lifespan, hit_damage)
     body = PrimitiveShapes.rectangle(0.3, 0.3, 45)
     body.translate(Vector3D(-0.05, -0.05, 0))
     self.delete_all_components()
     self.add_component(PolygonComponent(body))
     self.add_component(HitboxComponent(body))
     self.add_component(ColorComponent(RGB(1, 0.4, 0.4)))
예제 #2
0
 def __init__(self):
     self.__position = Point3D(0, 0, 0)
     self.__move_vector = Vector3D(0, 0, 0)
     self.__rotation = Rotation(rotation_callback=self.__rotation_callback)
     self.__spinning_speed = 0
     self.__event_handler = event_handler.EventHandler()
     self.__components = []
     self.__collision_mask = 0x0
예제 #3
0
 def __init__(self, lifespan=10, hit_damage=1):
     super().__init__(lifespan)
     body = PrimitiveShapes.rectangle(0.2, 0.2, 45)
     body.translate(Vector3D(-0.05, -0.05, 0))
     self.add_component(PolygonComponent(body))
     self.add_component(HitboxComponent(body))
     self.add_component(ColorComponent(RGB(1, 0.4, 0.4)))
     self.__subscribe_to_events()
     self.__hit_damage = hit_damage
예제 #4
0
파일: main.py 프로젝트: jorchube/GameEngine
    def __init__(self):
        super().__init__()
        body = Polygon([Point3D(5, 0, 0), Point3D(0, 5, 0), Point3D(5, 5, 0)])

        body.translate(Vector3D(0, 0, 0, origin=body.center))

        self.add_component(HitboxComponent(body))
        self.add_component(PolygonComponent(body))
        self.position = Point3D(-15, 5, 0)
        self.spinning_speed = 3
예제 #5
0
    def test_actor_position_changes_on_tick_notification_when_on_move_vector_is_not_zero_normalized_with_the_fps(
            self):
        Game.set_display_configuration(DisplayConfiguration(800, 600, 30))
        an_actor = Actor()
        an_actor.position = Point3D(5, 5, 5)
        an_actor.move_vector = Vector3D(15, -15, 30)

        an_actor.end_tick()

        assert an_actor.position == Point3D(5.5, 4.5, 6)
예제 #6
0
파일: main.py 프로젝트: jorchube/GameEngine
 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))
예제 #7
0
파일: main.py 프로젝트: jorchube/GameEngine
 def __init__(self):
     super().__init__()
     body1 = Polygon([
         Point3D(0, -0.25, 0),
         Point3D(3, -0.25, 0),
         Point3D(3, 0.25, 0),
         Point3D(0, 0.25, 0)
     ])
     body2 = Polygon(
         [Point3D(3.5, -1, 0),
          Point3D(3.5, 1, 0),
          Point3D(5, 0, 0)])
     polygon1 = PolygonComponent(body1)
     polygon1.add_component(ColorComponent(RGB(1, 0, 0)))
     polygon1.add_component(OutlineComponent(RGB(0, 0, 1), thickness=4))
     polygon2 = PolygonComponent(body2)
     polygon2.add_component(ColorComponent(RGB(0, 1, 0)))
     polygon2.add_component(OutlineComponent(RGB(0.5, 0, 0.5), thickness=8))
     self.add_component(HitboxComponent(body1))
     self.add_component(polygon1)
     self.add_component(HitboxComponent(body2))
     self.add_component(polygon2)
     self.position = Point3D(5, -15, 0)
     self.spinning_speed = 0.6
     self.subscribe_to_event(collision_event.CollisionEvent,
                             self.__on_collision_event)
     self.collision_sound = Audio.new_sound(
         'sound_samples/metal_crunch.wav')
     particle_emitter = ParticleEmitterComponent(RotatingParticle,
                                                 5,
                                                 Vector3D(9, 0, 0),
                                                 speed_variability=0.1,
                                                 direction_variability=0.1)
     particle_emitter.position_offset_relative_to_actor = Vector3D(5, 0, 0)
     self.add_component(particle_emitter)
     self.collision_mask = 0x01
예제 #8
0
파일: main.py 프로젝트: jorchube/GameEngine
 def __init__(self):
     super().__init__()
     body = Polygon(
         [Point3D(0, 0, 0),
          Point3D(-3, -1, 0),
          Point3D(-3, 1, 0)])
     self.add_component(HitboxComponent(body))
     self.add_component(PolygonComponent(body))
     self.position = Point3D(-10, 15, 0)
     particle_emitter = ParticleEmitterComponent(TriangleParticle,
                                                 10,
                                                 Vector3D(6, 0, 0),
                                                 speed_variability=0.5,
                                                 direction_variability=60)
     self.add_component(particle_emitter)
 def __apply_emission_vector(self, particle):
     particle.move_vector = Vector3D.multiply_vector_by_number(
         GeometryOperations.rotate_vector(
             self.__emission_vector,
             self.__calculate_direction_variability()),
         self.__calculate_speed_variability())
예제 #10
0
 def __move_vector_per_tick(self):
     return Vector3D.divide_vector_by_number(
         self.move_vector,
         game.Game.display_configuration().fps)
예제 #11
0
 def __init__(self):
     self.__actor = None
     self.__tag = None
     self.__components = []
     self.__offset_relative_to_actor = Vector3D(0, 0, 0)
     self.__original_offset_relative_to_actor = Vector3D(0, 0, 0)
예제 #12
0
    def test_creating_a_3d_vector_setting_an_origin_point(self):
        vector = Vector3D(5, 6, 7, origin=Point3D(1, 3, 5))

        assert vector.x == 4
        assert vector.y == 3
        assert vector.z == 2
예제 #13
0
    def test_creating_a_3d_vector(self):
        vector = Vector3D(1, 2, 3)

        assert vector.x == 1
        assert vector.y == 2
        assert vector.z == 3
예제 #14
0
    def test_multiplying_by_number(self):
        p1 = Vector3D(1, 2, 3)

        assert Vector3D(2, 4, 6) == Vector3D.multiply_vector_by_number(p1, 2)
예제 #15
0
    def test_dividing_by_number(self):
        p1 = Vector3D(1, 2, 3)

        assert Vector3D(0.5, 1, 1.5) == Vector3D.divide_vector_by_number(p1, 2)
예제 #16
0
 def test_comparing_two_vectors(self):
     assert Vector3D(1, 2, 3) == Vector3D(1, 2, 5, origin=Point3D(0, 0, 2))
     assert Vector3D(1, 2, 3) != Vector3D(1, 2, 5)
예제 #17
0
    def test_substracting_two_vectors(self):
        added = Vector3D(5, 2, 17) - Vector3D(3, 4, 5)

        assert added.x == 2
        assert added.y == -2
        assert added.z == 12
예제 #18
0
    def test_adding_two_vectors(self):
        added = Vector3D(1, 2, 3) + Vector3D(3, 4, 5)

        assert added.x == 4
        assert added.y == 6
        assert added.z == 8
예제 #19
0
 def setUp(self):
     self.fps = 60
     self.scene = mock.MagicMock()
     Game.set_display_configuration(DisplayConfiguration(800, 600, fps=self.fps))
     Game.set_scene(self.scene)
     self.game = Game
     self.an_actor = Actor()
     self.test_emitter = ParticleEmitterComponent(OneSecondLifespanParticle, emission_rate=1, emission_vector=Vector3D(1, 0, 0))
     self.an_actor.add_component(self.test_emitter)
예제 #20
0
 def rotate_vector(cls, vector, z_axis):
     geo = geometry.LineString([[0, 0, 0], [vector.x, vector.y, vector.z]])
     rotated = affinity.rotate(geo, z_axis)
     new_coords = rotated.coords
     return Vector3D(new_coords[1][0] - new_coords[0][0],
                     new_coords[1][1] - new_coords[0][1], 0)