Tuesday, June 24, 2008

Let's >> scroll >> baby ...

edit: screentoaster, video.google.com ... all these are no longer operating and not covered by the wayback machine. Sorry for broken links

Hop. Un p'tit temps de midi et je rattaque le scrolling, maintenant capable de "suivre" véritablement Bilou (plutôt que de se contenter de mimer ces déplacements au risque de finir par le faire sortir de l'écran :P) Le plus délicat, c'est d'éviter un scrolling "par à-coups" comme on avait tendance à le voir dans les jeux Titus, ou (pire) dans le Game Maker de mon enfance :P

It's about time I focus on scrolling again, so that we can actually "track" Bilou's position. So far all it did was mimmic'ing Bilou's moves but as you hit ceilings and floors, it slowly gets off. I realise when playing games of my childhood that a smooth and smart scrolling is the key to a great platformer experience. 

I want to avoid "quantum leaps" that was typicall from Titus games and that sloppy "I'm following you at my speed don't move soo fast" scrolling coded in the Recreative Game Maker my Brother and I used for Badman series.  

J'ai eu droit à quelques effets marrant en débuggant (ou déboguant?), comme l'écran qui fait le point-fixe autour d'un moustique invisible tournant autour de Bilou (ça, ça fait mal aux yeux), d'où les dernières lignes) ... ou alors le scrolling qui fait des sauts de puces en arrière après avoir fait un pas de géant en avant ... Bref. Le dernier truc qui reste douteux, c'est le fait que l'écran scrolle presqu'immédiatement vers le haut dès que Bilou saute ... je suis pas fan (ça donne un peu le mal de mer), mais je ne vois pas trop comment l'éviter proprement.  

As usual, there has been some odd-and-funny bugs while working on it, such as the camera suddenly tracking "a bee that fly around Bilou" rather than tracking Bilou himself. The last 4 rows of code shown above are designed to avoid that : they prevent counter-centering moves from happening. Yet, it turns out that perfectly keeping Bilou in the center of the screen isn't so sexy. You quickly get sick when you jump often ... 

I dug for Commander Keen videos, where you can observe a surprising but efficient approach. The camera only keeps Keen in the center of the screen (vertically) when he's on the ground (not quite at the center, but almost. I'd say some 32 pixels lower than the centre). However, when Keen jumps, the camera remains at its current height, giving a better view of where you're going to land. The only exception is when Keen gets really close to the edges of the screen (some 8 pixels close from the top or 32 pixels close from the bottom). Only when Keen *lands* does the camera quickly bring him back at the center of the screen.

Si on compare, la politique dans Commander Keen est assez particulière. Tant que Keen est au sol, il est maintenu dans une zone proche du centre (pas exactement au centre, mais presque; je dirais à 32 pixels du centre au maximum), mais lorsqu'il saute, on ne scrollera verticalement que si Keen approche le bord haut (ou bas) de l'écran (je dirais de 8 pixels au moins, probablement plutôt 32 pour le bas), et ce n'est qu'au moment ou Keen "atterit" sur une plateforme que le scrolling vertical se recentre. Je trouve que c'est un assez bon choix en somme : celà permet de conserver le point de vue que le joueur avait au moment de prendre la décision de faire un saut, et donc de mieux gérer l'endroit où le personnage retombe, tout en ayant un bonne vue d'ensemble du niveau pendant que le personnage "marche", tout simplement.

2 comments:

Anonymous said...

avant de lire ta proposition, j'allais faire la même ;) sans les détails en pixel... et avec la possibilité de regarder sur ce qui arrive...

pourtant de moins en moins souvent dans les jeux... peut-être prcq devenu trop prévisible ?

PypeBros said...

wow. j'avais complètement zappé le fait que si Titus The Fox avait un scrolling si perturbant c'est entre-autres parce qu'Eric et ses comparses voulaient que le jeu puisse tourner sur 8086 avec un écran CGA ...

Heureusement qu'il y a le Pix'n'Love pour rétablir la vérité...