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 8035075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:12:26+00:00 2026-06-05T02:12:26+00:00

A rubygame tutorial has a basic screen creation section followed by an excersize to

  • 0

A rubygame tutorial has a basic screen creation section followed by an excersize to modify the code to allow passing command line arguments that define screen size. I was able to use google to cobble together something I thought would work:

#! /usr/bin/ruby -w

# require 'rubygame'

screenx = ""
screeny = ""

# Rubygame.init

ARGV.each do |a|
    if a.scan("x=")
            screenx = a["x="] = ""
    end
    if a.scan("y=")
            screeny = a["y="] = ""
    end
end

puts screenx
puts screeny

# screen = Rubygame::Screen.new [screenx, screeny]
# loop {}

Without the comments I get a huge mess of errors which I don’t understand and found very few results for any of them on Google.

With the comments I get different errors:
If I give it a nonsense argument, it outputs "String not matched"
If I give it a properly formatted request, I get "can’t modify frozen String"

I’m not sure this is even the best way to extract x and y values from arguments.

  • 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-05T02:12:28+00:00Added an answer on June 5, 2026 at 2:12 am

    Take a look at OptionParser:

    options = {}
    
    OptionParser.new do |opts|
      opts.on '-w', '--width WIDTH', 'Screen width' do |width|
        options[:width] = width
      end
    
      opts.on '-h', '--height HEIGHT', 'Screen height' do |height|
        options[:height] = height
      end
    end.parse!
    
    # options is now filled with values
    

    There are separate gems for this – I’m the author of one. However, since your game isn’t a full-blown command line application, I don’t think you really need an extra dependency.

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

Sidebar

Related Questions

I have an underlying ruby game-engine code and I want to use the web
I'm trying to use Rubygame to determine each of a string's character widths as
I'm playing around with Rubygame. I installed it with the Mac Pack, and now
I'm test SciTe editor, and Gosu for ruby game development. I decided to make
I'm looking for a good graphic framework to make a nice 2D game in
I've been learning about gems lately, and one error I get is: WARNING: Installing
I'm running Mac OS X 10.6.2 and I've got a strange problem with rake
I am building a very simple game with Ruby on Rails. Two players are
I'm running into an interesting issue with the relatively simple assignment below. Each of

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.