[Roi of the Suisse] Collines, nuages, trou du cul

Avatar de l’utilisateur
Vincent
Dompteur de lions
Messages : 367
Inscription : 25 Nov 2011, 13:10

[Roi of the Suisse] Collines, nuages, trou du cul

Messagepar Vincent » 27 Oct 2016, 13:54

Sympa ton code, tu as fait des efforts pour que ça soit bien lisible. :)

Désolé d'avance pour le gros paté, j'ai aussi du code pour que les tiles à côté des portes soient particuliers (spécifique à Wolfenstein).

Donc de mon côté, la fonction translateZoneId permet en quelque sorte de savoir dans quelle zone du chipset je me trouve.
Les zones 1,2 et 3, c'est pour l'eau.
Les zones 4,5 et 6, c'est des tiles animés.
La zone 7, c'est la partie autotile.
La zone 8, c'est la partie tile "simple" sans animation, sans autotile.

J'ai aussi du code pour gérer les tiles sur les bords de la map. Comme chaque tile est dépendante des tiles à côté, j'ai du code pour reconnaitre les tiles des bords.

Chaque tile a deux couches, la couche principale et la couche supérieure qui s'imprime par dessus.
Ca permet par exemple de faire des murs avec des décorations genre tableau, des fissures, des choses écrites.

Le generatateUniqueId me permet de générer un id unique pour chaque permutation de tile (si c'est un bord ou pas, l'identifiant de la couche principale et celle du dessus, la permutation entre les différentes alternatives de couches principales).

Code : Tout sélectionner

// Rpgmaker Wolf Tile typedef struct { int zone; int tileId; // Rpgmaker internal Id, used also in Wolf int tileIdGroup; // Tile Number used to identify which tile/tilegroup the tile belongs to int tileIdWithinGroup; // This id is to describe how the merge is done int tileSource; // Tile id of the picture to load int x,y; booleanint borderLeft[NBDIRCHIPSET]; booleanint borderRight[NBDIRCHIPSET]; int nextToADoor[NBDIRCHIPSET]; booleanint shadowed [NBDIRCHIPSET]; long unsigned int uniqueTile[NBDIRCHIPSET]; tileComposition * tc; booleanint wall; int tileUniqueness[NBDIRCHIPSET]; int tileIdDecoration; int uniqueDecorationId; } tileInfo; typedef enum { texture, decoration_tile, object_unpassable, object_passable, object_pickable, doors } tileType; std::map<int, tileInfo *> mapTI; std::map<int, fileChipset *> tilesPresent; int getTilePosition(tileInfo * ti) { return ti->y * mapWidth + ti->x; } void caseMergeZone(tileInfo * ti, int tileId) { int tileIdNoZone = tileId - 4000; // tileId = 4120, tileIdNoZone = 120; ti->tileIdGroup = (tileIdNoZone / 50); // tileIdGroup = (120 / 50) = 2 ti->tileIdWithinGroup = tileIdNoZone - (ti->tileIdGroup * 50); // tileIdWithinGroup = 120 - 2 * 50 = 20 ti->tileSource = 7 + ti->tileIdGroup; } void caseSimpleZone(tileInfo * ti, int tileId) { int tileIdNoZone = tileId - 5000; ti->tileIdGroup = tileIdNoZone; ti->tileSource = 7 + 12 + tileIdNoZone; ti->tileIdWithinGroup = 0; } int translateZoneId(int tileId) { // First zone : water if (tileId < 1000) { return 1; } // Water with border alternative if (tileId >= 1000 && tileId < 2000) { return 2; } // Deep water if (tileId >= 2000 && tileId < 3000) { return 3; } // Short tile animations if (tileId >= 3000 && tileId < 4000) { if (tileId >= 3000 && tileId < 3050) { // First tile anim return 4; } if (tileId >= 3050 && tileId < 3100) { // Second tile anim return 5; } if (tileId >= 3100 && tileId < 3150) { // Third tile anim return 6; } } if (tileId >= 4000 && tileId < 5000) { return 7; } if (tileId >= 5000) { return 8; } } tileInfo* fillTileInfo(int tileId) { tileInfo * ti = new tileInfo(); int zone = translateZoneId(tileId); ti->zone = zone; ti->tileId = tileId; ti->tileSource = zone; // this is true for first zones which do not work yet if (zone == 7) { caseMergeZone(ti, tileId); } else if (zone == 8) { caseSimpleZone(ti, tileId); } ti->wall = testWall(ti); return ti; } void generatateUniqueId(tileInfo * ti, int idDir) { int borderId = 0; if (ti->borderLeft[idDir]) { borderId++; } if (ti->borderRight[idDir]) { borderId += 2; } unsigned long int uniqueTileId = 0; unsigned long int uniqueDecorationId = 0; if (!ti->nextToADoor[idDir] || !testWall(ti)) { uniqueTileId += (ti->tileUniqueness[idDir]) & 0x0000000F; uniqueTileId += (ti->tileIdWithinGroup << 1 * HEXA) & 0x00000FF0; uniqueTileId += (ti->tileIdGroup << 3 * HEXA) & 0x0000F000; uniqueTileId += (ti->zone << 4 * HEXA) & 0x000F0000; uniqueTileId += (borderId << 5 * HEXA) & 0x00F00000; uniqueTileId += (ti->tileIdDecoration << 6 * HEXA) & 0xFF000000; } else { uniqueTileId += (11 << 4 * HEXA) & 0x000F0000; uniqueTileId += (ti->tileIdDecoration << 6 * HEXA) & 0xFF000000; } uniqueDecorationId += generateUniqueDecorationId(ti->tileUniqueness[idDir], ti->tileIdDecoration); ti->uniqueTile[idDir]=uniqueTileId; ti->uniqueDecorationId=uniqueDecorationId; } int generateUniqueDecorationId(int tileUniqueness, int tileIdDecoration) { unsigned long int uniqueDecorationId = 0; uniqueDecorationId += (tileUniqueness) & 0x0000000F; uniqueDecorationId += (10 << 4 * HEXA) & 0x000F0000; uniqueDecorationId += (tileIdDecoration << 6 * HEXA) & 0xFF000000; return uniqueDecorationId; } booleanint tileExist(int tilePosition, int decallagex, int decallagey) { booleanint isBorderLeft = false; booleanint isBorderRight = false; booleanint isBorderTop = false; booleanint isBorderBottom = false; if (tilePosition % mapWidth == 0) { isBorderLeft = true; } if ((tilePosition + 1) % mapWidth == 0) { isBorderRight = true; } if (tilePosition < mapWidth) { isBorderTop = true; } if (tilePosition >= mapWidth * (mapHeight - 1)) { isBorderBottom = true; } if (decallagex == -1) { if (isBorderLeft) { return false; } } else if (decallagex == 1) { if (isBorderRight) { return false; } }else if (decallagex == 0) { } else { QuitNbr("Function only works with x and y being -1,0 or 1 and x = ", decallagex); } if (decallagey == -1) { if (isBorderTop) { return false; } } else if (decallagey == 1) { if (isBorderBottom) { return false; } }else if (decallagey == 0) { } else { QuitNbr("Function only works with x and y being -1,0 or 1 and y = ", isBorderBottom); } return true; } int getDoorBottom(tileInfo * ti) { int tilePosition = getTilePosition(ti); tileInfo* tiBottom = NULL; if (tileExist(tilePosition, 0, 1)) { tiBottom = mapTI[tilePosition + mapWidth]; } if (tiBottom && testDoor(tiBottom)) { return tiBottom->tileIdDecoration; } else { return 0; } } int getDoorLeft(tileInfo * ti) { int tilePosition = getTilePosition(ti); tileInfo* tiLeft = NULL; if (tileExist(tilePosition, -1, 0)) { tiLeft = mapTI[tilePosition - 1]; } if (tiLeft && testDoor(tiLeft)) { return tiLeft->tileIdDecoration; } else { return 0; } } int getDoorUp(tileInfo * ti) { int tilePosition = getTilePosition(ti); tileInfo* tiTop = NULL; if (tileExist(tilePosition, 0, -1)) { tiTop = mapTI[tilePosition - mapWidth]; } if (tiTop && testDoor(tiTop)) { return tiTop->tileIdDecoration; } else { return 0; } } int getDoorRight(tileInfo * ti) { int tilePosition = getTilePosition(ti); tileInfo* tiRight = NULL; if (tileExist(tilePosition, 1, 0)) { tiRight = mapTI[tilePosition + 1]; } if (tiRight && testDoor(tiRight)) { return tiRight->tileIdDecoration; } else { return 0; } } booleanint testSameLeft(tileInfo * ti) { int tilePosition = getTilePosition(ti); tileInfo* tiLeft = NULL; if (tileExist(tilePosition, -1, 0)) { tiLeft = mapTI[tilePosition - 1]; } if (tiLeft && tiLeft->tileIdGroup == ti->tileIdGroup && tiLeft->zone == ti->zone) { return true; } else { return false; } } booleanint testSameRight(tileInfo * ti) { int tilePosition = getTilePosition(ti); tileInfo* tiRight = NULL; if (tileExist(tilePosition, 1, 0)) { tiRight = mapTI[tilePosition + 1]; } if (tiRight && tiRight->tileIdGroup == ti->tileIdGroup && tiRight->zone == ti->zone) { return true; } else { return false; } } booleanint testSameUp(tileInfo * ti) { int tilePosition = getTilePosition(ti); tileInfo* tiTop = NULL; if (tileExist(tilePosition, 0, -1)) { tiTop = mapTI[tilePosition - mapWidth]; } if (tiTop && tiTop->tileIdGroup == ti->tileIdGroup && tiTop->zone == ti->zone) { return true; } else { return false; } } booleanint testSameBottom(tileInfo * ti) { int tilePosition = getTilePosition(ti); tileInfo* tiBottom = NULL; if (tileExist(tilePosition, 0, 1)) { tiBottom = mapTI[tilePosition + mapWidth]; } if (tiBottom && tiBottom->tileIdGroup == ti->tileIdGroup && tiBottom->zone == ti->zone) { return true; } else { return false; } } booleanint testNoWallLeftBottom(int tilePosition) { tileInfo* tiLeftBottom = NULL; if (tileExist(tilePosition, -1, 1)) { tiLeftBottom = mapTI[tilePosition - 1 + mapWidth]; return !tiLeftBottom->wall; } return false; } booleanint testNoWallRightBottom(int tilePosition) { tileInfo* tiRightBottom = NULL; if (tileExist(tilePosition, 1, 1)) { tiRightBottom = mapTI[tilePosition + 1 + mapWidth]; return !tiRightBottom->wall; } return false; } booleanint testNoWallLeftUp(int tilePosition) { tileInfo* tiLeftUp = NULL; if (tileExist(tilePosition, -1, -1)) { tiLeftUp = mapTI[tilePosition - 1 - mapWidth]; return !tiLeftUp->wall; } return false; } booleanint testNoWallRightUp(int tilePosition) { tileInfo* tiRightUp = NULL; if (tileExist(tilePosition, 1, -1)) { tiRightUp = mapTI[tilePosition + 1 - mapWidth]; return !tiRightUp->wall; } return false; } void calculateTileSurroundings(tileInfo * ti) { int tilePosition = getTilePosition(ti); ti->borderLeft[0] = ti->borderRight[0] = ti->borderLeft[1] = ti->borderRight[1] = ti->borderLeft[2] = ti->borderRight[2] = ti->borderLeft[3] = ti->borderRight[3] = false; if (!testSameLeft(ti) || !testNoWallLeftBottom(tilePosition)) { ti->borderLeft[0] = true; } testSameRight(ti); testNoWallRightBottom(tilePosition); if (!testSameRight(ti) || !testNoWallRightBottom(tilePosition)) { ti->borderRight[0] = true; } if (!testSameUp(ti) || !testNoWallLeftUp(tilePosition)) { ti->borderLeft[1] = true; } if (!testSameBottom(ti) || !testNoWallLeftBottom(tilePosition)) { ti->borderRight[1] = true; } if (!testSameRight(ti) || !testNoWallRightUp(tilePosition)) { ti->borderLeft[2] = true; } if (!testSameLeft(ti) || !testNoWallLeftUp(tilePosition)) { ti->borderRight[2] = true; } if (!testSameBottom(ti) || !testNoWallRightBottom(tilePosition)) { ti->borderLeft[3] = true; } if (!testSameUp(ti) || !testNoWallRightUp(tilePosition)) { ti->borderRight[3] = true; } ti->nextToADoor[0] = getDoorBottom(ti); ti->nextToADoor[1] = getDoorLeft(ti); ti->nextToADoor[2] = getDoorUp(ti); ti->nextToADoor[3] = getDoorRight(ti); for (int idDirection = 0; idDirection <= NBDIRCHIPSET - 1; idDirection++) { generatateUniqueId(ti, idDirection); } } tileComposition * calculateTile(int tileIdWithinGroup) { short tileUpLeft = 0; short tileUpRight = 0; short tileBottomLeft = 0; short tileBottomRight = 0; switch(tileIdWithinGroup) { case 0: //00 -> Case milieu tileUpLeft = 5; tileUpRight = 5; tileBottomLeft = 5; tileBottomRight = 5; break; case 1: //01 -> Case milieu + haut gauche transparent tileUpLeft = 0; tileUpRight = 5; tileBottomLeft = 5; tileBottomRight = 5; break; case 2: //02 -> Case milieu + haut droite transparent tileUpLeft = 5; tileUpRight = 0; tileBottomLeft = 5; tileBottomRight = 5; break; case 3: //03 -> Tout bas Case milieu + tout haut transparent tileUpLeft = 0; tileUpRight = 0; tileBottomLeft = 5; tileBottomRight = 5; break; case 4: //04 -> Case milieu + bas droite transparent tileUpLeft = 5; tileUpRight = 5; tileBottomLeft = 5; tileBottomRight = 0; break; case 5: //05 -> Case milieu haut droite + case milieu bas gauche + reste transparent tileUpLeft = 0; tileUpRight = 5; tileBottomLeft = 5; tileBottomRight = 0; break; case 6: //06 -> Case milieu + haut droite et bas droite transparent tileUpLeft = 5; tileUpRight = 0; tileBottomLeft = 5; tileBottomRight = 0; break; case 7: //07 -> case milieu + haut gauche et droite et bas droite transparent tileUpLeft = 0; tileUpRight = 0; tileBottomLeft = 5; tileBottomRight = 0; break; case 8: //08 -> case milieu + bas gauche transparent tileUpLeft = 5; tileUpRight = 5; tileBottomLeft = 0; tileBottomRight = 5; break; case 9: //09 -> case milieu droite + tout gauche transparent tileUpLeft = 0; tileUpRight = 5; tileBottomLeft = 0; tileBottomRight = 5; break; case 10: //10-> case milieu + haut droite + bas gauche transparent tileUpLeft = 5; tileUpRight = 0; tileBottomLeft = 0; tileBottomRight = 5; break; case 11: //11-> case milieu en bas droite + reste transparent tileUpLeft = 0; tileUpRight = 0; tileBottomLeft = 0; tileBottomRight = 5; break; case 12: //12-> case milieu + bas transparent tileUpLeft = 5; tileUpRight = 5; tileBottomLeft = 0; tileBottomRight = 0; break; case 13: //13-> case milieu haut droite + reste transparent tileUpLeft = 0; tileUpRight = 5; tileBottomLeft = 0; tileBottomRight = 0; break; case 14: //14-> case milieu gauche haut + reste transparent tileUpLeft = 5; tileUpRight = 0; tileBottomLeft = 0; tileBottomRight = 0; break; case 15: //15-> tout transparent tileUpLeft = 0; tileUpRight = 0; tileBottomLeft = 0; tileBottomRight = 0; break; case 16: //16-> case gauche tileUpLeft = 4; tileUpRight = 4; tileBottomLeft = 4; tileBottomRight = 4; break; case 17: //17-> case gauche + haut droite tileUpLeft = 4; tileUpRight = 0; tileBottomLeft = 4; tileBottomRight = 4; break; case 18: //18-> case gauche + bas droite tileUpLeft = 4; tileUpRight = 4; tileBottomLeft = 4; tileBottomRight = 0; break; case 19: //18-> case gauche tout gauche + transparent tout droite tileUpLeft = 4; tileUpRight = 0; tileBottomLeft = 4; tileBottomRight = 0; break; case 20: //20-> case haut tileUpLeft = 8; tileUpRight = 8; tileBottomLeft = 8; tileBottomRight = 8; break; case 21: //21-> case haut + bas droite tileUpLeft = 8; tileUpRight = 8; tileBottomLeft = 8; tileBottomRight = 0; break; case 22: //22-> case haut + bas gauche tileUpLeft = 8; tileUpRight = 8; tileBottomLeft = 0; tileBottomRight = 8; break; case 23: //23-> case haut + tout bas transparent tileUpLeft = 8; tileUpRight = 8; tileBottomLeft = 0; tileBottomRight = 0; break; case 24: //24-> case droite tileUpLeft = 6; tileUpRight = 6; tileBottomLeft = 6; tileBottomRight = 6; break; case 25: //25-> case droite + bas gauche transparent tileUpLeft = 6; tileUpRight = 6; tileBottomLeft = 0; tileBottomRight = 6; break; case 26: //26-> case droite + haut gauche transparent tileUpLeft = 0; tileUpRight = 6; tileBottomLeft = 6; tileBottomRight = 6; break; case 27: //27-> case droite + gauche tileUpLeft = 0; tileUpRight = 6; tileBottomLeft = 0; tileBottomRight = 6; break; case 28: //28-> case bas tileUpLeft = 2; tileUpRight = 2; tileBottomLeft = 2; tileBottomRight = 2; break; case 29: //29-> case bas + haut gauche tileUpLeft = 0; tileUpRight = 2; tileBottomLeft = 2; tileBottomRight = 2; break; case 30: //30-> case bas + haut droite tileUpLeft = 2; tileUpRight = 0; tileBottomLeft = 2; tileBottomRight = 2; break; case 31: //31-> case bas + haut tileUpLeft = 0; tileUpRight = 0; tileBottomLeft = 2; tileBottomRight = 2; break; case 32: //32-> case gauche + case droite tileUpLeft = 4; tileUpRight = 6; tileBottomLeft = 4; tileBottomRight = 6; break; case 33: //33-> case haut tout haut case bas tout le bas tileUpLeft = 8; tileUpRight = 8; tileBottomLeft = 2; tileBottomRight = 2; break; case 34: //34-> case haut gauche tileUpLeft = 7; tileUpRight = 7; tileBottomLeft = 7; tileBottomRight = 7; break; case 35: //35-> case haut gauche sauf bas droite transparent tileUpLeft = 7; tileUpRight = 7; tileBottomLeft = 7; tileBottomRight = 0; break; case 36: //36-> case haut droite tileUpLeft = 9; tileUpRight = 9; tileBottomLeft = 9; tileBottomRight = 9; break; case 37: //37-> case haut droite + bas gauche transparent tileUpLeft = 9; tileUpRight = 9; tileBottomLeft = 0; tileBottomRight = 9; break; case 38: //38-> case bas droite tileUpLeft = 3; tileUpRight = 3; tileBottomLeft = 3; tileBottomRight = 3; break; case 39: //39-> case bas gauche + haut gauche transparent tileUpLeft = 0; tileUpRight = 3; tileBottomLeft = 3; tileBottomRight = 3; break; case 40: //40-> case bas gauche tileUpLeft = 1; tileUpRight = 1; tileBottomLeft = 1; tileBottomRight = 1; break; case 41: //41-> case bas gauche + haut droit transparent tileUpLeft = 1; tileUpRight = 0; tileBottomLeft = 1; tileBottomRight = 1; break; case 42: //42-> case haut gauche tout gauche, case haut droite tout droite tileUpLeft = 7; tileUpRight = 9; tileBottomLeft = 7; tileBottomRight = 9; break; case 43: //43-> case haut gauche tout haut, case bas gauche tout bas tileUpLeft = 7; tileUpRight = 7; tileBottomLeft = 1; tileBottomRight = 1; break; case 44: //44-> case bas gauche tout gauche, case bas droite tout droite tileUpLeft = 1; tileUpRight = 3; tileBottomLeft = 1; tileBottomRight = 3; break; case 45: //45-> case haut droite tout haut, case bas droite tout bas tileUpLeft = 9; tileUpRight = 9; tileBottomLeft = 3; tileBottomRight = 3; break; case 46: //46-> case haut droite + case haut gauche + case bas gauche + case bas droite tileUpLeft = 7; tileUpRight = 9; tileBottomLeft = 1; tileBottomRight = 3; break; default: QuitNbr("Fail to guess tile ti->tileIdWithinGroup ", tileIdWithinGroup); return NULL; break; } tileComposition * tc = new tileComposition(); tc->tileUpLeft = tileUpLeft; tc->tileUpRight = tileUpRight; tc->tileBottomLeft = tileBottomLeft; tc->tileBottomRight = tileBottomRight; return tc; }

