예제 #1
0
class ComposingSprite:
    """object used to display the components of the maze"""
    def __init__(self):
        """initialisation de l'objet"""
        self.image_guardian = pygame.image.load(settings.Path_image_guardian)
        self.image_object = pygame.image.load(settings.Path_image_objects)
        self.image_wall = pygame.image.load(settings.Path_image_wall)
        self.position = Position()

    def display_sprite_wall(self, screen, map_class):
        """object used to display the walls of the maze"""
        for i in self.position.research_pos(map_class, settings.Wall):
            screen.blit(self.image_wall, i)
    
    def display_sprite_object(self, screen, map_class):
        """object used to display the objects of the maze"""
        for i in self.position.research_pos(map_class, settings.Objects):
            screen.blit(self.image_object, i)
    
    def display_sprite_guardian(self, screen, map_class):
        """object used to display the gardian of the maze"""
        for g in self.position.research_pos(map_class, settings.Guardian):
            screen.blit(self.image_guardian, g)

    def display_sprite_point(self, screen, nbs_point):
        """object used to display the points of the maze"""
        font = pygame.font.SysFont("comicsansms", 20)
        label = font.render("score : " + str(nbs_point), 0, (255,255,255))
        screen.blit(label, (660,0))
예제 #2
0
 def __init__(self, map_class):
     """I initialize the object that will handle the points"""
     self.map = Map()
     self.position = Position()
     self.pos_computer = (0, 0)
     self.pos_hero = (0, 0)
     self.point = 0
     self.nbs_objects = 0
     self.list_objects = self.map.put_objetcs(map_class)
예제 #3
0
class HeroSprite:
    """object used to display the hero """
    def __init__(self):
        """initialization of the object"""
        self.image_hero = pygame.image.load(settings.Path_image_hero)
        self.position = Position()

    def display_sprite_hero(self, screen, map_class):
        """Posing the hero in the right position, it returns the pose as a tuple """
        position_hero = self.position.research_pos(map_class, settings.Hero)
        screen.blit(self.image_hero, position_hero[0])
        (x, y) = position_hero[0]

        return (x, y)
예제 #4
0
 def __init__(self):
     #object initialization
     self.Composing_sprite_class = ComposingSprite()
     self.hero_sprite_class = HeroSprite()
     self.position_class = Position()
     self.map_class = Map() 
     self.score_class = Point(self.map_class.list_labyrinth)
     self.movement_class = Hero(self.map_class)
     self.new_map = self.map_class.list_map()
     self.screen = pygame.display.set_mode((750, 750))
     self.background = pygame.image.load(settings.Path_image_Background)
     self.win_image = pygame.image.load(settings.Path_image_win)
     self.defeat_image = pygame.image.load(settings.Path_image_defeat)
     self.new_map = self.score_class.generate_new_map()
     self.nbs_point = 0
예제 #5
0
class Map:
    """object used to display the maze and these components"""
    def __init__(self):
        """initialization of the map object"""
        self.list_objects = []
        self.position = Position()
        self.list_labyrinth = self.load_map()
        self.list_labyrinth = [list(s) for s in self.list_labyrinth]

    def load_map(self):
        """loading the file with the maze"""
        with open(settings.Path, 'r') as file:
            list_labyrinth = file.readlines()
        return list_labyrinth

    def display_map(self):
        """ display map in the terminal """
        for line in self.list_labyrinth:
            update_list = "".join(line)
            print(update_list, end="")

    def list_map(self):
        """returns the double list"""
        return self.list_labyrinth

    def put_objetcs(self, map_class):
        """Put the objects randomly into the maze """
        place_object = self.position.research_pos(map_class,
                                                  settings.Path_free)

        for loop in range(3):
            length_list = len(place_object)
            nbs_random = randint(0, length_list)
            self.list_objects.append(place_object[nbs_random])
            (x, y) = self.list_objects[loop]
            x = int(x / 50)
            y = int(y / 50)
            map_class[y][x] = settings.Objects
        print(self.list_objects)
        return self.list_objects
예제 #6
0
class Point:
    """object that will be used to keep track of the player's points"""
    def __init__(self, map_class):
        """I initialize the object that will handle the points"""
        self.map = Map()
        self.position = Position()
        self.pos_computer = (0, 0)
        self.pos_hero = (0, 0)
        self.point = 0
        self.nbs_objects = 0
        self.list_objects = self.map.put_objetcs(map_class)

    def count_points(self, map_class, new_map):
        """method that will be used to increment the points if the player takes an object"""
        for m in self.position.research_pos(map_class, settings.Hero):
            self.pos_hero = m
            (x_hero, y_hero) = self.pos_hero
            x_hero = int(x_hero / 50)
            y_hero = int(y_hero / 50)

        for pos_objects in self.list_objects:
            if pos_objects == self.pos_hero:
                if new_map[y_hero][x_hero] == settings.Objects:
                    self.point += 1
                    new_map[y_hero][x_hero] = settings.Path_free
                elif new_map[y_hero][x_hero] == settings.Path_free:
                    pass
        return self.point

    def generate_new_map(self):
        """method that will be used to generate another map to compare the position of the object with that of the player"""
        for loop in self.list_objects:
            (x, y) = loop
            x = int(x / 50)
            y = int(y / 50)
            new_map = self.map.list_labyrinth
            new_map[y][x] = settings.Objects
        return new_map
예제 #7
0
 def __init__(self):
     """initialization of the object"""
     self.image_hero = pygame.image.load(settings.Path_image_hero)
     self.position = Position()
예제 #8
0
 def __init__(self):
     """initialization of the map object"""
     self.list_objects = []
     self.position = Position()
     self.list_labyrinth = self.load_map()
     self.list_labyrinth = [list(s) for s in self.list_labyrinth]
예제 #9
0
 def __init__(self):
     """initialisation de l'objet"""
     self.image_guardian = pygame.image.load(settings.Path_image_guardian)
     self.image_object = pygame.image.load(settings.Path_image_objects)
     self.image_wall = pygame.image.load(settings.Path_image_wall)
     self.position = Position()