Module: Gosu

Defined in:
rdoc/gosu.rb

Defined Under Namespace

Classes: Channel, Color, Font, GLTexInfo, Image, Sample, Song, TextInput, Window

Constant Summary collapse

MAJOR_VERSION =

The first component of the version.

:an_integer
MINOR_VERSION =

The second component of the version.

:an_integer
POINT_VERSION =

The third component of the version.

:an_integer
VERSION =

A version string of the form “0.1.2”, “0.1.2.3” or “0.1.2pre4”.

:a_string
LICENSES =

A block of legal copy that your game is obliged to display somewhere.

:a_string
KB_0…KB_9 =
:an_integer
KB_A…KB_Z =
:an_integer
KB_APOSTROPHE =
:an_integer
KB_BACKSLASH =
:an_integer
KB_BACKSPACE =
:an_integer
KB_BACKTICK =
:an_integer
KB_COMMA =
:an_integer
KB_DELETE =
:an_integer
KB_DOWN =
:an_integer
KB_END =
:an_integer
KB_ENTER =

This is the key on the numpad.

:an_integer
KB_EQUALS =
:an_integer
KB_ESCAPE =
:an_integer
KB_F1…KB_F12 =
:an_integer
KB_HOME =
:an_integer
KB_INSERT =
:an_integer
KB_ISO =
:an_integer
KB_LEFT =
:an_integer
KB_LEFT_ALT =
:an_integer
KB_LEFT_BRACKET =
:an_integer
KB_LEFT_CONTROL =
:an_integer
KB_LEFT_META =
:an_integer
KB_LEFT_SHIFT =
:an_integer
KB_MINUS =
:an_integer
KB_NUMPAD_0…KB_NUMPAD_9 =
:an_integer
KB_NUMPAD_DELETE =
:an_integer
KB_NUMPAD_DIVIDE =
:an_integer
KB_NUMPAD_MINUS =
:an_integer
KB_NUMPAD_MULTIPLY =
:an_integer
KB_NUMPAD_PLUS =
:an_integer
KB_PAGE_DOWN =
:an_integer
KB_PAGE_UP =
:an_integer
KB_PERIOD =
:an_integer
KB_RETURN =

This is the key above the right shift key.

:an_integer
KB_RIGHT =
:an_integer
KB_RIGHT_ALT =
:an_integer
KB_RIGHT_BRACKET =
:an_integer
KB_RIGHT_CONTROL =
:an_integer
KB_RIGHT_META =
:an_integer
KB_RIGHT_SHIFT =
:an_integer
KB_SEMICOLON =
:an_integer
KB_SLASH =
:an_integer
KB_SPACE =
:an_integer
KB_TAB =
:an_integer
KB_UP =
:an_integer
MS_LEFT =
:an_integer
MS_MIDDLE =
:an_integer
MS_RIGHT =
:an_integer
MS_WHEEL_DOWN =
:an_integer
MS_WHEEL_UP =
:an_integer
MS_OTHER_0…MS_OTHER_7 =
:an_integer
GP_BUTTON_0…GP_BUTTON_15 =
:an_integer
GP_DOWN =
:an_integer
GP_LEFT =
:an_integer
GP_RIGHT =
:an_integer
GP_UP =
:an_integer
GP_0_BUTTON_0…GP_3_BUTTON_15 =
:an_integer
GP_0_DOWN…GP_3_DOWN =
:an_integer
GP_0_LEFT…GP_3_LEFT =
:an_integer
GP_0_RIGHT…GP_3_RIGHT =
:an_integer
GP_0_UP…GP_3_UP =
:an_integer

Drawing primitives collapse

Manipulating the current drawing context collapse

Class Method Summary collapse

Class Method Details

.angle(x1, y1, x2, y2) ⇒ Float


1221
# File 'rdoc/gosu.rb', line 1221

def angle(x1, y1, x2, y2); end

.angle_diff(angle1, angle2) ⇒ Float


1227
# File 'rdoc/gosu.rb', line 1227

def angle_diff(angle1, angle2); end

.available_height(window = nil) ⇒ Integer

All windows larger than this size will automatically be shrunk to fit.


1269
# File 'rdoc/gosu.rb', line 1269

def available_height(window = nil); end

.available_width(window = nil) ⇒ Integer

All windows larger than this size will automatically be shrunk to fit.


1265
# File 'rdoc/gosu.rb', line 1265

def available_width(window = nil); end

.button_down?(id) ⇒ true, false

Returns whether the button `id` is currently pressed. Button states are updated once per tick, so repeated calls during the same tick will always yield the same result.


929
# File 'rdoc/gosu.rb', line 929

def button_down?(id); end

.button_id_to_char(id) ⇒ String?

Note:

For real text input, look at TextInput instead.

Returns the character a button usually produces, if any.


1184
# File 'rdoc/gosu.rb', line 1184

def self.button_id_to_char(id); end

.char_to_button_id(char) ⇒ Integer?

Returns the button that usually produces a character, if any.


1195
# File 'rdoc/gosu.rb', line 1195

def self.char_to_button_id(char); end

.clip_to(x, y, w, h) { ... } ⇒ void

This method returns an undefined value.

Masks the drawing area inside the block.

Yields:

  • rendering code.

See Also:


1061
# File 'rdoc/gosu.rb', line 1061

def clip_to(x, y, w, h); end

.default_font_nameString

Returns the name of a neutral font that is available on the current platform.


1251
# File 'rdoc/gosu.rb', line 1251

def default_font_name(); end

.distance(x1, y1, x2, y2) ⇒ Float


1235
# File 'rdoc/gosu.rb', line 1235

def distance(x1, y1, x2, y2); end

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

Note:

OpenGL lines are not reliable at all and may have a missing pixel at the start or end point. Relying on your machine's behavior can only end in tears. Recommended for debugging purposes only.

This method returns an undefined value.

Draws a line from one point to another—inconsistently.


952
# File 'rdoc/gosu.rb', line 952

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) ⇒ void

This method returns an undefined value.

Draws a quad (actually two triangles).


1022
# File 'rdoc/gosu.rb', line 1022

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

.draw_rect(x, y, width, height, c, z = 0, mode = :default) ⇒ void

This method returns an undefined value.

Draws a rectangle (actually a quad, or two triangles).


995
# File 'rdoc/gosu.rb', line 995

def draw_rect(x, y, width, height, c, z=0, mode=:default); end

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

This method returns an undefined value.

Draws a triangle.


975
# File 'rdoc/gosu.rb', line 975

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

.flushvoid

This method returns an undefined value.

Flushes all drawing operations to OpenGL so that Z-ordering can start anew. This is useful for drawing multiple layers that may not have knowledge of each other's Z-ordering, e.g., drawing a HUD on top of the game world or ensuring that a custom cursor is always drawn above everything else.


1031
# File 'rdoc/gosu.rb', line 1031

def flush; end

.fpsInteger


1245
# File 'rdoc/gosu.rb', line 1245

def fps(); end

.gl(z = nil) { ... } ⇒ void

Note:

Gosu does not provide access to the underlying OpenGL APIs. A gem like ruby-opengl is required to use custom OpenGL drawing code.

Note:

Gosu rendering functions MUST NOT be used within the block, and gl MUST be used only within the call tree of Gosu::Window#draw.

This method returns an undefined value.

Runs the block in a clean OpenGL environment.

If a Z-order is given, the block will be scheduled to run between Gosu drawing operations as normal; otherwise, all prior drawing operations will be flushed and the block will be executed immediately.

Yields:

  • OpenGL code.

See Also:


1048
# File 'rdoc/gosu.rb', line 1048

def gl(z=nil); end

.languageString

Returns the language code for the user's preferred language. Expect return values such as 'en_US', 'de_DE.UTF-8', 'ja', 'zh-Hans', etc. You can rely only the first two letters being a language abbreviation.


1277
# File 'rdoc/gosu.rb', line 1277

def language(); end

.millisecondsInteger

Note:

For long-running games, this counter will eventually wrap around to 0 again.

Returns the number of milliseconds elapsed.


1241
# File 'rdoc/gosu.rb', line 1241

def milliseconds(); end

.offset_x(theta, r) ⇒ Float


1207
# File 'rdoc/gosu.rb', line 1207

def offset_x(theta, r); end

.offset_y(theta, r) ⇒ Float


1213
# File 'rdoc/gosu.rb', line 1213

def offset_y(theta, r); end

.random(min, max) ⇒ Float


1201
# File 'rdoc/gosu.rb', line 1201

def random(min, max); end

.record(width, height) { ... } ⇒ Gosu::Image

Note:

Because the returned object is not backed by a bitmap texture, there are restrictions on how it can be used. For example, you can not use any color other than Gosu::Color#WHITE when drawing the image.

Note:

The width and height of the returned image will be the values you passed to record, regardless of the area you draw on.

Records all drawing operations inside the block as a macro (a special Image) that can be reused later on. This is useful for rendering larger groups of images (e.g. a tiled map in a game) and then rendering this group with a single call to Gosu::Image#draw.

It is important to pass accurate values if you plan on calling Gosu::Image#draw_as_quad or Gosu::Image#draw_rot on the result later.

Yields:

  • rendering code.

See Also:


1079
# File 'rdoc/gosu.rb', line 1079

def record(width, height); end

.render(width, height) { ... } ⇒ Gosu::Image

Records all drawing operations inside the block and returns the result as a new Image.

Yields:

  • rendering code.

See Also:


1093
# File 'rdoc/gosu.rb', line 1093

def render(width, height); end

.rotate(angle, around_x = 0, around_y = 0) { ... } ⇒ void

This method returns an undefined value.

Rotates all drawing operations inside the block.

Yields:

  • rendering code.

See Also:


1108
# File 'rdoc/gosu.rb', line 1108

def rotate(angle, around_x=0, around_y=0); end

.scale(scale_x, scale_y = scale_x) ⇒ void .scale(scale_x, scale_y, around_x, around_y) ⇒ void

This method returns an undefined value.

Scales all drawing operations inside the block.

Yields:

  • rendering code.

See Also:


1127
# File 'rdoc/gosu.rb', line 1127

def scale(scale_x, scale_y, around_x, around_y); end

.screen_height(window = nil) ⇒ Integer


1260
# File 'rdoc/gosu.rb', line 1260

def screen_height(window = nil); end

.screen_width(window = nil) ⇒ Integer


1256
# File 'rdoc/gosu.rb', line 1256

def screen_width(window = nil); end

.transform(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15) { ... } ⇒ void

This method returns an undefined value.

Applies a free-form matrix transformation to everything drawn in the block.

Yields:

  • rendering code.

See Also:


1169
# File 'rdoc/gosu.rb', line 1169

def transform(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15); end

.translate(x, y) { ... } ⇒ void

This method returns an undefined value.

Offsets all drawing operations inside the block.

Yields:

  • rendering code.

See Also:


1141
# File 'rdoc/gosu.rb', line 1141

def translate(x, y); end