Main class that serves as the foundation of a standard Gosu application. Manages initialization of all of Gosu‘s core components and provides timing functionality.

Note that all coordinates, even the mouse position, are in client coordinates relative to the window. This means that the mouse position can be negative or larger than the window size.

Note that you should really only use one instance of this class at the same time. This may or may not change later.

Right now, having two or more windows and loading samples or songs on both of them will result in an exception.

Attributes

NameRead/write?
caption RW
height R
mouse_x RW
mouse_y RW
text_input RW
update_interval R
width R

Public Class Methods


button_id_to_char (id)

DEPRECATED: Returns the character a button usually produces, or nil. Please use TextInput instead.

# File reference/gosu.rb, line 424
    def self.button_id_to_char(id); end

char_to_button_id (char)

DEPRECATED: Returns the button that has to be pressed to produce the given character, or nil. Please use TextInput instead.

# File reference/gosu.rb, line 428
    def self.char_to_button_id(char); end

new (width, height, fullscreen, update_interval = 16.666666)

update_interval:Interval in milliseconds between two calls

to the update member function. The default means the game will run at 60 FPS, which is ideal on standard 60 Hz TFT screens.

# File reference/gosu.rb, line 377
    def initialize(width, height, fullscreen, update_interval = 16.666666); end

Public Instance Methods


button_down (id)

Called before update when the user pressed a button while the window had the focus.

# File reference/gosu.rb, line 406
    def button_down(id); end

button_down? (id)

Returns true if a button is currently pressed. Updated every tick.

# File reference/gosu.rb, line 421
    def button_down?(id); end

button_up (id)

Same as buttonDown. Called then the user released a button.

# File reference/gosu.rb, line 408
    def button_up(id); end

clip_to (x, y, w, h, &drawing_code)

Limits the drawing area to a given rectangle while evaluating the code inside of the block.

# File reference/gosu.rb, line 434
    def clip_to(x, y, w, h, &drawing_code); end

close ()

Tells the window to end the current show loop as soon as possible.

# File reference/gosu.rb, line 383
    def close; end

draw ()

Called after every update and when the OS wants the window to repaint itself. Your application‘s rendering code goes here.

# File reference/gosu.rb, line 391
    def draw; end

draw_line (x1, y1, c1, x2, y2, c2, z=0, mode=:default)

Draws a line from one point to another (last pixel exclusive).

# File reference/gosu.rb, line 411
    def draw_line(x1, y1, c1, x2, y2, c2, z=0, mode=:default); end

draw_quad (x1, y1, c1, x2, y2, c2, x3, y3, c3, x4, y4, c4, z=0, mode=:default)

Draws a rectangle (two triangles) with given corners and corresponding colors. The points can be in clockwise order, or in a Z shape.

# File reference/gosu.rb, line 418
    def draw_quad(x1, y1, c1, x2, y2, c2, x3, y3, c3, x4, y4, c4, z=0, mode=:default); end

draw_triangle (x1, y1, c1, x2, y2, c2, x3, y3, c3, z=0, mode=:default)

# File reference/gosu.rb, line 413
    def draw_triangle(x1, y1, c1, x2, y2, c2, x3, y3, c3, z=0, mode=:default); end

gl (&custom_gl_code)

See examples/OpenGLIntegration.rb.

# File reference/gosu.rb, line 431
    def gl(&custom_gl_code); end

needs_redraw? ()

Can be overriden to give the game a chance to say no to being redrawn. This is not a definitive answer. The operating system can still cause redraws for one reason or another.

By default, the window is redrawn all the time (i.e. Window#needs_redraw? always returns true.)

# File reference/gosu.rb, line 399
    def needs_redraw?; end

set_mouse_position (x, y)

DEPRECATED.

# File reference/gosu.rb, line 402
    def set_mouse_position(x, y); end

show ()

Enters a modal loop where the Window is visible on screen and receives calls to draw, update etc.

# File reference/gosu.rb, line 380
    def show; end

update ()

Called every update_interval milliseconds while the window is being shown. Your application‘s main game logic goes here.

# File reference/gosu.rb, line 387
    def update; end