Forums Archived

The forums are being archived. See this topic for more information.

Rubygame - some problems

Get help and support with Rubygame

Rubygame - some problems

Postby Loaden » Sat Jan 15, 2011 12:15 pm

Haai

I just wanted to play with Rubygame. But it was not so easy like I'am imagined that.

At first my Ubuntu Hardy machine had problems with the Gem include path. Maybe that's because of the different Apt mirros. I solved the problem quick and dirty with this code:
Code: Select all
inc_dirs = {
   'rubygame' => '/usr/lib/ruby/gems/1.9.0/gems/rubygame-2.6.4/lib/',
   'nice-ffi' => '/usr/lib/ruby/gems/1.9.0/gems/nice-ffi-0.4/lib/',
   'ffi' => '/usr/lib/ruby/gems/1.9.0/gems/ffi-0.6.3/lib/',
   'ruby-sdl-ffi' => '/usr/lib/ruby/gems/1.9.0/gems/ruby-sdl-ffi-0.3/lib/',
}
inc_dirs.each do | name, path |
   puts 'Notice: Setting include path "'+name+''
   $:.unshift path
end

Do you know another way to fix the include problem global on my machine?
Back to my Rubygame test code:
Code: Select all
## Including Rubygame
require "rubygame"
include Rubygame

## Open Window with 640x480px
screen = Screen.open [640, 480]

## Window title
screen.title = 'Hello Rubygame World'

# Create a queue to receive events+
#  + events such as "the mouse has moved", "a key has been pressed" and so on
event_queue = EventQueue.new

# Use new style events so that this software will work with Rubygame 3.0
event_queue.enable_new_style_events

# Wait for an event
while event = event_queue.wait

  # Show the details of the event
  puts  event.inspect

  # Stop this program if the user closes the window
  break if event.is_a? Events::QuitRequested
end

If I start that code I get the following errors messages:
Code: Select all
/usr/lib/ruby/gems/1.9.0/gems/nice-ffi-0.4/lib/nice-ffi/library.rb:142: warning: shadowing outer local variable - args
/usr/lib/ruby/gems/1.9.0/gems/ruby-sdl-ffi-0.3/lib/ruby-sdl-ffi/sdl/audio.rb:47: warning: method redefined; discarding old callback=
/usr/lib/ruby/gems/1.9.0/gems/ruby-sdl-ffi-0.3/lib/ruby-sdl-ffi/sdl/audio.rb:52: warning: method redefined; discarding old callback
/usr/lib/ruby/gems/1.9.0/gems/nice-ffi-0.4/lib/nice-ffi/opaquestruct.rb:51: warning: instance variable @typed_pointer not initialized
/usr/lib/ruby/gems/1.9.0/gems/ruby-sdl-ffi-0.3/lib/ruby-sdl-ffi/sdl/rwops.rb:73: warning: method redefined; discarding old seek=
/usr/lib/ruby/gems/1.9.0/gems/ruby-sdl-ffi-0.3/lib/ruby-sdl-ffi/sdl/rwops.rb:78: warning: method redefined; discarding old seek
/usr/lib/ruby/gems/1.9.0/gems/ruby-sdl-ffi-0.3/lib/ruby-sdl-ffi/sdl/rwops.rb:82: warning: method redefined; discarding old read=
/usr/lib/ruby/gems/1.9.0/gems/ruby-sdl-ffi-0.3/lib/ruby-sdl-ffi/sdl/rwops.rb:87: warning: method redefined; discarding old read
/usr/lib/ruby/gems/1.9.0/gems/ruby-sdl-ffi-0.3/lib/ruby-sdl-ffi/sdl/rwops.rb:91: warning: method redefined; discarding old write=
/usr/lib/ruby/gems/1.9.0/gems/ruby-sdl-ffi-0.3/lib/ruby-sdl-ffi/sdl/rwops.rb:96: warning: method redefined; discarding old write
/usr/lib/ruby/gems/1.9.0/gems/ruby-sdl-ffi-0.3/lib/ruby-sdl-ffi/sdl/rwops.rb:100: warning: method redefined; discarding old close=
/usr/lib/ruby/gems/1.9.0/gems/ruby-sdl-ffi-0.3/lib/ruby-sdl-ffi/sdl/rwops.rb:105: warning: method redefined; discarding old close
/usr/lib/ruby/gems/1.9.0/gems/rubygame-2.6.4/lib/rubygame/clock.rb:388: warning: shadowing outer local variable - sum
/usr/lib/ruby/gems/1.9.0/gems/rubygame-2.6.4/lib/rubygame/named_resource.rb:190: warning: shadowing outer local variable - dir
Warning: Function 'SDL_gfxBlitRGBA' not found in [/usr/lib/libSDL_gfx.so]
Warning: Function 'SDL_gfxSetAlpha' not found in [/usr/lib/libSDL_gfx.so]
Warning: Function 'arcColor' not found in [/usr/lib/libSDL_gfx.so]
Warning: Function 'arcRGBA' not found in [/usr/lib/libSDL_gfx.so]
Warning: Function 'texturedPolygon' not found in [/usr/lib/libSDL_gfx.so]
Warning: Function 'filledPolygonColorMT' not found in [/usr/lib/libSDL_gfx.so]
Warning: Function 'filledPolygonRGBAMT' not found in [/usr/lib/libSDL_gfx.so]
Warning: Function 'texturedPolygonMT' not found in [/usr/lib/libSDL_gfx.so]
Warning: Function 'shrinkSurface' not found in [/usr/lib/libSDL_gfx.so]
Warning: Function 'rotateSurface90Degrees' not found in [/usr/lib/libSDL_gfx.so]
/usr/lib/ruby/gems/1.9.0/gems/nice-ffi-0.4/lib/nice-ffi/opaquestruct.rb:51: warning: instance variable @typed_pointer not initialized
/usr/lib/ruby/gems/1.9.0/gems/nice-ffi-0.4/lib/nice-ffi/opaquestruct.rb:51: warning: instance variable @typed_pointer not initialized
<dummy toplevel>: unexpected return

