WONDERING HOW TO MAKE A CLI GAME A LITTLE MORE ~SNAZZY~?
Utilizing RubyGems for 2D Gaming
With my first project for Flatiron School coming up I was definitely feeling a little lost, how could I make a CLI (Command Line Interface) database application more interesting than just characters on the screen? With RubyGems, of course! But more specifically, the Ruby 2D gem!
But First of All…What is RubyGems???
Basically, a Ruby gem is an open source library of Ruby code. It means that programmers can utilize the code written in the gem without having to write it out themselves! Gems are great because programmers like to be efficient, so it makes sense that the unofficial slogan of software developers is DRY (Don’t Repeat Yourself).
And that brings us to…
THE RUBY 2D GEM!!!
What’s the big deal with Ruby 2D?
Ruby 2D enables programmers to create 2D games, visualizations, and applications with just a few lines of code! With Ruby 2D, you can create a game console, add music, add images, and even create animations in as little as 5 short lines of code!
Making Something Interesting with Ruby 2D
I’m going to walk you through one of the simpler things we can do with Ruby 2D, we’ll be creating a (rather colorful) triangle.
- First we’ll create a new Ruby script, ‘triangle.rb’ and write the following lines of code which will give us an empty window:
- To spruce it up a bit we’ll add a little more code to give our window a name and describe what our triangle should look like:
- After saving our script, we run it on the command line with the following code:
- Then we’ll end up with this lovely ombre triangle:
Kudo’s to you! You’ve dipped your toe into the waters of Ruby 2D!👏👏👏👏
Try changing the colors of the triangle or try something more complex like creating an animation and let me know how it goes!
Resources
To check out Ruby 2D for yourself: Ruby 2D
For more on CLI:
For more on RubyGems: