29.3.07

Z-sorting · Part 1

...un peu de technique pour changer.

Ces derniers jours, Adarias a commencé à plancher sur des animations de personnages en train de courir avec armes et boucliers en main. J'aime beaucoup les premiers essais (qui pourtant ne sont, parait-il, pas d'un réalisme exceptionnel) mais euh...j'ai été très surpris quand j'ai vu que tout était dans des cadres de 64*64 pixels !
Cette décision a je crois été prise il y a très longtemps et dans mon esprit, les persos et leurs animations tenaient dans du 48*48, comme les tiles de décor. J'ai lâché un superbe "Gloups" quand j'ai pris conscience que ce changement de taille allait foutre en l'air mon Z-Sorting (pour les néophytes, le Z-sorting c'est la gestion de la profondeur dans l'affichage. Cela sert à déterminer si un personnage doit être affiché au dessus ou au dessous d'un tile).
Après un petit tour sur le net, je n'ai pas trouvé d'article répondant précisément à mon problème (les solutions proposées sur le net ne couvrent pas le cas de map avec relief comme celles de Partisan). Je suis donc parti à la recherche d'une solution que j'ai fini par trouver à grand renfort de jus de tomate (si si. très important de boire du jus de tomate pour bien réfléchir).

Ma solution sur un petit schéma :
Les chiffres indiquent la profondeur des objets. Plus le nombre est élevé, plus l'objet/personnage est affiché haut. Par exemple , un objet de profondeur 5 recouvre un objet de profondeur 4.

C'est pourtant tout con non ? Je me demande pourquoi je n'ai pas toujours fait comme ça. J'ai testé le système sur une petite map avec un personnage contrôlable avec les flèches directionnelles et ça m'a l'air impeccable. Je posterai surement ce petit test interactif une fois que je l'aurai essayé sur une map à plusieurs étages (ce qui implique d'abord de paramétrer les données de mon tileset).

A bientôt (genre la semaine prochaine ?) pour la partie 2 ^^

...some coding stuff today.


During the last few days, Adarias has started working on animations of running characters with their weapons and shields. I dig the animations (which according to Pixelation and Adarias are not too realistic) but er....I was very surprised when I noticed that these animations where 64*64 pixels big !
We took this decision quite a while ago and I had forgotten it. I tought we were using 48*48 animations. I was quite near the heart attack when I understood that this would screw my Zsorting (if you don't know what it is, google it or give up reading this entry). I browsed the web in quest for a nice solution but I couldn't find one which would work in Partisan (most of the time because we are using maps with various altitude). I started searching for a personnal solution and I eventually found it, thanks to the tomato juice (yeah. Tomato juice is the key).
Here's my solution on a little schema :

The numbers refer to each object's depth. The higher the number is, the higher the object is. For example, something at 4.1 can cover something at 4.

That's very simple, isn't it ? I wonder why I did not think of it earlier. I have coded a small test map with a movable character over it and it works fine. I may post on this blog the "interactive test" when it is tested with a map with altitude variations but I set my tileset properties before the character can climb stuff...

Stay tuned for part 2 ^^

7 Commentaires:

Enregistrer un commentaire

<< Accueil