Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8535499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:26:45+00:00 2026-06-11T10:26:45+00:00

I built a command line game in Ruby and now I’m trying to build

  • 0

I built a command line game in Ruby and now I’m trying to build a GUI for the game using Shoes. I spent the morning reading about Shoes, looking at some code samples, and writing a bit of code myself. It appears (I’m new to Shoes, so this could be totally wrong) that the Shoes code (for example, a shoes.rb file that you open with the Shoes application) has to contain all the Ruby code you want to run. All of the Ruby code will exist within that file.

The way I’m firing up this game is at the command line by passing command line arguments to play.rb (a Ruby script). Either run play.rb "command line game" or play.rb "shoes game" at the command line. If you run the latter, it will make a system call to open shoes.rb with the Shoes application. Within play.rb it will pass ShoesInterface to the players, rather than CommandLineInterface. Below is an example of how a player might be asked for a move:

In the human_player.rb file:

def make_move
    @interface.print("It's your turn to make a move.")
end

@interface will either be CommandLineInterface or ShoesInterface. The print method in CommandLineInterface is simply a puts statement. The print method in ShoesInterface should tell the Shoes GUI to display that text. I’m trying to re-use as much of my code as possible. Theoretically, regardless of how someone is playing the game (on the web, at the command line, through a GUI, etc.) it should use most of the same logic. The interfaces simply display messages and receive user input. They just do it in different ways.

The problem is that I don’t know how to connect my Shoes GUI to my existing Ruby code. Is anyone here proficient in Shoes? This might not be possible in Shoes…maybe I’ll have to use a different Ruby GUI, but I thought I’d ask before moving on to another one.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T10:26:46+00:00Added an answer on June 11, 2026 at 10:26 am

    What you can do, is to write a Shoes Widget that will respond to method print. Below is a very crude example of such a widget which will append a message from the edit line to its arbitrary display slot. Of course you can easily modify the Widget so that you can initialize it with a target slot for display etc but the idea stays the same.

    class Prompt < Shoes::Widget
     def initialize opts={}
      @top=opts[:top]
      @left=opts[:left]
      @width=opts[:width]
      @prom=flow :top=>@top, :left=>@left, :width=>@width do
       background red
      end
      end
     def print(msg)
      @prom.append do
       para msg
      end
     end
    end
    Shoes.app :title => "Test" do 
     @el=edit_line
     button "print"do
      @interface.print(@el.text)
     end
     @interface=prompt({:top=>50, :left=>20, :width=>100})
    end
    

    I hope that is what yo wanted.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to build my android project using ant in command line mode.
I have an application which is built from command line (ANT) using J2ME Polish.
I'm trying to use the post build command line to get my class library
I've build a command-line tool in Java, which I would now like to profile
Currently I am using a post-build event command line similar to this one: xcopy
I am using command line (ant) to create and build android projects . I
I just started trying to build simple GUIs because I've always used command-line script
In Delphi 2009, how can I build a project using command line. I tried
I'm using the devenv command line to build a quite large project. Sometimes it
I want to build the html version of my game from the command line

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.