Esempio n. 1
0
    def fall(self, limx, direction, matrix, ladder, floor, wall, coin, donkey, fireballs):

        self.collectCoin(matrix, coin)

        #direction of fall
        if direction == Direction.EAST:
            offset = self.velx
        elif direction == Direction.WEST:
            offset = -1*self.velx
        else: 
            offset = 0
        if ((direction == Direction.EAST and matrix.SE_of(self) == matrix.symbol) or (direction == Direction.WEST and matrix.SW_of(self) == matrix.symbol) or matrix.getPosition(self) == matrix.symbol):
            while matrix.grid[self.y+self.vely][self.x+offset] in [matrix.symbol, 'o', coin.symbol]:
                self.collectCoin(matrix, coin)
                matrix.update_character_in_matrix(self.y, self.x, self.trace)
                matrix.update_ladders_in_matrix(floor.coordinates, ladder.coordinates, ladder.symbol, floor.gap)
                for fireball in fireballs:
                    matrix.update_character_in_matrix(fireball.y, fireball.x, fireball.trace)
                    fireball.move(limx, matrix, self, ladder, wall, floor, 0)
                    matrix.update_character_in_matrix(fireball.y, fireball.x, fireball.symbol)
                matrix.update_character_in_matrix(donkey.y, donkey.x, donkey.trace)
                donkey.move(matrix.grid, self, 0)
                matrix.update_coins_in_matrix(coin.coordinates, coin.symbol)
                matrix.update_character_in_matrix(donkey.y, donkey.x, donkey.symbol)
                self.y += self.vely
                if matrix.grid[self.y][self.x+offset] != wall:
                    self.x += offset
                matrix.update_character_in_matrix(self.y, self.x, self.symbol) 
                #                time.sleep(0.05)
                matrix.print_matrix(self.score, self.lives)
Esempio n. 2
0
    def climb_down(self, matrix, player, ladder, wall, floor, autocall = 1):

        while matrix.S_of(self) not in [floor.symbol, wall]:
            self.checkCollision(player)
            matrix.update_character_in_matrix(self.y, self.x, self.trace)
            matrix.update_ladders_in_matrix(floor.coordinates, ladder.coordinates, ladder.symbol, floor.gap)
            self.y += self.vely
            matrix.update_character_in_matrix(self.y, self.x, self.symbol)
            if autocall == 1:
                time.sleep(0.02)
            matrix.print_matrix(player.score, player.lives)
Esempio n. 3
0
    def fall(self, matrix, player, ladder, wall, floor, autocall = 1):

        offset = self.velx
        while matrix.SE_of(self) == matrix.symbol or matrix.SW_of(self) == matrix.symbol:
            matrix.update_character_in_matrix(self.y, self.x, self.trace)
            matrix.update_ladders_in_matrix(floor.coordinates, ladder.coordinates, ladder.symbol, floor.gap)
            self.y += self.vely
            if matrix.grid[self.y][self.x+offset] != wall:
                self.x += offset
            matrix.update_character_in_matrix(self.y, self.x, self.symbol)
            if autocall == 1:
                time.sleep(0.02)
            matrix.print_matrix(player.score, player.lives)
Esempio n. 4
0
    def climb(self, direction, matrix, ladder, floor, coin):

            self.collectCoin(matrix, coin)

            matrix.update_ladders_in_matrix(floor.coordinates, ladder.coordinates, ladder.symbol, floor.gap)

            if direction == Direction.NORTH and matrix.getPosition(self) == ladder.symbol:
                if matrix.N_of(self) == matrix.symbol and matrix.S_of(self) == floor.symbol:
                    return;
                self.y -= self.vely
            elif direction == Direction.SOUTH and matrix.S_of(self) == ladder.symbol:
                self.y += self.vely
            else:
                return

            matrix.update_character_in_matrix(self.y, self.x, self.symbol)
Esempio n. 5
0
    def jump(self, direction, limx, limy, matrix, ladder, floor, wall, coin, donkey, fireballs, max_height = 2, multiplier = 3):

        self.collectCoin(matrix, coin)

        #direction of jump
        if self.motion == Motion.RIGHT:
            offset = multiplier*self.velx
        elif self.motion == Motion.LEFT:
            offset = -1*multiplier*self.velx
        elif self.motion == Motion.REST:
            offset = 0

        matrix.update_character_in_matrix(self.y, self.x, self.trace)
        #init jump
        if direction == Direction.JUMP and matrix.S_of(self) in [wall, floor.symbol, ladder.symbol]:
            maxjump = self.y-max_height
            initial_height = self.y

            #up
            while self.y > maxjump:
                matrix.update_character_in_matrix(self.y, self.x, self.trace)
                matrix.update_ladders_in_matrix(floor.coordinates, ladder.coordinates, ladder.symbol, floor.gap)
                for fireball in fireballs:
                    matrix.update_character_in_matrix(fireball.y, fireball.x, fireball.trace)
                    fireball.move(limx, matrix, self, ladder, wall, floor, 0)
                    matrix.update_character_in_matrix(fireball.y, fireball.x, fireball.symbol)
                matrix.update_character_in_matrix(donkey.y, donkey.x, donkey.trace)
                donkey.move(matrix.grid, self, 0)
                matrix.update_coins_in_matrix(coin.coordinates, coin.symbol)
                matrix.update_character_in_matrix(donkey.y, donkey.x, donkey.symbol)
                if matrix.N_of(self) != floor.symbol or getPosition(self) != floor.symbol:
                     if matrix.getPosition(self) == ladder.symbol and self.motion != Motion.REST:
                         break
                     self.y -= self.vely
                else:
                     break
                if self.x + offset not in range(1,limx-2):
                     if self.motion == Motion.RIGHT:
                         self.x = limx-2
                         offset = 0
                     elif self.motion == Motion.LEFT:
                         self.x = 1
                         offset = 0
                else:
                     self.x += offset
                matrix.update_character_in_matrix(self.y, self.x, self.symbol)
                time.sleep(0.05)
                matrix.print_matrix(self.score, self.lives)

            #down    
            while matrix.S_of(self) in [matrix.symbol, 'o', coin.symbol]:
                self.collectCoin(matrix, coin)
                matrix.update_character_in_matrix(self.y, self.x, self.trace)
                matrix.update_ladders_in_matrix(floor.coordinates, ladder.coordinates, ladder.symbol, floor.gap)
                for fireball in fireballs:
                    matrix.update_character_in_matrix(fireball.y, fireball.x, fireball.trace)
                    fireball.move(limx, matrix, self, ladder, wall, floor, 0)
                    matrix.update_character_in_matrix(fireball.y, fireball.x, fireball.symbol)
                matrix.update_character_in_matrix(donkey.y, donkey.x, donkey.trace)
                donkey.move(matrix.grid, self, 0)
                matrix.update_coins_in_matrix(coin.coordinates, coin.symbol)
                matrix.update_character_in_matrix(donkey.y, donkey.x, donkey.symbol)
                if matrix.getPosition(self) == ladder.symbol and self.motion != Motion.REST:
                    break
                self.y += self.vely
                if self.x + offset not in range(1,limx-1):
                    if self.motion == Motion.RIGHT:
                        self.x = limx-2
                        offest = 0
                    elif self.motion == Motion.LEFT: 
                        self.x = 1
                        offset = 0
                else:
                    self.x += offset
                matrix.update_character_in_matrix(self.y, self.x, self.symbol)
                time.sleep(0.05)
                matrix.print_matrix(self.score, self.lives)