Пример #1
0
def test_combat(zone):
    INVENTORY.add('potion')
    INVENTORY.add('potion')
    INVENTORY.add('dragon blood')
    INVENTORY.add('stone')
    INVENTORY.add('honey')

    heros = [Character('nod1',(0,0),'NOD',1),Character('nel1',(0,0),'NEL',1)]
    dummy_scene = FightScene(zone,heros)
    cocos.director.director.push(dummy_scene)
Пример #2
0
def start_game():
    INVENTORY.add('potion')
    INVENTORY.add('potion')
    INVENTORY.add('dragon blood')

    HOOK['NED'] = Character('nel1',(0,0),'NEL',1)
    
    player = Character('nod1',(0,0),'NOD',1)
    player.map_mode()
    player.do(MoveCharacter())
    player.do(CheckForBattle())


    MAPS['inside_house_nod'] = Map('inside_house_nod')
    MAPS['village'] = Map('village')
    MAPS['village2'] = Map('village2')
    MAPS['village3'] = Map('village3')

    MAPS['inside_house_gen_1'] = Map('inside_house_gen_1')
    MAPS['inside_house_gen_2'] = Map('inside_house_gen_2')
    MAPS['inside_house_gen_3'] = Map('inside_house_gen_3')
    MAPS['inside_house_gen_4'] = Map('inside_house_gen_4')
    MAPS['inside_ceremony_hall'] = Map('inside_ceremony_hall')
    MAPS['grassland'] = Map('grassland')
    MAPS['forest'] = Map('forest')
    MAPS['falaise'] = Map('falaise')


    MAPS['inside_house_nod'].spawnPlayer(player, (7,9))
    MAPS['inside_house_nod'].displayDialog('Intro')

    cocos.director.director.window.push_handlers(KEYBOARD)
Пример #3
0
def init_game():

    print "Initialising the game..."

    INVENTORY.add('potion')
    INVENTORY.add('potion')
    INVENTORY.add('dragon blood')

    HOOK['NED'] = Character('nel1',(0,0),'NEL',1)
    
    player = Character('nod1',(0,0),'NOD',1)
    player.map_mode()
    player.do(MoveCharacter())
    player.do(CheckForBattle())


    MAPS['inside_house_nod'] = Map('inside_house_nod')
    MAPS['village'] = Map('village')
    MAPS['village2'] = Map('village2')
    MAPS['village3'] = Map('village3')

    MAPS['inside_house_gen_1'] = Map('inside_house_gen_1')
    MAPS['inside_house_gen_2'] = Map('inside_house_gen_2')
    MAPS['inside_house_gen_3'] = Map('inside_house_gen_3')
    MAPS['inside_house_gen_4'] = Map('inside_house_gen_4')
    MAPS['inside_ceremony_hall'] = Map('inside_ceremony_hall')
    MAPS['grassland'] = Map('grassland')
    MAPS['forest'] = Map('forest')
    MAPS['falaise'] = Map('falaise')

    main_command =  [
                    ('Start game',start_game,[player]),
                    ('Credits',push_credit,[]),
                    ('Battle (Prairie)',test_combat,['prairie']),
                    ('Battle (Forest)',test_combat,['forest']),
                    ('How to play',push_how_to_play,[])
                    ]

    menu_scene = cocos.scene.Scene()
    menu_scene.schedule(callback)

    #Title
    sprite = cocos.sprite.Sprite('img/GUI/titre.png',(400,450))
    menu_scene.add(sprite)

    menu =  Menu(main_command)
    menu_scene.add(menu)
    print "Going to menu..."
    cocos.director.director.replace(cocos.scenes.FadeTransition( menu_scene, duration=2 ) )
