Skip to content
This repository has been archived by the owner on Apr 13, 2022. It is now read-only.

Creating a window

D3nX edited this page Jul 3, 2018 · 5 revisions

Hey !

You just installed Ruby & Gosu and want to use Neogame ? Then you are at the right place !
So, let's get started. Once you've installed Ruby and Gosu, install Neogame like that : gem install Neogame. Then, create in the same folder a file that we gonna to call, hum... Let say main.rb !
Finally, open the file main.rb using your favorite text editor. We can finally start coding !

First, we need to import Neogame, else we couldn't make our games with :

require 'neogame'

And include it like this :
include Neogame

After doing that, we gonna, to like in Gosu, create our game window class, which extend from Neogame::Window :
class Game < Neogame::Window

  def initialize
    super Settings.new(640, 480, false, "Hello World!")
  end

  def update

  end

  def draw

  end
end

So what do we done exactly ? First we extended from the Neogame::Window class, which contain everything the window needs for your games. After that, in the constructor "initialize", we passed to the super class the "Settings" of the windows (width, height, fullscreen, caption). And finally the update function is intended to use for make the game logic and the draw function is for drawing everything on the screen.

And finally use that line to run the game :
Game.new.run

That's it ! You make your very first progam with Neogame, now let's go to the next : Drawing sprites !

Clone this wiki locally