Mirage Source
Ruby and Gosu Part 1 - Printable Version

+- Mirage Source (https://mirage-engine.uk/forums)
+-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61)
+--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18)
+---- Forum: Programming (https://mirage-engine.uk/forums/forumdisplay.php?fid=24)
+----- Forum: General (https://mirage-engine.uk/forums/forumdisplay.php?fid=27)
+----- Thread: Ruby and Gosu Part 1 (/showthread.php?tid=3089)



Ruby and Gosu Part 1 - skillzalot - 26-08-2009

This is part 1: How to set up and use gosu with ruby and making a window

1)download this file and install it a SciTE which comes with it http://rubyforge.org/frs/?group_id=167

2)Download gosu from http://gosu.googlecode.com/files/gosu-w ... 0.7.14.zip

3)Make a new directory where your going to make your thing and copy these for files into there. Fmod.dll, Gosu.For_1_8.so, Gosu.for_1_9.so, and gosu .rb.

4)Make a new .rb file with the following code

Code:
require 'gosu'

class GameWindow < Gosu::Window
  def initialize
    super(800, 600, false)
    self.caption = "Fareoke"
   end

end

window = GameWindow.new
window.show


you should save that as text.rb
now double click it if you did it correctly you should see a black windo with the title fareoke. Now to explain it a bit more in detail.


Code:
require 'gosu'

This tell ruby to find gosu and use it.


Code:
class GameWindow < Gosu::Window

This says you are going to be making a window using gosu.


Code:
def initialize
    super(800, 600, false)
    self.caption = "Fareoke"
   end

Def initialize starts the program. Super(800,600,False) Tells us how big the window will be.
self.caption = "Fareoke" Is the title of the window
End finishes the def.

Code:
end

that end finishes all our code
Code:
window = GameWindow.new
window.show

window = GameWindow.new that says we are making a new window
and window.show means show that window when all the other is finished.

Tune in next time to learn how to load and blit images