Page 1 of 1

Create a Game in Ruby ~pt 1~ Requires the Gosu libary.

#1 Rickster0  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 16
  • View blog
  • Posts: 236
  • Joined: 08-July 08

Posted 05 October 2009 - 06:38 AM

Ok im going to create a series of tuts on how to create a Very simple game in Ruby.

Firstly, you'll need the Gosu Lib. found HERE!

after you have that done. Create a folder for the project. then extract the Gosu folder (somewhere thats not in the project folder) then go into the Lib folder of gosu. copy "gosu.for_1_8.so", "gosu.rb" and "fmod.dll" into your project folder.

now. open up Notepad(or a texteditor of your choice) and put this code in:
require 'gosu'

class GameWindow < Gosu::Window
  def initialize
	super(640, 480, false)
	self.caption = "Gosu Window"
  end

  def update
  end

  def draw
  end
end

window = Gamewindow.new
window.show


now save it as main.rb and run.

now i shall explain what all this does.

 require 'gosu'

this allows the ruby file to use Gosu's built in classes.

class GameWindow < Gosu::Window

creates a new class defined by the Gosu::Window class, allowing you to create a window.

 def initialize
	super(640, 480, false)
	self.caption = "Gosu Window"
  end


when the GameWindow is created, it sets up a new window of 640 width and 480 hight, with a caption of Gosu window.

window = Gamewindow.new
window.show

creates a new instance of the GameWindow class, then displays it on the screen.

if there are any problems feel free to ask.

the next part of this tut will show you how to create a sprite on the screen and move it using the arrow keys .. keep a look out :D

Is This A Good Question/Topic? 0
  • +

Replies To: Create a Game in Ruby ~pt 1~

#2 selavy_rrose  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 16-March 10

Posted 17 March 2010 - 04:57 AM

Yes, please, would be very helpful to me, as currently I don't know how to make keyboard name input, and mouse movement.
Was This Post Helpful? 0
  • +
  • -

#3 crummydo  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 223
  • Joined: 06-January 09

Posted 10 April 2010 - 02:26 PM

If anybody has tried this and found errors on running, check that line 16 reads

Window (with a capital W)

and not

Gamewindow.new


Ruby, like many languages, is case sensitive. But the system used to insert code changes it to a lower case. Not the contributors fault.

This post has been edited by crummydo: 10 April 2010 - 02:28 PM

Was This Post Helpful? 0
  • +
  • -

#4 Blackllama  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 22-June 10

Posted 26 June 2010 - 10:37 AM

This may end up being a stupid question, but how do you run it?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1