jeudi, mars 15, 2007

rumbling session

A small 'rumbling session' this lunchtime, after Cyril teased me about using apples to do "gravity experiments" on the DS -- "just like Isaac Newton, hmmm".

I managed to replace the 'decompress(VRAM, some_file_bin)' by tiles loader from my Sprite Editor, and started exploring the internals of Tetris Attack source code. I like how Sten Larsson did split his code between "PlayField" (that is basically how i would code the game in QuickBasic) and "FieldGraphics", which offers an abstract -- and adapted -- interface to push blocks on the screen, add effects, and the like.

Now i can enjoy a completely screwed "Tetris Attack" with random blocks of wood and apples as graphics :P

On discutait DS et sprites avec Cyril, et je lui explique que je voudrais faire quelques essais de gravité pour mes jeux DS, par exemple avec mes petites pommes -- "Comme Newton, hein?" qu'il rajoute.

Donc vous avez la un aperçu de la session de 'rumbling' de ce temps de midi, avec "TetattDS" qui ressemble de moins en moins à un jeu de Tetris depuis que j'ai intégré mon code du Sprite Editor DS pour récupérer mes pommes :P J'en ai aussi profité pour regarder un peu (et documenter en UML) la découpe du code de Sten. J'aime encore bien le partage entre les classes FieldGraphics (tout ce qui est dessin un peu bas niveau) et PlayField (grosso-modo, c'est l'algorithme de jeu comme je l'aurais écrit en BASIC si le jeu avait utilisé des caractères sur un fond tout noir -- sauf qu'on fait appel à FieldGraphics)

TetattDS sources show a good example of game-specific engine. On a sidescrolling platformer, i'd have avoid per-block state as much as i could, still tetattDS has "BaseBock *field[FIELD_WIDTH*FIELD_HEIGHT]". In other words, the whole grid contains pointers to instances of blocks or garbage blocks. Pretty odd.
Well, for me only, actually. Unlike blocks in e.g. SMB, here you need to 'stress()' 'pop()' and 'drop()' blocks individually, and you need to tell apart garbage block (unmovable) from regular blocks.
Yet another puzzle-specific thing is the effect handler. Anything that requires a fancy animation goes through a class that extends "effect" baseclass and that is registered in the EffectHandler. The EffectHandler is a singleton that will evaluate each effect, calling their individual 'tick()' and 'draw()' routines appropriatedly and collecting effects which duration is over. I claim this to be puzzle-specific because in a sidescroller, you'd have rather implemented such effect by transient Sprites among the character and foe sprites.

Unfortunately, that means i cannot just use it as such to implement falling apples (since they'll fall until they hit the ground, not simply for a fixed time interval.

Aucun commentaire: