Esempio n. 1
0
 def populateMap(self):
     for x in range(len(self.map)):
         for y in range(len(self.map[x])):
             if self.map[x][y] == 1:
                 # Add a wall at that position
                 self.Walls.append(OnBoard(self.IMAGES["wood_block"], (y * 15 + 15 / 2, x * 15 + 15 / 2)))
             elif self.map[x][y] == 2:
                 # Add a ladder at that position
                 self.Ladders.append(OnBoard(self.IMAGES["ladder"], (y * 15 + 15 / 2, x * 15 + 15 / 2)))
Esempio n. 2
0
 def resetGroups(self):
     self.score = 0
     self.lives = 3
     self.map = []  # We will create the map again when we reset the game
     self.Players = [Player(self.IMAGES["still"], (self.__width/2, 435), 15, 15)]
     self.Enemies = [MonsterPerson(self.IMAGES["monster0"], (100, 117), self.rng, self._dir)]
     self.Allies = [Person(self.IMAGES["princess"], (50, 48), 18, 25)]
     self.Allies[0].updateWH(self.Allies[0].image, "H", 0, 25, 25)
     self.Coins = []
     self.Walls = []
     self.Ladders = []
     self.Fireballs = []
     self.FireballEndpoints = [OnBoard(self.IMAGES["still"], (50, 440))]
     self.initializeGame()  # This initializes the game and generates our map
     self.createGroups()  # This creates the instance groups
Esempio n. 3
0
    def populateMap(self):
        self.map = np.loadtxt(os.path.join(self._dir, 'map1.txt'), dtype='i', delimiter=',') #use numpy for python3

        for x in range(len(self.map)):
            for y in range(len(self.map[x])):
                if self.map[x][y] == 1:
                    # Add a wall at that position
                    self.Walls.append(
                        OnBoard(
                            self.IMAGES["wood_block"],
                            (y * 15 + 15 / 2,
                             x * 15 + 15 / 2)))
                elif self.map[x][y] == 2:
                    # Add a ladder at that position
                    self.Ladders.append(
                        OnBoard(
                            self.IMAGES["ladder"],
                            (y * 15 + 15 / 2,
                             x * 15 + 15 / 2)))
                elif self.map[x][y] == 11:
                    # Add the enemy to our enemy list
                    self.enemys.append(
                        enemy(
                            self.IMAGES["enemy1"],
                            (y * 15 + 15 / 2,
                             x * 15 + 15 / 2),
                             self._dir))
                elif self.map[x][y] == 12:
                    # Add the enemy to our enemy list
                    self.enemys2.append(
                        enemy(
                            self.IMAGES["enemy2"],
                            (y * 15 + 15 / 2,
                             x * 15 + 15 / 2),
                             self._dir))
                # Add a wall at that position
                elif self.map[x][y] == 4:
                    self.Walls.append(
                        OnBoard(
                            self.IMAGES["wood_block2"],
                            (y * 15 + 15 / 2,
                             x * 15 + 15 / 2)))                 
                elif self.map[x][y] == 5:
                    self.Walls.append(
                        OnBoard(
                            self.IMAGES["wood_block3"],
                            (y * 15 + 15 / 2,
                             x * 15 + 15 / 2)))
                elif self.map[x][y] == 6:
                    self.Walls.append(
                        OnBoard(
                            self.IMAGES["wood_block4"],
                            (y * 15 + 15 / 2,
                             x * 15 + 15 / 2))) 
                elif self.map[x][y] == 7:
                    self.Walls.append(
                        OnBoard(
                            self.IMAGES["wood_block5"],
                            (y * 15 + 15 / 2,
                             x * 15 + 15 / 2))) 
                elif self.map[x][y] == 9:
                    self.Walls.append(
                        OnBoard(
                            self.IMAGES["boundary"], #9 is to create boundary walls so that player doesn't cross over the game
                            (y * 15 + 15 / 2,
                             x * 15 + 15 / 2)))