Ejemplo n.º 1
0
def create_wall():
    """
    Randomly generating , with out making it conjusted , walls as obstacles
    """
    if config.W_LIST == []:
        pos = randint(config.M.x_pos + 4, common.R2)
        if common.value_arr(pos, common.MIDS_R) == " " and \
            common.value_arr(pos, common.MIDS_R+1) == "0":
            try:
                witem = obstacle.Wall(pos)
                config.W_LIST.append(witem)
            except config.GapHere:
                pass

    elif len(config.W_LIST) < int((3 * common.COLS) / 80):
        if randint(0, 10) == 5:
            # create a obstacle
            pos = config.W_LIST[-1].x_pos + randint(10, 20)
            if pos < common.COLS - 3:
                try:
                    witem = obstacle.Wall(pos)
                    config.W_LIST.append(witem)
                except config.GapHere:
                    pass

    else:
        pass
Ejemplo n.º 2
0
def check_floor():
    """
    For gravity check
    """
    if common.value_arr(config.M.x_pos, config.M.y_pos + 1) != "0":
        while common.value_arr(config.M.x_pos, config.M.y_pos + 1) != "0":
            config.M.move(config.M.x_pos, config.M.y_pos + 1)
Ejemplo n.º 3
0
def check_life(x_pos, y_pos, who):
    """
    The ways to kill Mario
    """
    if who == "Wall":
        if common.value_arr(x_pos - 1, y_pos) in {"^", "O", "I"}:
            raise config.DeadMario
    elif who == "Enemy":
        if (common.value_arr(x_pos, y_pos) in {"<", ">"}):
            raise config.EnemyHere
        elif common.value_arr(x_pos, y_pos) == "|":
            raise config.WallHere
        elif common.value_arr(x_pos, y_pos + 1) != "0":
            raise config.GapHere
        elif common.value_arr(x_pos, y_pos - 1) in {"^", "O", "I"}:
            raise config.MarioAbove
    elif who == "Mario":
        if common.value_arr(x_pos, y_pos) not in {" ", "I", "O", "^", "$"}:
            raise config.DeadMario
    elif who == "Marijuana":
        for j in range(0, 2):
            for i in range(-2, 3):
                if common.value_arr(x_pos + i, y_pos + j) in {"^", "O", "I"}:
                    raise config.DeadMario
        for i in range(-2, 3):
            for j in range(0, 2):
                if common.value_arr(x_pos + i, y_pos + j) in {"|", "-"}:
                    raise config.WallHere
    elif who == "Boss":
        if common.value_arr(x_pos, y_pos - 4) == "I":
            raise config.MarioAbove
Ejemplo n.º 4
0
    def move(self, x, y):
        # when Mario hits the Marijuana
        if common.value_arr(x, y) == "$":
            sound.play_sound("mb_sc.wav")
            for i in config.M_LIST:
                if i.x_pos == x or i.x_pos == x + 1 or i.x_pos == x - 1:
                    if i.y_pos == y or i.y_pos == y + 1 or i.y_pos == y - 1:
                        config.POINTS += 20
                        config.M_LIST.remove(i)
        try:

            if (x > common.R3 and x < common.R4):
                check.check_life(x, y, "Mario")
                self.refresh_out()
                super().move(x, y)
                self.print_out()

            else:
                movement.move_all(x - self.x_pos)
                check.check_life(self.x_pos, y, "Mario")
                self.refresh_out()
                super().move(self.x_pos, y, "Mario")
                self.print_out()

        except config.GapHere:
            raise config.DeadMario from None
Ejemplo n.º 5
0
 def __check(self):
     if self.y_pos >= common.MIDS_R and common.value_arr(
             self.x_pos, self.y_pos + 1) != '0':
         if self.y_pos > (common.MIDS_R + 3):
             raise config.GapHere
         else:
             self.move(self.x_pos, self.y_pos + 1)
Ejemplo n.º 6
0
def floor(floor_y):
    """
    Coordinates of floor
    """
    for i in range(1, common.COLS + 1):
        if common.value_arr(i, floor_y) == " ":
            common.set_arr(i, floor_y, "0")
            common.set_arr(i, floor_y + 1, "0")