Forums Archived

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

Rubygame `rsdl X.rb` throws Bus Error?

Get help and support with Rubygame

Rubygame `rsdl X.rb` throws Bus Error?

Postby click170 » Fri Dec 17, 2010 11:47 pm

Hi,
I've installed the Rubygame Mac Pack, and am calling my sample script as `rsdl sample1.rb` and have removed the shebang from the beginning of sample1.rb, but I'm seeing a Bus Error when I try to run `rsdl sample1.rb`.
I've tried making the file executable, but there was no change.
I've made sure there is a 'meanie.png' file in the directory with the sample1.rb file, no change.


The exact output is
Code: Select all
$ rsdl sample1.rb
/Library/Ruby/Gems/1.8/gems/nice-ffi-0.4/lib/nice-ffi/library.rb:143: [BUG] Bus Error
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]

Abort trap


The sample script's contents are
Code: Select all
require "rubygems"
require "rubygame"

include Rubygame

@screen = Screen.open [ 640, 480]


# Defines a class for an example object in the game that will have a
# representation on screen ( a sprite)
class Meanie

  # Turn this object into a sprite
  include Sprites::Sprite

  def initialize
    # Invoking the base class constructor is important and yet easy to forget:
    super()

    # @image and @rect are expected by the Rubygame sprite code
    @image = Surface.load "meanie.png"
    @rect  = @image.make_rect

    @angle = 2*Math::PI * rand
  end

  # Animate this object.  "seconds_passed" contains the number of ( real-world)
  # seconds that have passed since the last time this object was updated and is
  # therefore useful for working out how far the object should move ( which
  # should be independent of the frame rate)
  def update  seconds_passed

    # This example makes the objects orbit around the center of the screen.
    # The objects make one orbit every 4 seconds
    @angle = ( @angle + 2*Math::PI / 4 * seconds_passed) % ( 2*Math::PI)

    @rect.topleft = [ 320 + 100 * Math.sin(@angle),
                      240 - 100 * Math.cos(@angle)]
  end

  def draw  on_surface
    @image.blit  on_surface, @rect
  end
end


@clock = Clock.new
@clock.target_framerate = 60

# Ask Clock.tick() to return ClockTicked objects instead of the number of
# milliseconds that have passed:
@clock.enable_tick_events

# Create a new group of sprites so that all sprites in the group may be updated
# or drawn with a single method invocation.
@sprites = Sprites::Group.new
Sprites::UpdateGroup.extend_object @sprites
3.times do @sprites << Meanie.new end

# Load a background image and copy it to the screen
@background = Surface.load "background.jpg"
@background.blit @screen, [ 0, 0]

@event_queue = EventQueue.new
@event_queue.enable_new_style_events

should_run = true
while should_run do

  seconds_passed = @clock.tick().seconds

  @event_queue.each do |event|
    case event
      when Events::QuitRequested, Events::KeyReleased
        should_run = false
    end
  end

  # "undraw" all of the sprites by drawing the background image at their
  # current location ( before their location has been changed by the animation)
  @sprites.undraw @screen, @background

  # Give all of the sprites an opportunity to move themselves to a new location
  @sprites.update  seconds_passed

  # Draw all of the sprites
  @sprites.draw @screen

  @screen.flip
end


The observant reader will notice that its the Sprites sample script from the Starting Simple page on the Rubygame wiki.
Any help is appreciated, thanks :)
click170
 
Posts: 3
Joined: Fri Dec 17, 2010 11:38 pm

Return to Help & Support

Who is online

Users browsing this forum: No registered users and 1 guest

cron