Avatar de l’utilisateur
Roi of the Suisse
Dompteur de lions
Messages : 362
Inscription : 20 Août 2011, 00:33
Localisation : Rennes aussi

[Roi of the Suisse] Collines, nuages, trou du cul

Messagepar Roi of the Suisse » 27 Oct 2016, 22:35

Mmmmh je vois, tu énumères tous les cas possibles de manière exhaustive. C'est plus listeux et moins nesté :loupe:

Avatar de l’utilisateur
Vincent
Dompteur de lions
Messages : 367
Inscription : 25 Nov 2011, 13:10

[Roi of the Suisse] Collines, nuages, trou du cul

Messagepar Vincent » 14 Déc 2016, 13:43

(désolé pour la réponse ultra tardive)
Autant que possible, je supprime du nesting.
Le but est d'arriver au code le plus simple possible.

Quant au côté listeux, la partie qui traite de l'autotile est comme ça car à la base, j'ai décodé une à une les valeurs des tiles Rpgmaker.
Je devrais peut être le retravailler mais j'ai un peu la flemme. :p

Bien joué pour avoir posté ton projet en ligne, j'ai regardé rapidement. :)

Si tu es intéressé, j'ai redéveloppé aussi le système de dialogue de Rpgmaker :
Image

Qui aurait cru que c'était compliqué ?
Déjà la boîte de dialogue, il y a une partie pixels fixe (1pixel dans l'image de départ = 1 pixel à l'écran) (les coins de la boîte de dialogue sont une partie fixe) et une partie variable (1 pixel dans l'image de départ = 3 à 6 pixels dans la boîte de dialogue finale), ça permet de faire les fonds dégradés des boîtes de dialogue de RM.
Mine de rien, c'est génial, car potentiellement, tu peux faire des boîtes de dialogues de tailles variables.
Ensuite, les polices. Il y a une ombre projeté de chaque lettre.
Chaque pixel qui compose chaque lettre est coloré en fonction de l'image ressource.

Avatar de l’utilisateur
Roi of the Suisse
Dompteur de lions
Messages : 362
Inscription : 20 Août 2011, 00:33
Localisation : Rennes aussi

[Roi of the Suisse] Collines, nuages, trou du cul

Messagepar Roi of the Suisse » 06 Avr 2017, 15:43

Quelques nouveautés graphiques

Dépoussiérage de l'algue, du tonneau et de la hutte de la chamane :

Image

Image

ImageImage


Les femmes vikings :

Image


Le parquet de Zam ( Image ) dans le sous-sol du donjon 5 :

Image


Nouvelle apparence du donjon 4 :

Image


Nouvelle apparence du donjon 1 :

Image


Nouvelle apparence des salles d'énigmes hors donjon :

Image


Côté moteur java

Minimap dans le menu des quêtes :

Image


Transition par défilement entre deux maps adjacentes :

Image


Animations (pot cassé ici) et brouillard lumineux :

Image

Avatar de l’utilisateur
Giuliani
A sauté un trou
Messages : 49
Inscription : 11 Mars 2015, 22:42

[Roi of the Suisse] Collines, nuages, trou du cul

Messagepar Giuliani » 06 Avr 2017, 21:32

Très joli le rendu.


Revenir vers « Espaces personnels »

Qui est en ligne ?

Utilisateurs parcourant ce forum : Aucun utilisateur inscrit et 6 invités

cron