Пример #4
0
    def __init__(self, name):

        self.name = name

        self.scroller = cocos.layer.ScrollingManager()
        self.char_layer = cocos.layer.ScrollableLayer()
        self.map_layer = cocos.tiles.load('maps/'+self.name+'.tmx')["ground1"]
        self.map_layer2 = cocos.tiles.load('maps/'+self.name+'.tmx')["ground2"]
        self.map_layer3 = cocos.tiles.load('maps/'+self.name+'.tmx')["foreground"]

        self.scroller.add(self.map_layer, z = 0)

        self.scroller.add(self.map_layer2, z = 1)

        self.scroller.add(self.char_layer, z = 2)

        self.scroller.add(self.map_layer3, z = 3)


        #self.player = None

        self.npcs = {}
        self.items = []

        cocos.scene.Scene.__init__(self, self.scroller)

        self.dialog_layer = cocos.layer.Layer()
        self.dialog_box = cocos.sprite.Sprite(pyglet.image.load('img/GUI/dialog_box.png'), anchor=(0,0))
        self.dialog_layer.add(self.dialog_box,z=0)
        self.dialog_layer.visible = False
        self.add(self.dialog_layer, z = 4)
        self.dialog_line1 = cocos.text.Label(anchor_x = 'left',font_name='Statix',position=(100,90), color=(36,36,36,255), font_size=30)
        self.dialog_line2 = cocos.text.Label(anchor_x = 'left',font_name='Statix',position=(100,46), color=(36,36,36,255), font_size=30)

        self.dialog_arrow = cocos.sprite.Sprite(pyglet.image.load('img/GUI/dialog_arrow.png'), anchor=(0,0))
        self.dialog_arrow.position = (690,15)
        self.dialog_arrow.visible = False
        self.dialog_layer.add(self.dialog_arrow, z = 5)

        self.dialog_layer.add(self.dialog_line1, z = 5)
        self.dialog_layer.add(self.dialog_line2, z = 5)

        self.current_dialog = []
        self.current_dialog_speaker = []
        self.current_dialog_counter = 0
        self.speaker_boxes = {}

        # Spawn characters
        player = Character('nod1',(0,0))
        player.map_mode()

        self.timer = 0.0

        self.in_transition = True

        if name == 'village':
            name += str(1)

        for character in MAPCHARA[name]:
            chara = Character(character[0][0:-1], (0,0))
            chara.name = character[0]
            self.placeCharacter(chara, character[1])

        cocos.director.director.window.push_handlers(self)

        # self.bgm = pyglet.media.load('bgm/'+BGM[name], streaming=False)
        # self.bgm_player = pyglet.media.Player()
        # self.bgm_player.queue(self.bgm)
        # self.bgm_player.eos_action = self.bgm_player.EOS_LOOP

        self.ready = 0
Пример #5
0
    def __init__(self, name):

        self.name = name

        self.scroller = cocos.layer.ScrollingManager()
        self.char_layer = cocos.layer.ScrollableLayer()
        self.map_layer = cocos.tiles.load('maps/' + self.name +
                                          '.tmx')["ground1"]
        self.map_layer2 = cocos.tiles.load('maps/' + self.name +
                                           '.tmx')["ground2"]
        self.map_layer3 = cocos.tiles.load('maps/' + self.name +
                                           '.tmx')["foreground"]

        self.scroller.add(self.map_layer, z=0)

        self.scroller.add(self.map_layer2, z=1)

        self.scroller.add(self.char_layer, z=2)

        self.scroller.add(self.map_layer3, z=3)

        #self.player = None

        self.npcs = {}
        self.items = []

        cocos.scene.Scene.__init__(self, self.scroller)

        self.dialog_layer = cocos.layer.Layer()
        self.dialog_box = cocos.sprite.Sprite(
            pyglet.image.load('img/GUI/dialog_box.png'), anchor=(0, 0))
        self.dialog_layer.add(self.dialog_box, z=0)
        self.dialog_layer.visible = False
        self.add(self.dialog_layer, z=4)
        self.dialog_line1 = cocos.text.Label(anchor_x='left',
                                             font_name='Statix',
                                             position=(100, 90),
                                             color=(36, 36, 36, 255),
                                             font_size=30)
        self.dialog_line2 = cocos.text.Label(anchor_x='left',
                                             font_name='Statix',
                                             position=(100, 46),
                                             color=(36, 36, 36, 255),
                                             font_size=30)

        self.dialog_arrow = cocos.sprite.Sprite(
            pyglet.image.load('img/GUI/dialog_arrow.png'), anchor=(0, 0))
        self.dialog_arrow.position = (690, 15)
        self.dialog_arrow.visible = False
        self.dialog_layer.add(self.dialog_arrow, z=5)

        self.dialog_layer.add(self.dialog_line1, z=5)
        self.dialog_layer.add(self.dialog_line2, z=5)

        self.current_dialog = []
        self.current_dialog_speaker = []
        self.current_dialog_counter = 0
        self.speaker_boxes = {}

        # Spawn characters
        player = Character('nod1', (0, 0))
        player.map_mode()

        self.timer = 0.0

        self.in_transition = True

        if name == 'village':
            name += str(1)

        for character in MAPCHARA[name]:
            chara = Character(character[0][0:-1], (0, 0))
            chara.name = character[0]
            self.placeCharacter(chara, character[1])

        cocos.director.director.window.push_handlers(self)

        self.bgm = pyglet.media.load('bgm/' + BGM[name], streaming=False)
        self.bgm_player = pyglet.media.Player()
        self.bgm_player.queue(self.bgm)
        self.bgm_player.eos_action = self.bgm_player.EOS_LOOP

        self.ready = 0
Пример #6
0
    def step(self, dt):

        if self.target.current_map.timer < 2.0:
            self.target.visible = False
            self.target.current_map.timer += dt
            return
        else:
            self.target.visible = True

        # handle input and move the character
        if self.target.current_map.dialog_layer.visible == True:
            return
        self.target.velocity = ((KEYBOARD[key.RIGHT] - KEYBOARD[key.LEFT]) *
                                150,
                                (KEYBOARD[key.UP] - KEYBOARD[key.DOWN]) * 150)
        if self.target.current_map is not None:

            x0 = self.target.position[0]
            y0 = self.target.position[1]

            x = self.target.position[0] + self.target.velocity[0] * dt
            y = self.target.position[1] + self.target.velocity[1] * dt

            #rect = cocos.rect.Rect(x-12, y, 24, 16)
            rect_x = cocos.rect.Rect(x - 12, y0, 24, 16)
            rect_y = cocos.rect.Rect(x0 - 12, y, 24, 16)

            for i in range(int(x / TILE_SIZE) - 1, int(x / TILE_SIZE) + 2):
                for j in range(int(y / TILE_SIZE) - 1, int(y / TILE_SIZE) + 2):
                    cell = self.target.current_map.map_layer.get_cell(i, j)
                    cell2 = self.target.current_map.map_layer2.get_cell(i, j)

                    if cell is not None:
                        if cell.intersects(rect_x):
                            if cell is not None and 'passable' in cell and cell[
                                    'passable'] == 'True':
                                if cell2 is not None and 'passable' in cell2 and cell2[
                                        'passable'] == 'True':
                                    pass
                                else:
                                    self.target.velocity = (
                                        0, self.target.velocity[1])
                            else:
                                self.target.velocity = (
                                    0, self.target.velocity[1])

                        if cell.intersects(rect_y):
                            if cell is not None and 'passable' in cell and cell[
                                    'passable'] == 'True':
                                if cell2 is not None and 'passable' in cell2 and cell2[
                                        'passable'] == 'True':
                                    pass
                                else:
                                    self.target.velocity = (
                                        self.target.velocity[0], 0)
                            else:
                                self.target.velocity = (
                                    self.target.velocity[0], 0)

            if self.target.velocity != (0, 0):
                self.target.map_position = [
                    int(self.target.position[0]) / TILE_SIZE,
                    int(self.target.position[1]) / TILE_SIZE
                ]
                self.target.current_map.scroller.set_focus(
                    self.target.position[0], self.target.position[1])
                self.target.battle_timer += dt

                cell = self.target.current_map.map_layer2.get_cell(
                    self.target.map_position[0], self.target.map_position[1])
                if 'door' in cell:
                    self.target.current_map = MAPS[cell['door_map']]
                    dest = cell['door_destination'].split()
                    dest = [int(dest[0]), int(dest[1])]
                    self.target.current_map.spawnPlayer(self.target, dest)
            #
            # if next_cell is not None and 'passable' in next_cell and next_cell['passable'] == 'True':
            #     if 'door' in next_cell:
            #         self.target.current_map = MAPS[next_cell['door_map']]
            #         dest = next_cell['door_destination'].split()
            #         dest = [int(dest[0]), int(dest[1])]
            #         self.target.current_map.spawnPlayer(self.target, dest)
            #     self.target.map_position = [int(self.target.position[0]) / TILE_SIZE, int(self.target.position[1]) / TILE_SIZE]
            #     self.target.current_map.scroller.set_focus(self.target.position[0], self.target.position[1])
            #     self.target.battle_timer += dt
            # else:
            #     # Nice to have : slider le long des murs
            #     self.target.velocity = (0,0)

            player_rect = self.target.get_rect()
            player_rect.x += self.target.velocity[0] * dt
            player_rect.y += self.target.velocity[1] * dt

            if self.target.current_map.name == 'falaise':

                if TRIGGERS['cliff'] == 3:
                    self.target.current_map.displayDialog('Nod_Nel_Followers')
                    TRIGGERS['cliff'] = 4

                if TRIGGERS['cliff'] == 2:
                    for npc in self.target.current_map.npcs:
                        self.target.current_map.npcs[npc].do(
                            cocos.actions.interval_actions.MoveBy(
                                (0, 32 * 14 + 32 * random.randint(-2, 2)),
                                random.randint(4, 5)))
                    TRIGGERS['cliff'] = 3

                if TRIGGERS['cliff'] == 1:
                    self.target.current_map.displayDialog('Nod_Nel_G')
                    TRIGGERS['cliff'] = 2

            if self.target.current_map.name == 'forest':
                if TRIGGERS['forest'] == 1:
                    self.target.current_map.displayDialog('Nod_Nel_Dude')
                    TRIGGERS['forest'] = 2

            if TRIGGERS['found_nel'] and TRIGGERS['village_state'] == 1:
                TRIGGERS['village_state'] = 2
                self.target.current_map.char_layer.remove(
                    self.target.current_map.npcs['nel11'])
                self.target.current_map.npcs.pop('nel11')
                self.target.current_map.npcs['villagera4'].do(
                    cocos.actions.interval_actions.MoveBy((-1000, 0), 5))

            if TRIGGERS[
                    'village_state'] == 3 and self.target.current_map.name == 'inside_ceremony_hall':
                thewise = Character('n_the_wise', (0, 0))
                self.target.current_map.placeCharacter(thewise, (13, 2))
                thewise.do(cocos.actions.interval_actions.MoveBy((0, 256), 3))
                self.target.current_map.displayDialog('N_friends_Wise_A')
                TRIGGERS['village_state'] = 4

            if TRIGGERS['village_state'] == 10:
                self.target.current_map.displayDialog('Nod_Nel_D')
                TRIGGERS['village_state'] = 11

            if TRIGGERS['village_state'] == 9:
                self.target.current_map = MAPS['village3']
                self.target.current_map.spawnPlayer(self.target, (6, 9))
                TRIGGERS['village_state'] = 10

            if TRIGGERS['village_state'] == 8:
                self.target.current_map.displayDialog('Ellipse')
                TRIGGERS['village_state'] = 9

            if TRIGGERS['village_state'] == 7:
                self.target.current_map = MAPS['inside_house_nod']
                self.target.current_map.spawnPlayer(self.target, (5, 8))
                TRIGGERS['village_state'] = 8

            if TRIGGERS['village_state'] == 6:
                self.target.current_map.displayDialog('Nod_Nel_C')
                TRIGGERS['village_state'] = 7

            if TRIGGERS['village_state'] == 5:
                self.target.current_map = MAPS['village2']
                self.target.current_map.spawnPlayer(self.target, (24, 16))
                TRIGGERS['village_state'] = 6

            if TRIGGERS[
                    'village_state'] == 4 and self.target.current_map.name == 'village':
                self.target.current_map.displayDialog('Nod_Nel_B')
                TRIGGERS['village_state'] = 5

            for npc in self.target.current_map.npcs:
                if player_rect.intersects(
                        self.target.current_map.npcs[npc].get_rect()):
                    self.target.velocity = (0, 0)
                    self.target.in_dialog = True

                    if TRIGGERS['village_state'] == 1 and not TRIGGERS[
                            'found_nel']:
                        print 'Name', self.target.current_map.npcs[npc].name
                        if self.target.current_map.npcs[npc].name == 'nel11':
                            self.target.current_map.displayDialog('Nod_Nel_A')
                            TRIGGERS['found_nel'] = True
                        else:
                            self.target.current_map.displayDialog(
                                'Villageois_A')
                    elif TRIGGERS['village_state'] == 2:
                        if self.target.current_map.name == 'inside_ceremony_hall':
                            self.target.current_map.displayDialog(
                                'N_friends_A')
                            TRIGGERS['village_state'] = 3
                        else:
                            self.target.current_map.displayDialog(
                                'Villageois_B')

            for item in self.target.current_map.items:
                if player_rect.intersects(
                        self.target.current_map.items[item].get_rect()):
                    print "ITEMY!"

        super(MoveCharacter, self).step(dt)