After that error output the "Game" is over (the application shutdown). I use SDL GFX version 1.2-4. I'am sure that version isn't oudatet and the warnings aren't the problem which stop working of Rubygame.

I hope somebody can help me. Thanks.

EDIT:
I forgot to point out which code snippet shutdown the application. It's this one:
Code: Select all
event = event_queue.wait
Last edited by Loaden on Sun Jan 16, 2011 1:34 pm, edited 2 times in total.
Loaden
 
Posts: 4
Joined: Sat Jan 15, 2011 11:40 am

Re: Rubygame - some problems

Postby sgrevan » Sun Jan 16, 2011 1:22 am

Hello,

The generally preferred way to install gems is to use rubygem instead of distribution-specific package managers.
Therefore, I strongly recommend to clean your setup by :
- uninstalling packages with apt,
- installing ruby/rubygem[s] (depending on your distribution's packages),
- gem install rubygame

Once you've done that, your code should run without any problem.
sgrevan
 
Posts: 6
Joined: Wed Jan 12, 2011 5:32 pm
Location: France

Re: Rubygame - some problems

Postby Loaden » Sun Jan 16, 2011 12:49 pm

Hi

Thanks for your answer.

Note that you can't install Gems via the preferred way with Rubygems on many Debian / Ubuntu machines. You get this message from your Gem:
Code: Select all
gem update --system is disabled on Debian. RubyGems can be updated using the official Debian repositories by aptitude or apt-get.

If you get this message you can solve your problem with Debgem. This service converts Gems in Apt packages.

I installed Rubygame an depencies with Rubygems. The problem was the Ruby include path (paths in $:) and that problem is fixed.

EDIT:
I read online that my ruby version 1.9.0 is buggy. I solved the problem with compiling and reinstalling ruby new from the source code. Also the load path is ok now. :)
Loaden
 
Posts: 4
Joined: Sat Jan 15, 2011 11:40 am


Return to Help & Support

Who is online

Users browsing this forum: No registered users and 2 guests

cron