def __init__(self, position, player):
        velocity = np.array([-2., 0.])
        rep = util.str_to_array(graphics.BOSS_BULLET)
        color = util.tup_to_array(rep.shape, (col.Back.RED, col.Fore.YELLOW))

        self.player = player

        super().__init__(rep, position, velocity, color)
    def __init__(self):
        """
        Constructor for falcon
        """
        rep = util.str_to_array(graphics.FALCON)

        position = np.array([config.WIDTH, 1.])

        super().__init__(rep, position, np.array([-4., 0.]))
Beispiel #3
0
    def __init__(self, game):
        """
        Constructor for the Dragon
        """
        grid = util.str_to_array(graphics.DRAGON)
        grid_col = util.tup_to_array(grid.shape,
                                     (col.Back.RED, col.Fore.BLACK))
        grid_col = util.mask(grid, grid_col)
        self.game = game

        super().__init__(grid, \
                    np.array([config.WIDTH - 50, 0], dtype="float64"), \
                    0, grid_col, config.DRAGONBOSS_LIVES, self.game)
    def __init__(self, position, game):
        """
        Constructor for Magnet

        Args:
            position [px, py] : Initial position of the Magnet
            game (Game)       : The game object
        """

        self.game = game
        rep = util.str_to_array(graphics.MAGNET)
        color = util.tup_to_array(rep.shape, (col.Back.MAGENTA, col.Fore.RED))

        super().__init__(rep, position, np.array([-2., 0.]), color=color)
Beispiel #5
0
    def __init__(self, game):
        """
        Constructor for the Mandalorian
        """
        grid = util.str_to_array(graphics.MANDALORIAN)
        grid_col = util.tup_to_array(grid.shape,
                                     (col.Back.BLUE, col.Fore.BLACK))
        self.init_pos = np.array([10, config.MAX_HEIGHT], dtype='float64')

        super().__init__(grid, \
                self.init_pos.copy(),\
                0.45, grid_col, config.MANDALORIAN_LIVES, game)

        self.__controls = ["w", "a", "d"]
        self.shield_active = False
    def __init__(self, position, orientation=None):
        """
        Constructor for FireBeam

        Args:
            position [px, py] : Initial position of the FireBeam
            orientation (int) : 0 -> config.FIREBEAM_MAX, type of FireBeam
        """
        if orientation is None or orientation < 0 or orientation > config.FIREBEAM_MAX:
            orientation = util.randint(0, config.FIREBEAM_MAX - 1)

        rep = util.str_to_array(graphics.FIREBEAM[orientation])
        color = util.tup_to_array(rep.shape, (col.Back.RED, col.Fore.YELLOW))

        super().__init__(rep, position, np.array([-2., 0.]),
                         util.mask(rep, color))
Beispiel #7
0
    def get_rep(self, phase_offset=0):
        """
        Returns the live representation of dragon
        """
        rep = np.full((self.height, self.width), " ")
        color = util.tup_to_array(rep.shape, (col.Back.BLACK, col.Fore.GREEN))

        dragon_head = util.str_to_array(graphics.DRAGON_HEAD)
        head_h, head_w = dragon_head.shape

        # phase_offset = 4 * (phase_offset // 4)

        _h, _w = self.get_shape()

        body_width = _w - head_w

        _y = np.sin(np.linspace(-np.pi, np.pi, body_width) + phase_offset)
        _y *= (_h / 2)
        _y += (_h / 2)

        _y = _y.astype(int)

        for i in range(body_width):
            rep[_y[i]][i] = "~"

            if _y[i] > self.height - 2:
                rep[_y[i] - 2][i] = "~"
            else:
                rep[_y[i] + 1][i] = "~"

            if _y[i] == 0:
                rep[2][i] = "~"
            else:
                rep[_y[i] - 1][i] = "~"

        beg_h = int(min(_y[-1], self.height - head_h))

        rep[beg_h:beg_h + head_h, -head_w:] = dragon_head

        self.head = self.get_position() + beg_h

        color = util.mask(rep, color)

        return rep, color
Beispiel #8
0
    def from_string(rep,
                    position=np.array([0., 0.]),
                    velocity=np.array([0., 0.]),
                    accel=np.array([0., 0.]),
                    gravity=0,
                    color=("", "")):
        """
        Creates a GameObject from string

        Args:
            rep (2D np.array)   : The object representation (How does it look?)
            position ([x, y])   : Initial position of the object
            velocity ([vx, vy]) : Speed with which the object moves to left
            accel ([fx, fy])    : accel in both dir
            gravity (float)     : Gravitational accel on that object
            color (str, str)    : Color of each character (bg, fg)

        Returns:
            GameObject with all the parameters
        """
        grid = util.str_to_array(rep)
        color = util.mask(grid, util.tup_to_array(grid.shape, color))

        return GameObject(grid, position, velocity, accel, gravity, color)
    def __init__(self, position):
        velocity = np.array([2., 0.])
        rep = util.str_to_array(graphics.MANDALORIAN_BULLET)
        color = util.tup_to_array(rep.shape, (col.Back.WHITE, col.Fore.BLACK))

        super().__init__(rep, position, velocity, color)