Saturday, January 23, 2021

Glimmer Tetris Cont'd: Scoring, Leveling, and Preview

The Glimmer Tetris game that took one day to develop just got improved with Scoring, Leveling, and Next Preview with one more day, thanks to Glimmer DSL for SWT's incredibly malleable architecture and extensive feature set. 

Seeing is believing!


One thing that is noteworthy is the idea of mapping Tetromino Blocks to Playfield Model Blocks, which are in turn data-bound to View Blocks with regards to Color. So, whenever a Tetromino moves, it changes the colors of Playfield Model Blocks (previous and new position), which propogate changes to the GUI automatically, thanks to the intelligent bidirectional data-binding support in Glimmer DSL for SWT. This enables writing much more decoupled logic code that is easy to maintain given it is not directly bound to the View, which is only connected to the Model declaratively (no imperative render logic).

Another thing that is noteworthy was how I very quickly built the Preview Next Tetromini feature by simply reusing the 'playfield' custom widget but with much smaller dimensions (4x2). Otherwise, I reused the logic for placing a tetromino on it (via mapping to its blocks as explained above), and voila! The power of modular componentization, a great asset of Object Oriented Programming applied to rapid GUI development.

It is included in the new Glimmer DSL for SWT v4.18.2.4

Happy Glimmering!

Otherwise, check out the next article in the Tetris saga about adding a Tetris Menu Bar.

This article is part of the Tetris Saga

No comments: