Bienvenue, Invité. Merci de vous connecter ou de vous inscrire. Avez-vous oublié d'activer ?

Voir les contributions

Cette section vous permet de consulter les contributions (messages, sujets et fichiers joints) d'un utilisateur. Vous ne pourrez voir que les contributions des zones auxquelles vous avez accès.


Sujets - mrpantalon

Pages: [1]
1
Général / Problème organisation d'un tileset
« le: Avril 30, 2012, 06:54:10 pm »
Salut,
ce code est censer gérer le découpage de mon tileset situer plus haut pour les jonction entre deux tiles différent, mais le problème c'est que dans la cas d'un coin par exemple le tiles deviendra bien un coin mais le tiles au dessus lui ce transformera en jonction vers le bas .

Voici mon code :
//type des variable
boost::multi_array<std::pair<unsigned char,unsigned short> ,2> tiles;
unsigned short _type;
//code
    _sprite.setTexture(*(Engine::Manager::TextureManager::getInstance()->getTexture(texture)));
    sf::IntRect a(16,48,32,32);

    //TILE HAUT
    if(tiles[0][1].first != _type and tiles[1][2].first == _type and tiles[2][1].first == _type and tiles[1][0].first == _type)
    {
        a.top = 32;
        a.left = 16;
    }
    //TILE BAS
    else if(tiles[1][2].first != _type and tiles[0][1].first == _type and tiles[2][1].first == _type and tiles[1][0].first == _type)
    {
        a.top = 64;
        a.left = 16;
    }
    //TILE DROIT
    else if(tiles[2][1].first != _type and tiles[1][0].first == _type and tiles[1][2].first == _type and tiles[0][1].first == _type)
    {
        a.top = 48;
        a.left = 32;
    }
    //TILE GAUCHE
    else if(tiles[1][0].first != _type and tiles[2][1].first == _type and tiles[1][2].first == _type and tiles[0][1].first == _type)
    {
        a.top = 48;
        a.left = 0;
    }
    //COIN HAUT GAUCHE
    else if(tiles[1][0].first != _type and tiles[0][1].first != _type and tiles[1][2].first == _type and tiles[2][1].first == _type)
    {
            a.top = 32;
            a.left = 0;
    }
    //COIN BAS GAUCHE
    else if(tiles[1][0].first != _type and tiles[1][2].first != _type and tiles[2][1].first == _type and tiles[0][1].first == _type)
    {
            a.top = 64;
            a.left = 0;
    }
    //COIN HAUT DROIT
    else if(tiles[0][1].first != _type and tiles[2][1].first != _type and tiles[1][2].first == _type and tiles[1][0].first == _type)
    {
            a.top = 32;
            a.left = 32;
    }
    //COIN BAS DROIT
    else if(tiles[2][1].first != _type and tiles[1][2].first != _type and tiles[1][0].first == _type and tiles[0][1].first == _type)
    {
        a.top = 64;
        a.left = 32;
    }
    else if(tiles[2][1].first != _type and tiles[1][2].first != _type and tiles[1][0].first != _type and tiles[0][1].first != _type)
    {
        a.top = 0;
        a.left = 0;
    }
    _sprite.setTextureRect(a);
 
Voici l'organisation de mes cartes:
//Meta.xml
<?xml version="1.0" encoding="utf-8"?>
<Game>
        <mapheight>32</mapheight>
        <mapwidth>32</mapwidth>
</Game>
<Tiles>
        <nbid>3</nbid>
        <0>Blank.png</0>
        <1>Herbe.png</1>
        <2>Terre.png</2>
</Tiles>
 
//map.map
1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;
1;1;1;1;2;2;1;1;1;1;1;1;1;2;2;2;2;2;1;1;1;1;1;1;1;1;1;1;1;1;1;1;
1;1;1;1;2;2;1;1;1;1;1;1;1;2;1;1;1;2;1;1;1;1;1;1;1;1;1;1;1;1;1;1;
1;1;1;1;1;1;1;1;1;1;1;1;1;2;1;1;1;2;1;1;1;1;1;1;1;1;1;1;1;1;1;1;
1;1;1;1;1;1;1;1;1;1;1;1;1;2;1;1;1;2;1;1;1;1;1;1;1;1;1;1;1;1;1;1;
1;1;1;1;1;1;1;1;1;1;1;1;1;2;2;2;2;2;1;1;1;1;1;1;1;1;1;1;1;1;1;1;
1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;
1;1;1;1;1;1;1;1;1;2;2;2;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;
1;1;1;1;1;1;1;1;1;2;1;2;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;
1;1;1;1;1;1;1;1;1;2;2;2;1;1;1;1;1;1;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