Sunday, December 08, 2024

Montreal.rb Hack Night Solutions for Hunt The Wampus

In November and December of 2024, Montreal.rb hosted 2 Ruby Hack Night meetups about building the historic computer game, Hunt The Wampus, which was a text-based adventure game developed by Gregory Yob in 1973.

The Hack Night details are at this GitHub repository (you can look at Git branches for solutions):

https://github.com/AndyObtiva/hunt_the_wampus


I heard great feedback about the event from attendees of the Ruby meetup:

- "This was very interesting!'

- "It is great to change things up with a Hack Night instead of just having talks at every Ruby meetup!"

- "It is very useful that this Hack Night gives people the option to build an app as a CLI, TUI, GUI, Web Backend, or Web Frontend. Even if people made one of those choices during the Hack Night, they can later build other versions of the app after the Ruby meetup."

Here are demos of a couple of Ruby implementations of the game that were done in under 2 hours.

Ruby GUI desktop app built using Glimmer DSL for LibUI:

https://github.com/AndyObtiva/hunt_the_wampus/tree/solution-gui-glimmer-dsl-libui-text


Ruby on Rails Web Frontend SPA built with Glimmer DSL for Web and Opal:


Building a lo-fi prototype is a common Game Development practice. That's why the GUI version of Hunt the Wampus intentionally did not render graphics, yet text only, for representing the various objects and senses of the game. It can certainly be upgraded in the future with graphics if desired (Glimmer DSL for LibUI supports canvas graphics with the area control).

It was pretty amazing to be able to take the Model layer Ruby code that worked in CRuby and reuse it successfully in Opal Ruby (Ruby 3.1 to JavaScript transpiler). That clearly demonstrated the superiority of the Frontend Ruby approach in Rails applications over JavaScript libraries like React or Vue because JavaScript does not support being able to reuse Ruby code directly in the Frontend when needed. Only Frontend Ruby (e.g. Opal or WASM) supports that, which saved a lot of development time for building Hunt The Wampus as a Web Frontend in a Rails web app given that the Model layer was already complete from a previous Hack Night event.

Feel free to do the Hack Night exercises yourself by going through parts 1 and 2:

Happy learning!


No comments: