Example #1
0
    def load_content(self) -> None:
        ''' All content the are supposed to be loaded/initialized only once at the beginning are meant to belong in this method, this method is called once

        :returns: NoReturn
        :rtype: None
        '''

        self.object_handler = ObjectHandler(
            Vector2(0, 0), Vector2.tuple_to_vector2(utils.world_size))
        self.camera = Camera(utils.window, self.object_handler,
                             Transform(None),
                             Vector2.tuple_to_vector2(utils.window_size),
                             Vector2(0, 0))
Example #2
0
    def update(self, delta_time):
        '''
        '''

        super().update(delta_time)

        if self.is_dead:
            return

        # update current gun
        self.current_gun.update(delta_time)

        # handle movement
        self._movement(delta_time)

        # shoot
        if event_handler.is_mouse_down(1):
            self.attack()

        # switch weapons
        self._swith_weapons()

        # get the camera in current screen
        camera = Screen.get_current_screen().camera

        # look at mouse
        self.transform.look_at(
            camera.screen_to_world_point(
                Vector2.tuple_to_vector2(pygame.mouse.get_pos())))

        # make the camera follow player
        self._camera_follow(camera)