AndyObtiva / glimmer-dsl-libui

Glimmer DSL for LibUI - Prerequisite-Free Ruby Desktop Development Cross-Platform Native GUI Library - The Quickest Way From Zero To GUI - If You Liked Shoes, You'll Love Glimmer! - No need to pre-install any prerequisites. Just install the gem and have platform-independent GUI that just works on Mac, Windows, and Linux.
MIT License
497 stars 15 forks source link

Games for libui? Tetris? #2

Closed rubyFeedback closed 2 years ago

rubyFeedback commented 2 years ago

Heya Andy,

I saw that you have tetris for glimmer-dsl-swt here:

https://github.com/AndyObtiva/glimmer-dsl-swt/blob/v4.18.3.1/samples/elaborate/tetris.rb

I was wondering whether this could be added to libui too.

I think in the simplest way, we could simulate a tetris by having buttons placed in a grid; and then these buttons may have differential text (even if we may not be able to use colours; but perhaps we can use unattributed string for colours there). So the "tetris blocks" would then just be simulated via buttons. Of course I suppose we could use the drawing area too; you did the circle example, but I was mostly wondering for a minimal example. (Minimal so as to minimize time investment to it.)

Actually, I came from the point of view of "would it not be nice if there would be games in libui", and here I was thinking of simple games, such as tic tac toe, or snake (where the snake eats an apple and gets bigger on a 2D map).

At any rate, please feel free to ignore/disregard; it's more an idea of "when you have some time and are bored" then perhaps that could be added to glimmer-dsl-libui. Thank you for reading this suggestion either way!

AndyObtiva commented 2 years ago

Cool!

I got an initial version of Tetris working (without the scoreboard or menus): https://github.com/AndyObtiva/glimmer-dsl-libui/blob/28396dedb0d3ec4213ac94d20f922c36f13c11a6/examples/tetris.rb

Screen Shot 2021-11-03 at 1 26 02 PM

I added the games you mentioned to TODO.md (Tetris, Tic Tac Toe, and Snake)

I will close this issue once I have made releases with these games.

AndyObtiva commented 2 years ago

An improved version of Tetris has been released with a bevel-block 3D look:

3D look

AndyObtiva commented 2 years ago

A version just got released with a score board on top, including a next tetromino preview:

Tetris with Score Board

AndyObtiva commented 2 years ago

The Tetris example is done in the latest release. It now has option menus and a high score dialog.

Tetris High Score Dialog

kojix2 commented 2 years ago

Wow!

AndyObtiva commented 2 years ago

Tic Tac Toe has been implemented and released.

tic tac toe

o wins

x wins

draw

AndyObtiva commented 2 years ago

Snake has been implemented test-first following the MVP (Model / View / Presenter) architectural pattern and released in v0.2.22.

Snake Screenshot: Snake

Snake Game Over Screenshot: Snake Game Over

With that, the issue request is fully addressed.

Happy Glimmering!