Пример #7
0
    def step(self, dt):

        if self.target.current_map.timer < 2.0:
            self.target.visible = False
            self.target.current_map.timer += dt
            return
        else:
            self.target.visible = True

        # handle input and move the character
        if self.target.current_map.dialog_layer.visible == True:
            return
        self.target.velocity = ((KEYBOARD[key.RIGHT] - KEYBOARD[key.LEFT]) * 150,(KEYBOARD[key.UP] - KEYBOARD[key.DOWN]) * 150 )
        if self.target.current_map is not None:

            x0 = self.target.position[0]
            y0 = self.target.position[1]

            x = self.target.position[0] + self.target.velocity[0]*dt
            y = self.target.position[1] + self.target.velocity[1]*dt

            #rect = cocos.rect.Rect(x-12, y, 24, 16)
            rect_x = cocos.rect.Rect(x-12, y0, 24,16)
            rect_y = cocos.rect.Rect(x0-12, y, 24,16)

            for i in range(int(x/TILE_SIZE)-1,int(x/TILE_SIZE)+2):
                for j in range(int(y/TILE_SIZE)-1, int(y/TILE_SIZE)+2):
                    cell = self.target.current_map.map_layer.get_cell(i,j)
                    cell2 = self.target.current_map.map_layer2.get_cell(i,j)

                    if cell is not None:
                        if cell.intersects(rect_x):
                            if cell is not None and 'passable' in cell and cell['passable'] == 'True':
                                if cell2 is not None and 'passable' in cell2 and cell2['passable'] == 'True':
                                    pass
                                else:
                                    self.target.velocity = (0,self.target.velocity[1])
                            else:
                                self.target.velocity = (0,self.target.velocity[1])
                        
                        if cell.intersects(rect_y):
                            if cell is not None and 'passable' in cell and cell['passable'] == 'True':
                                if cell2 is not None and 'passable' in cell2 and cell2['passable'] == 'True':
                                    pass
                                else:
                                    self.target.velocity = (self.target.velocity[0],0)
                            else:
                                self.target.velocity = (self.target.velocity[0],0)

            if self.target.velocity != (0,0):
                self.target.map_position = [int(self.target.position[0]) / TILE_SIZE, int(self.target.position[1]) / TILE_SIZE]
                self.target.current_map.scroller.set_focus(self.target.position[0], self.target.position[1])
                self.target.battle_timer += dt

                cell = self.target.current_map.map_layer2.get_cell(self.target.map_position[0],self.target.map_position[1])
                if 'door' in cell:
                    self.target.current_map = MAPS[cell['door_map']]
                    dest = cell['door_destination'].split()
                    dest = [int(dest[0]), int(dest[1])]
                    self.target.current_map.spawnPlayer(self.target, dest)
            #    
            # if next_cell is not None and 'passable' in next_cell and next_cell['passable'] == 'True':
            #     if 'door' in next_cell:
            #         self.target.current_map = MAPS[next_cell['door_map']]
            #         dest = next_cell['door_destination'].split()
            #         dest = [int(dest[0]), int(dest[1])]
            #         self.target.current_map.spawnPlayer(self.target, dest)
            #     self.target.map_position = [int(self.target.position[0]) / TILE_SIZE, int(self.target.position[1]) / TILE_SIZE]
            #     self.target.current_map.scroller.set_focus(self.target.position[0], self.target.position[1])
            #     self.target.battle_timer += dt
            # else:
            #     # Nice to have : slider le long des murs
            #     self.target.velocity = (0,0)


            player_rect = self.target.get_rect()
            player_rect.x += self.target.velocity[0]*dt
            player_rect.y += self.target.velocity[1]*dt

            if self.target.current_map.name == 'falaise':
                

                if TRIGGERS['cliff'] == 3:
                    self.target.current_map.displayDialog('Nod_Nel_Followers')
                    TRIGGERS['cliff'] = 4

                if TRIGGERS['cliff'] == 2:
                    for npc in self.target.current_map.npcs:
                        self.target.current_map.npcs[npc].do(cocos.actions.interval_actions.MoveBy((0,32*14+32*random.randint(-2,2)),random.randint(4,5)))
                    TRIGGERS['cliff'] = 3

                if TRIGGERS['cliff'] == 1:
                    self.target.current_map.displayDialog('Nod_Nel_G')
                    TRIGGERS['cliff'] = 2

            if self.target.current_map.name == 'forest':
                if TRIGGERS['forest'] == 1:
                    self.target.current_map.displayDialog('Nod_Nel_Dude')
                    TRIGGERS['forest'] = 2                



            if TRIGGERS['found_nel'] and TRIGGERS['village_state'] == 1:
                TRIGGERS['village_state'] = 2
                self.target.current_map.char_layer.remove(self.target.current_map.npcs['nel11'])
                self.target.current_map.npcs.pop('nel11')
                self.target.current_map.npcs['villagera4'].do(cocos.actions.interval_actions.MoveBy((-1000,0),5))

            if TRIGGERS['village_state'] == 3 and self.target.current_map.name == 'inside_ceremony_hall':
                thewise = Character('n_the_wise',(0,0))
                self.target.current_map.placeCharacter(thewise, (13,2))
                thewise.do(cocos.actions.interval_actions.MoveBy((0,256),3))
                self.target.current_map.displayDialog('N_friends_Wise_A')
                TRIGGERS['village_state'] = 4


            if TRIGGERS['village_state'] == 10:
                self.target.current_map.displayDialog('Nod_Nel_D')
                TRIGGERS['village_state'] = 11


            if TRIGGERS['village_state'] == 9:
                self.target.current_map = MAPS['village3']
                self.target.current_map.spawnPlayer(self.target, (6,9))
                TRIGGERS['village_state'] = 10                


            if TRIGGERS['village_state'] == 8:
                self.target.current_map.displayDialog('Ellipse')
                TRIGGERS['village_state'] = 9


            if TRIGGERS['village_state'] == 7:
                self.target.current_map = MAPS['inside_house_nod']
                self.target.current_map.spawnPlayer(self.target, (5,8))
                TRIGGERS['village_state'] = 8


            if TRIGGERS['village_state'] == 6:
                self.target.current_map.displayDialog('Nod_Nel_C')
                TRIGGERS['village_state'] = 7

            if TRIGGERS['village_state'] == 5:
                self.target.current_map = MAPS['village2']
                self.target.current_map.spawnPlayer(self.target, (24,16))
                TRIGGERS['village_state'] = 6

            if TRIGGERS['village_state'] == 4 and self.target.current_map.name == 'village':
                self.target.current_map.displayDialog('Nod_Nel_B')
                TRIGGERS['village_state'] = 5

            for npc in self.target.current_map.npcs:
                if player_rect.intersects(self.target.current_map.npcs[npc].get_rect()):
                    self.target.velocity = (0,0)
                    self.target.in_dialog = True

                    if TRIGGERS['village_state'] == 1 and not TRIGGERS['found_nel']:
                        print 'Name', self.target.current_map.npcs[npc].name
                        if self.target.current_map.npcs[npc].name == 'nel11':
                            self.target.current_map.displayDialog('Nod_Nel_A')
                            TRIGGERS['found_nel'] = True
                        else:
                            self.target.current_map.displayDialog('Villageois_A')
                    elif TRIGGERS['village_state'] == 2:
                        if self.target.current_map.name == 'inside_ceremony_hall':
                            self.target.current_map.displayDialog('N_friends_A')
                            TRIGGERS['village_state'] = 3
                        else:
                            self.target.current_map.displayDialog('Villageois_B')


            for item in self.target.current_map.items:
                if player_rect.intersects(self.target.current_map.items[item].get_rect()):
                    print "ITEMY!"

        super(MoveCharacter, self).step(dt)
Пример #8
0
    def __init__(self,zone,heros=[]):

        cocos.scene.Scene.__init__(self)

        self.layer = {}

        # battle zone

        self.layer['battle'] = cocos.layer.base_layers.Layer()
        self.add(self.layer['battle'],z=1)

        self.heros = heros

        pos = (700,180)
        first = True
        heros.reverse()
        for hero in heros:

            if first:
                first = False
                self.active = hero
                self.n_active = 0

            self.layer['battle'].add(hero)
            
            hero.position = pos
            hero.battle_mode()
            hero.hp = hero.hpl[0] # force l'animation de mort

            pos = pos[0] - 90, pos[1]

        heros.reverse()

        #Ennemies

        str_enemies = ZONE[zone][random.randint(0,len(ZONE[zone])-1)]
        enemies = []
        for index in range(len(str_enemies)):
            enemies.append(Character(str_enemies[index]))
        
        self.enemies = enemies

        pos = (200,250)
        mvt = None

        for enemy in enemies:
            dx, dy = 0,0

            for key,value in ENEMY_PROPERTY.items():
                if enemy.name in value:
                     if key == 'flying':
                        dy += 70
                        mvt = UpAndDown(10,10)

            enemy.position = pos[0] + dx, pos[1] + dy
            if mvt != None:
                enemy.do(mvt)
            mvt=None
            enemy.battle_mode()
            pos = pos[0] + enemy.image.width + 20 , pos[1]

            self.layer['battle'].add(enemy)

        # BG

        if zone == 'prairie':
            image = pyglet.image.load('img/GUI/bg_prairie.png')
            sprite = cocos.sprite.Sprite(image, anchor=(0,0))
            self.add(sprite,z=0)

        elif zone == 'forest':
            if 'kraken' in str_enemies:
                image = pyglet.image.load('img/GUI/bg_forest_water.png')
            else:
                image = pyglet.image.load('img/GUI/bg_forest.png')
            sprite = cocos.sprite.Sprite(image, anchor=(0,0))
            self.add(sprite,z=0)

        
        #arrow

        self.active_arrow = Sprite('img/GUI/arrow_current_character.png')
        self.add(self.active_arrow)
        self.active_arrow.visible = False

        self.next(0)

        # GUI

        self.layer['gui'] = guiFifhtLayer(self.heros,self.enemies)
        self.add(self.layer['gui'],z=2)

        self.bgm = pyglet.media.load("bgm/ld26battle.ogg", streaming=False)
        self.bgm_player = pyglet.media.Player()
        self.bgm_player.queue(self.bgm)
        self.bgm_player.eos_action = self.bgm_player.EOS_LOOP