Module: Rubygame

Defined in:
lib/rubygame/rect.rb,
lib/rubygame/ftor.rb,
lib/rubygame/clock.rb,
lib/rubygame/color.rb,
lib/rubygame/event.rb,
lib/rubygame/queue.rb,
lib/rubygame/sfont.rb,
lib/rubygame/events.rb,
lib/rubygame/shared.rb,
lib/rubygame/sprite.rb,
lib/rubygame/hotspot.rb,
lib/rubygame/mediabag.rb,
lib/rubygame/constants.rb,
lib/rubygame/event_hook.rb,
lib/rubygame/keyconstants.rb,
lib/rubygame/named_resource.rb,
lib/rubygame/color/models/hsl.rb,
lib/rubygame/color/models/hsv.rb,
lib/rubygame/color/models/rgb.rb,
lib/rubygame/color/models/base.rb,
lib/rubygame/color/palettes/css.rb,
lib/rubygame/color/palettes/x11.rb,
lib/rubygame/events/misc_events.rb,
lib/rubygame/events/clock_events.rb,
lib/rubygame/events/mouse_events.rb,
lib/rubygame/events/joystick_events.rb,
lib/rubygame/events/keyboard_events.rb,
ext/rubygame/rubygame_gl.c,
ext/rubygame/rubygame_gfx.c,
ext/rubygame/rubygame_ttf.c,
ext/rubygame/rubygame_main.c,
ext/rubygame/rubygame_clock.c,
ext/rubygame/rubygame_event.c,
ext/rubygame/rubygame_image.c,
ext/rubygame/rubygame_mixer.c,
ext/rubygame/rubygame_music.c,
ext/rubygame/rubygame_sound.c,
ext/rubygame/rubygame_event2.c,
ext/rubygame/rubygame_screen.c,
ext/rubygame/rubygame_shared.c,
ext/rubygame/rubygame_surface.c,
ext/rubygame/rubygame_joystick.c

Overview

– Rubygame – Ruby code and bindings to SDL to facilitate game creation Copyright © 2007 John Croisant

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++

Defined Under Namespace

Modules: Color, EventActions, EventTriggers, Events, GL, Hotspot, Key, MailQueue, Mixer, Mouse, NamedResource, Sprites Classes: ActiveEvent, Clock, Event, EventHandler, EventHook, EventQueue, ExposeEvent, Ftor, JoyAxisEvent, JoyBallEvent, JoyDownEvent, JoyHatEvent, JoyUpEvent, Joystick, KeyDownEvent, KeyUpEvent, MediaBag, MouseDownEvent, MouseMotionEvent, MouseUpEvent, Music, QuitEvent, Rect, ResizeEvent, SDLError, SFont, Screen, Sound, Surface, TTF

Constant Summary collapse

SDL_EVENTS =

List of all Rubygame hardware event classes. *Do not modify!*

[ActiveEvent, KeyDownEvent, KeyUpEvent,\
MouseMotionEvent,MouseDownEvent,MouseUpEvent,JoyAxisEvent,\
JoyBallEvent, JoyHatEvent,JoyDownEvent, JoyUpEvent,\
ResizeEvent, QuitEvent]
ALL_KEYS =
{\
K_BACKSPACE => ["\b", "backspace"],\
K_TAB => ["\t", "tab"],\
K_CLEAR => [nil, "clear"],\
K_RETURN => ["\n", "return", "enter"],\
K_PAUSE => [nil, "pause"],\
K_ESCAPE => ["^[", "escape"],\
K_SPACE => [" ", "space"],\
K_EXCLAIM => ["!", "exclamation_mark", "exclaim"],\
K_QUOTEDBL => ["\"", "double_quote"],\
K_HASH => ["#", "hash", "pound", "bang"],\
K_DOLLAR => ["$", "dollar"],\
K_AMPERSAND => ["&", "ampersand", "and"],\
K_QUOTE => ["'", "quote"],\
K_LEFTPAREN => ["(", "left_parenthesis", "lparen"],\
K_RIGHTPAREN => [")", "right_parenthesis","rparen"],\
K_ASTERISK => ["*", "asterisk"],\
K_PLUS => ["+", "plus"],\
K_COMMA => [",", "comma"],\
K_MINUS => ["-", "minus"],\
K_PERIOD => [".", "period"],\
K_SLASH => ["/", "slash"],\
K_0 => ["0", "numberline_0"],\
K_1 => ["1", "numberline_1"],\
K_2 => ["2", "numberline_2"],\
K_3 => ["3", "numberline_3"],\
K_4 => ["4", "numberline_4"],\
K_5 => ["5", "numberline_5"],\
K_6 => ["6", "numberline_6"],\
K_7 => ["7", "numberline_7"],\
K_8 => ["8", "numberline_8"],\
K_9 => ["9", "numberline_9"],\
K_COLON => [":", "colon"],\
K_SEMICOLON => [";", "semicolon"],\
K_LESS => ["<", "less_than"],\
K_EQUALS => ["=", "equals"],\
K_GREATER => [">", "greater_than"],\
K_QUESTION => ["?", "question_mark", "question"],\
K_AT => ["@", "at"],\
K_LEFTBRACKET => ["[", "left_bracket", "lbracket"],\
K_BACKSLASH => ["\\", "backslash"],\
K_RIGHTBRACKET => ["]", "right_bracket", "rbracket"],\
K_CARET => ["^", "caret"],\
K_UNDERSCORE => ["_", "underscore"],\
K_BACKQUOTE => ["`", "backquote", "grave"],\
K_A => ["a"],\
K_B => ["b"],\
K_C => ["c"],\
K_D => ["d"],\
K_E => ["e"],\
K_F => ["f"],\
K_G => ["g"],\
K_H => ["h"],\
K_I => ["i"],\
K_J => ["j"],\
K_K => ["k"],\
K_L => ["l"],\
K_M => ["m"],\
K_N => ["n"],\
K_O => ["o"],\
K_P => ["p"],\
K_Q => ["q"],\
K_R => ["r"],\
K_S => ["s"],\
K_T => ["t"],\
K_U => ["u"],\
K_V => ["v"],\
K_W => ["w"],\
K_X => ["x"],\
K_Y => ["y"],\
K_Z => ["z"],\
K_DELETE => [nil, "delete", "del"],\
K_KP0 => ["0", "kp0", "keypad_0"],\
K_KP1 => ["1", "kp1", "keypad_1"],\
K_KP2 => ["2", "kp2", "keypad_2"],\
K_KP3 => ["3", "kp3", "keypad_3"],\
K_KP4 => ["4", "kp4", "keypad_4"],\
K_KP5 => ["5", "kp5", "keypad_5"],\
K_KP6 => ["6", "kp6", "keypad_6"],\
K_KP7 => ["7", "kp7", "keypad_7"],\
K_KP8 => ["8", "kp8", "keypad_8"],\
K_KP9 => ["9", "kp9", "keypad_9"],\
K_KP_PERIOD => [".", "period", "keypad_period"],\
K_KP_DIVIDE => ["/", "divide", "keypad_divide"],\
K_KP_MULTIPLY => ["*", "multiply", "keypad_multiply"],\
K_KP_MINUS => ["-", "minus", "keypad_minus"],\
K_KP_PLUS => ["+", "plus", "keypad_plus"],\
K_KP_ENTER => ["\n", "enter", "keypad_enter"],\
K_KP_EQUALS => ["=", "equals", "keypad_equals"],\
K_UP => [nil, "up"],\
K_DOWN => [nil, "down"],\
K_RIGHT => [nil, "right"],\
K_LEFT => [nil, "left"],\
K_INSERT => [nil, "insert", "ins"],\
K_HOME => [nil, "home"],\
K_END => [nil, "end"],\
K_PAGEUP => [nil, "page_up", "pgup"],\
K_PAGEDOWN => [nil, "page_down", "pgdn"],\
K_F1 => [nil, "f1", "function_1"],\
K_F2 => [nil, "f2", "function_2"],\
K_F3 => [nil, "f3", "function_3"],\
K_F4 => [nil, "f4", "function_4"],\
K_F5 => [nil, "f5", "function_5"],\
K_F6 => [nil, "f6", "function_6"],\
K_F7 => [nil, "f7", "function_7"],\
K_F8 => [nil, "f8", "function_8"],\
K_F9 => [nil, "f9", "function_9"],\
K_F10 => [nil, "f10", "function_10"],\
K_F11 => [nil, "f11", "function_11"],\
K_F12 => [nil, "f12", "function_12"],\
K_F13 => [nil, "f13", "function_13"],\
K_F14 => [nil, "f14", "function_14"],\
K_F15 => [nil, "f15", "function_15"],\
K_NUMLOCK => [nil, "numlock"],\
K_CAPSLOCK => [nil, "capslock", "caplock"],\
K_SCROLLOCK => [nil, "scroll_lock", "scrollock", "scrolllock"],\
K_LSHIFT => [nil, "left_shift", "lshift"],\
K_RSHIFT => [nil, "right_shift", "rshift"],\
K_LCTRL => [nil, "left_control", "lctrl"],\
K_RCTRL => [nil, "right_control", "rctrl"],\
K_LALT => [nil, "left_alt", "lalt"],\
K_RALT => [nil, "right_alt", "ralt"],\
K_LMETA => [nil, "left_meta", "lmeta"],\
K_RMETA => [nil, "right_meta", "rmeta"],\
K_LSUPER => [nil, "left_super", "lsuper"],\
K_RSUPER => [nil, "right_super", "rsuper"],\
K_MODE => [nil, "mode"],\
K_HELP => [nil, "help"],\
K_PRINT => [nil, "print_screen","prt_scr","print"],\
K_SYSREQ => [nil, "sysrq", "sysreq", "system_request"],\
K_BREAK => [nil, "break"],\
K_MENU => [nil, "menu"],\
K_POWER => [nil, "power"],\
# I have no idea how to get a Euro symbol here!
K_EURO => ["\u20ac", "euro"],\
# just K_WORLD_0 to K_WORLD_95 after this
K_WORLD_0 => [nil, "world_0"],\
K_WORLD_1 => [nil, "world_1"],\
K_WORLD_2 => [nil, "world_2"],\
K_WORLD_3 => [nil, "world_3"],\
K_WORLD_4 => [nil, "world_4"],\
K_WORLD_5 => [nil, "world_5"],\
K_WORLD_6 => [nil, "world_6"],\
K_WORLD_7 => [nil, "world_7"],\
K_WORLD_8 => [nil, "world_8"],\
K_WORLD_9 => [nil, "world_9"],\
K_WORLD_10 => [nil, "world_10"],\
K_WORLD_11 => [nil, "world_11"],\
K_WORLD_12 => [nil, "world_12"],\
K_WORLD_13 => [nil, "world_13"],\
K_WORLD_14 => [nil, "world_14"],\
K_WORLD_15 => [nil, "world_15"],\
K_WORLD_16 => [nil, "world_16"],\
K_WORLD_17 => [nil, "world_17"],\
K_WORLD_18 => [nil, "world_18"],\
K_WORLD_19 => [nil, "world_19"],\
K_WORLD_20 => [nil, "world_20"],\
K_WORLD_21 => [nil, "world_21"],\
K_WORLD_22 => [nil, "world_22"],\
K_WORLD_23 => [nil, "world_23"],\
K_WORLD_24 => [nil, "world_24"],\
K_WORLD_25 => [nil, "world_25"],\
K_WORLD_26 => [nil, "world_26"],\
K_WORLD_27 => [nil, "world_27"],\
K_WORLD_28 => [nil, "world_28"],\
K_WORLD_29 => [nil, "world_29"],\
K_WORLD_30 => [nil, "world_30"],\
K_WORLD_31 => [nil, "world_31"],\
K_WORLD_32 => [nil, "world_32"],\
K_WORLD_33 => [nil, "world_33"],\
K_WORLD_34 => [nil, "world_34"],\
K_WORLD_35 => [nil, "world_35"],\
K_WORLD_36 => [nil, "world_36"],\
K_WORLD_37 => [nil, "world_37"],\
K_WORLD_38 => [nil, "world_38"],\
K_WORLD_39 => [nil, "world_39"],\
K_WORLD_40 => [nil, "world_40"],\
K_WORLD_41 => [nil, "world_41"],\
K_WORLD_41 => [nil, "world_41"],\
K_WORLD_42 => [nil, "world_42"],\
K_WORLD_43 => [nil, "world_43"],\
K_WORLD_44 => [nil, "world_44"],\
K_WORLD_45 => [nil, "world_45"],\
K_WORLD_46 => [nil, "world_46"],\
K_WORLD_47 => [nil, "world_47"],\
K_WORLD_48 => [nil, "world_48"],\
K_WORLD_49 => [nil, "world_49"],\
K_WORLD_50 => [nil, "world_50"],\
K_WORLD_51 => [nil, "world_51"],\
K_WORLD_52 => [nil, "world_52"],\
K_WORLD_53 => [nil, "world_53"],\
K_WORLD_54 => [nil, "world_54"],\
K_WORLD_55 => [nil, "world_55"],\
K_WORLD_56 => [nil, "world_56"],\
K_WORLD_57 => [nil, "world_57"],\
K_WORLD_58 => [nil, "world_58"],\
K_WORLD_59 => [nil, "world_59"],\
K_WORLD_60 => [nil, "world_60"],\
K_WORLD_61 => [nil, "world_61"],\
K_WORLD_62 => [nil, "world_62"],\
K_WORLD_63 => [nil, "world_63"],\
K_WORLD_64 => [nil, "world_64"],\
K_WORLD_65 => [nil, "world_65"],\
K_WORLD_66 => [nil, "world_66"],\
K_WORLD_67 => [nil, "world_67"],\
K_WORLD_68 => [nil, "world_68"],\
K_WORLD_69 => [nil, "world_69"],\
K_WORLD_70 => [nil, "world_70"],\
K_WORLD_71 => [nil, "world_71"],\
K_WORLD_72 => [nil, "world_72"],\
K_WORLD_73 => [nil, "world_73"],\
K_WORLD_74 => [nil, "world_74"],\
K_WORLD_75 => [nil, "world_75"],\
K_WORLD_76 => [nil, "world_76"],\
K_WORLD_77 => [nil, "world_77"],\
K_WORLD_78 => [nil, "world_78"],\
K_WORLD_79 => [nil, "world_79"],\
K_WORLD_80 => [nil, "world_80"],\
K_WORLD_81 => [nil, "world_81"],\
K_WORLD_82 => [nil, "world_82"],\
K_WORLD_83 => [nil, "world_83"],\
K_WORLD_84 => [nil, "world_84"],\
K_WORLD_85 => [nil, "world_85"],\
K_WORLD_86 => [nil, "world_86"],\
K_WORLD_87 => [nil, "world_87"],\
K_WORLD_88 => [nil, "world_88"],\
K_WORLD_89 => [nil, "world_89"],\
K_WORLD_90 => [nil, "world_90"],\
K_WORLD_91 => [nil, "world_91"],\
K_WORLD_92 => [nil, "world_92"],\
K_WORLD_93 => [nil, "world_93"],\
K_WORLD_94 => [nil, "world_94"],\
K_WORLD_95 => [nil, "world_95"],\
}
INIT_TIMER =

Flags for subsystem initialization

INT2NUM(SDL_INIT_TIMER)
INIT_AUDIO =
INT2NUM(SDL_INIT_AUDIO)
INIT_VIDEO =
INT2NUM(SDL_INIT_VIDEO)
INIT_CDROM =
INT2NUM(SDL_INIT_CDROM)
INIT_JOYSTICK =
INT2NUM(SDL_INIT_JOYSTICK)
INIT_NOPARACHUTE =
INT2NUM(SDL_INIT_NOPARACHUTE)
INIT_EVENTTHREAD =
UINT2NUM(SDL_INIT_EVENTTHREAD)
INIT_EVERYTHING =
UINT2NUM(SDL_INIT_EVERYTHING)
ALPHA_OPAQUE =

Define fully opaque and full transparent (0 and 255)

UINT2NUM(SDL_ALPHA_OPAQUE)
ALPHA_TRANSPARENT =
UINT2NUM(SDL_ALPHA_TRANSPARENT)
LOGPAL =

Flags for palettes (?)

UINT2NUM(SDL_LOGPAL)
PHYSPAL =
UINT2NUM(SDL_PHYSPAL)
NOEVENT =

Event constants

UINT2NUM(SDL_NOEVENT)
ACTIVEEVENT =
UINT2NUM(SDL_ACTIVEEVENT)
KEYDOWN =
UINT2NUM(SDL_KEYDOWN)
KEYUP =
UINT2NUM(SDL_KEYUP)
MOUSEMOTION =
UINT2NUM(SDL_MOUSEMOTION)
MOUSEBUTTONDOWN =
UINT2NUM(SDL_MOUSEBUTTONDOWN)
MOUSEBUTTONUP =
UINT2NUM(SDL_MOUSEBUTTONUP)
JOYAXISMOTION =
UINT2NUM(SDL_JOYAXISMOTION)
JOYBALLMOTION =
UINT2NUM(SDL_JOYBALLMOTION)
JOYHATMOTION =
UINT2NUM(SDL_JOYHATMOTION)
JOYBUTTONDOWN =
UINT2NUM(SDL_JOYBUTTONDOWN)
JOYBUTTONUP =
UINT2NUM(SDL_JOYBUTTONUP)
QUIT =
UINT2NUM(SDL_QUIT)
SYSWMEVENT =
UINT2NUM(SDL_SYSWMEVENT)
VIDEORESIZE =
UINT2NUM(SDL_VIDEORESIZE)
VIDEOEXPOSE =
UINT2NUM(SDL_VIDEOEXPOSE)
USEREVENT =
UINT2NUM(SDL_USEREVENT)
HAT_CENTERED =

Joystick constants

UINT2NUM(SDL_HAT_CENTERED)
HAT_UP =
UINT2NUM(SDL_HAT_UP)
HAT_RIGHT =
UINT2NUM(SDL_HAT_RIGHT)
HAT_DOWN =
UINT2NUM(SDL_HAT_DOWN)
HAT_LEFT =
UINT2NUM(SDL_HAT_LEFT)
HAT_RIGHTUP =
UINT2NUM(SDL_HAT_RIGHTUP)
HAT_RIGHTDOWN =
UINT2NUM(SDL_HAT_RIGHTDOWN)
HAT_LEFTUP =
UINT2NUM(SDL_HAT_LEFTUP)
HAT_LEFTDOWN =
UINT2NUM(SDL_HAT_LEFTDOWN)
MOUSE_LEFT =

Mouse constants

UINT2NUM(SDL_BUTTON_LEFT)
MOUSE_MIDDLE =
UINT2NUM(SDL_BUTTON_MIDDLE)
MOUSE_RIGHT =
UINT2NUM(SDL_BUTTON_RIGHT)
MOUSE_LMASK =
UINT2NUM(SDL_BUTTON_LMASK)
MOUSE_MMASK =
UINT2NUM(SDL_BUTTON_MMASK)
MOUSE_RMASK =
UINT2NUM(SDL_BUTTON_RMASK)
K_UNKNOWN =

ASCII key symbols

UINT2NUM(SDLK_UNKNOWN)
K_FIRST =
UINT2NUM(SDLK_FIRST)
K_BACKSPACE =
UINT2NUM(SDLK_BACKSPACE)
K_TAB =
UINT2NUM(SDLK_TAB)
K_CLEAR =
UINT2NUM(SDLK_CLEAR)
K_RETURN =
UINT2NUM(SDLK_RETURN)
K_PAUSE =
UINT2NUM(SDLK_PAUSE)
K_ESCAPE =
UINT2NUM(SDLK_ESCAPE)
K_SPACE =
UINT2NUM(SDLK_SPACE)
K_EXCLAIM =
UINT2NUM(SDLK_EXCLAIM)
K_QUOTEDBL =
UINT2NUM(SDLK_QUOTEDBL)
K_HASH =
UINT2NUM(SDLK_HASH)
K_DOLLAR =
UINT2NUM(SDLK_DOLLAR)
K_AMPERSAND =
UINT2NUM(SDLK_AMPERSAND)
K_QUOTE =
UINT2NUM(SDLK_QUOTE)
K_LEFTPAREN =
UINT2NUM(SDLK_LEFTPAREN)
K_RIGHTPAREN =
UINT2NUM(SDLK_RIGHTPAREN)
K_ASTERISK =
UINT2NUM(SDLK_ASTERISK)
K_PLUS =
UINT2NUM(SDLK_PLUS)
K_COMMA =
UINT2NUM(SDLK_COMMA)
K_MINUS =
UINT2NUM(SDLK_MINUS)
K_PERIOD =
UINT2NUM(SDLK_PERIOD)
K_SLASH =
UINT2NUM(SDLK_SLASH)
K_0 =
UINT2NUM(SDLK_0)
K_1 =
UINT2NUM(SDLK_1)
K_2 =
UINT2NUM(SDLK_2)
K_3 =
UINT2NUM(SDLK_3)
K_4 =
UINT2NUM(SDLK_4)
K_5 =
UINT2NUM(SDLK_5)
K_6 =
UINT2NUM(SDLK_6)
K_7 =
UINT2NUM(SDLK_7)
K_8 =
UINT2NUM(SDLK_8)
K_9 =
UINT2NUM(SDLK_9)
K_COLON =
UINT2NUM(SDLK_COLON)
K_SEMICOLON =
UINT2NUM(SDLK_SEMICOLON)
K_LESS =
UINT2NUM(SDLK_LESS)
K_EQUALS =
UINT2NUM(SDLK_EQUALS)
K_GREATER =
UINT2NUM(SDLK_GREATER)
K_QUESTION =
UINT2NUM(SDLK_QUESTION)
K_AT =
UINT2NUM(SDLK_AT)
K_LEFTBRACKET =
UINT2NUM(SDLK_LEFTBRACKET)
K_BACKSLASH =
UINT2NUM(SDLK_BACKSLASH)
K_RIGHTBRACKET =
UINT2NUM(SDLK_RIGHTBRACKET)
K_CARET =
UINT2NUM(SDLK_CARET)
K_UNDERSCORE =
UINT2NUM(SDLK_UNDERSCORE)
K_BACKQUOTE =
UINT2NUM(SDLK_BACKQUOTE)
K_A =
UINT2NUM(SDLK_a)
K_B =
UINT2NUM(SDLK_b)
K_C =
UINT2NUM(SDLK_c)
K_D =
UINT2NUM(SDLK_d)
K_E =
UINT2NUM(SDLK_e)
K_F =
UINT2NUM(SDLK_f)
K_G =
UINT2NUM(SDLK_g)
K_H =
UINT2NUM(SDLK_h)
K_I =
UINT2NUM(SDLK_i)
K_J =
UINT2NUM(SDLK_j)
K_K =
UINT2NUM(SDLK_k)
K_L =
UINT2NUM(SDLK_l)
K_M =
UINT2NUM(SDLK_m)
K_N =
UINT2NUM(SDLK_n)
K_O =
UINT2NUM(SDLK_o)
K_P =
UINT2NUM(SDLK_p)
K_Q =
UINT2NUM(SDLK_q)
K_R =
UINT2NUM(SDLK_r)
K_S =
UINT2NUM(SDLK_s)
K_T =
UINT2NUM(SDLK_t)
K_U =
UINT2NUM(SDLK_u)
K_V =
UINT2NUM(SDLK_v)
K_W =
UINT2NUM(SDLK_w)
K_X =
UINT2NUM(SDLK_x)
K_Y =
UINT2NUM(SDLK_y)
K_Z =
UINT2NUM(SDLK_z)
K_DELETE =
UINT2NUM(SDLK_DELETE)
K_WORLD_0 =

International keyboard symbols

UINT2NUM(SDLK_WORLD_0)
K_WORLD_1 =
UINT2NUM(SDLK_WORLD_1)
K_WORLD_2 =
UINT2NUM(SDLK_WORLD_2)
K_WORLD_3 =
UINT2NUM(SDLK_WORLD_3)
K_WORLD_4 =
UINT2NUM(SDLK_WORLD_4)
K_WORLD_5 =
UINT2NUM(SDLK_WORLD_5)
K_WORLD_6 =
UINT2NUM(SDLK_WORLD_6)
K_WORLD_7 =
UINT2NUM(SDLK_WORLD_7)
K_WORLD_8 =
UINT2NUM(SDLK_WORLD_8)
K_WORLD_9 =
UINT2NUM(SDLK_WORLD_9)
K_WORLD_10 =
UINT2NUM(SDLK_WORLD_10)
K_WORLD_11 =
UINT2NUM(SDLK_WORLD_11)
K_WORLD_12 =
UINT2NUM(SDLK_WORLD_12)
K_WORLD_13 =
UINT2NUM(SDLK_WORLD_13)
K_WORLD_14 =
UINT2NUM(SDLK_WORLD_14)
K_WORLD_15 =
UINT2NUM(SDLK_WORLD_15)
K_WORLD_16 =
UINT2NUM(SDLK_WORLD_16)
K_WORLD_17 =
UINT2NUM(SDLK_WORLD_17)
K_WORLD_18 =
UINT2NUM(SDLK_WORLD_18)
K_WORLD_19 =
UINT2NUM(SDLK_WORLD_19)
K_WORLD_20 =
UINT2NUM(SDLK_WORLD_20)
K_WORLD_21 =
UINT2NUM(SDLK_WORLD_21)
K_WORLD_22 =
UINT2NUM(SDLK_WORLD_22)
K_WORLD_23 =
UINT2NUM(SDLK_WORLD_23)
K_WORLD_24 =
UINT2NUM(SDLK_WORLD_24)
K_WORLD_25 =
UINT2NUM(SDLK_WORLD_25)
K_WORLD_26 =
UINT2NUM(SDLK_WORLD_26)
K_WORLD_27 =
UINT2NUM(SDLK_WORLD_27)
K_WORLD_28 =
UINT2NUM(SDLK_WORLD_28)
K_WORLD_29 =
UINT2NUM(SDLK_WORLD_29)
K_WORLD_30 =
UINT2NUM(SDLK_WORLD_30)
K_WORLD_31 =
UINT2NUM(SDLK_WORLD_31)
K_WORLD_32 =
UINT2NUM(SDLK_WORLD_32)
K_WORLD_33 =
UINT2NUM(SDLK_WORLD_33)
K_WORLD_34 =
UINT2NUM(SDLK_WORLD_34)
K_WORLD_35 =
UINT2NUM(SDLK_WORLD_35)
K_WORLD_36 =
UINT2NUM(SDLK_WORLD_36)
K_WORLD_37 =
UINT2NUM(SDLK_WORLD_37)
K_WORLD_38 =
UINT2NUM(SDLK_WORLD_38)
K_WORLD_39 =
UINT2NUM(SDLK_WORLD_39)
K_WORLD_40 =
UINT2NUM(SDLK_WORLD_40)
K_WORLD_41 =
UINT2NUM(SDLK_WORLD_41)
K_WORLD_42 =
UINT2NUM(SDLK_WORLD_42)
K_WORLD_43 =
UINT2NUM(SDLK_WORLD_43)
K_WORLD_44 =
UINT2NUM(SDLK_WORLD_44)
K_WORLD_45 =
UINT2NUM(SDLK_WORLD_45)
K_WORLD_46 =
UINT2NUM(SDLK_WORLD_46)
K_WORLD_47 =
UINT2NUM(SDLK_WORLD_47)
K_WORLD_48 =
UINT2NUM(SDLK_WORLD_48)
K_WORLD_49 =
UINT2NUM(SDLK_WORLD_49)
K_WORLD_50 =
UINT2NUM(SDLK_WORLD_50)
K_WORLD_51 =
UINT2NUM(SDLK_WORLD_51)
K_WORLD_52 =
UINT2NUM(SDLK_WORLD_52)
K_WORLD_53 =
UINT2NUM(SDLK_WORLD_53)
K_WORLD_54 =
UINT2NUM(SDLK_WORLD_54)
K_WORLD_55 =
UINT2NUM(SDLK_WORLD_55)
K_WORLD_56 =
UINT2NUM(SDLK_WORLD_56)
K_WORLD_57 =
UINT2NUM(SDLK_WORLD_57)
K_WORLD_58 =
UINT2NUM(SDLK_WORLD_58)
K_WORLD_59 =
UINT2NUM(SDLK_WORLD_59)
K_WORLD_60 =
UINT2NUM(SDLK_WORLD_60)
K_WORLD_61 =
UINT2NUM(SDLK_WORLD_61)
K_WORLD_62 =
UINT2NUM(SDLK_WORLD_62)
K_WORLD_63 =
UINT2NUM(SDLK_WORLD_63)
K_WORLD_64 =
UINT2NUM(SDLK_WORLD_64)
K_WORLD_65 =
UINT2NUM(SDLK_WORLD_65)
K_WORLD_66 =
UINT2NUM(SDLK_WORLD_66)
K_WORLD_67 =
UINT2NUM(SDLK_WORLD_67)
K_WORLD_68 =
UINT2NUM(SDLK_WORLD_68)
K_WORLD_69 =
UINT2NUM(SDLK_WORLD_69)
K_WORLD_70 =
UINT2NUM(SDLK_WORLD_70)
K_WORLD_71 =
UINT2NUM(SDLK_WORLD_71)
K_WORLD_72 =
UINT2NUM(SDLK_WORLD_72)
K_WORLD_73 =
UINT2NUM(SDLK_WORLD_73)
K_WORLD_74 =
UINT2NUM(SDLK_WORLD_74)
K_WORLD_75 =
UINT2NUM(SDLK_WORLD_75)
K_WORLD_76 =
UINT2NUM(SDLK_WORLD_76)
K_WORLD_77 =
UINT2NUM(SDLK_WORLD_77)
K_WORLD_78 =
UINT2NUM(SDLK_WORLD_78)
K_WORLD_79 =
UINT2NUM(SDLK_WORLD_79)
K_WORLD_80 =
UINT2NUM(SDLK_WORLD_80)
K_WORLD_81 =
UINT2NUM(SDLK_WORLD_81)
K_WORLD_82 =
UINT2NUM(SDLK_WORLD_82)
K_WORLD_83 =
UINT2NUM(SDLK_WORLD_83)
K_WORLD_84 =
UINT2NUM(SDLK_WORLD_84)
K_WORLD_85 =
UINT2NUM(SDLK_WORLD_85)
K_WORLD_86 =
UINT2NUM(SDLK_WORLD_86)
K_WORLD_87 =
UINT2NUM(SDLK_WORLD_87)
K_WORLD_88 =
UINT2NUM(SDLK_WORLD_88)
K_WORLD_89 =
UINT2NUM(SDLK_WORLD_89)
K_WORLD_90 =
UINT2NUM(SDLK_WORLD_90)
K_WORLD_91 =
UINT2NUM(SDLK_WORLD_91)
K_WORLD_92 =
UINT2NUM(SDLK_WORLD_92)
K_WORLD_93 =
UINT2NUM(SDLK_WORLD_93)
K_WORLD_94 =
UINT2NUM(SDLK_WORLD_94)
K_WORLD_95 =
UINT2NUM(SDLK_WORLD_95)
K_KP0 =

Numeric keypad symbols

UINT2NUM(SDLK_KP0)
K_KP1 =
UINT2NUM(SDLK_KP1)
K_KP2 =
UINT2NUM(SDLK_KP2)
K_KP3 =
UINT2NUM(SDLK_KP3)
K_KP4 =
UINT2NUM(SDLK_KP4)
K_KP5 =
UINT2NUM(SDLK_KP5)
K_KP6 =
UINT2NUM(SDLK_KP6)
K_KP7 =
UINT2NUM(SDLK_KP7)
K_KP8 =
UINT2NUM(SDLK_KP8)
K_KP9 =
UINT2NUM(SDLK_KP9)
K_KP_PERIOD =
UINT2NUM(SDLK_KP_PERIOD)
K_KP_DIVIDE =
UINT2NUM(SDLK_KP_DIVIDE)
K_KP_MULTIPLY =
UINT2NUM(SDLK_KP_MULTIPLY)
K_KP_MINUS =
UINT2NUM(SDLK_KP_MINUS)
K_KP_PLUS =
UINT2NUM(SDLK_KP_PLUS)
K_KP_ENTER =
UINT2NUM(SDLK_KP_ENTER)
K_KP_EQUALS =
UINT2NUM(SDLK_KP_EQUALS)
K_UP =

Arrows + Home/End pad

UINT2NUM(SDLK_UP)
K_DOWN =
UINT2NUM(SDLK_DOWN)
K_RIGHT =
UINT2NUM(SDLK_RIGHT)
K_LEFT =
UINT2NUM(SDLK_LEFT)
K_INSERT =
UINT2NUM(SDLK_INSERT)
K_HOME =
UINT2NUM(SDLK_HOME)
K_END =
UINT2NUM(SDLK_END)
K_PAGEUP =
UINT2NUM(SDLK_PAGEUP)
K_PAGEDOWN =
UINT2NUM(SDLK_PAGEDOWN)
K_F1 =

Function keys

UINT2NUM(SDLK_F1)
K_F2 =
UINT2NUM(SDLK_F2)
K_F3 =
UINT2NUM(SDLK_F3)
K_F4 =
UINT2NUM(SDLK_F4)
K_F5 =
UINT2NUM(SDLK_F5)
K_F6 =
UINT2NUM(SDLK_F6)
K_F7 =
UINT2NUM(SDLK_F7)
K_F8 =
UINT2NUM(SDLK_F8)
K_F9 =
UINT2NUM(SDLK_F9)
K_F10 =
UINT2NUM(SDLK_F10)
K_F11 =
UINT2NUM(SDLK_F11)
K_F12 =
UINT2NUM(SDLK_F12)
K_F13 =
UINT2NUM(SDLK_F13)
K_F14 =
UINT2NUM(SDLK_F14)
K_F15 =
UINT2NUM(SDLK_F15)
K_NUMLOCK =

Key state modifier keys

UINT2NUM(SDLK_NUMLOCK)
K_CAPSLOCK =
UINT2NUM(SDLK_CAPSLOCK)
K_SCROLLOCK =
UINT2NUM(SDLK_SCROLLOCK)
K_RSHIFT =
UINT2NUM(SDLK_RSHIFT)
K_LSHIFT =
UINT2NUM(SDLK_LSHIFT)
K_RCTRL =
UINT2NUM(SDLK_RCTRL)
K_LCTRL =
UINT2NUM(SDLK_LCTRL)
K_RALT =
UINT2NUM(SDLK_RALT)
K_LALT =
UINT2NUM(SDLK_LALT)
K_RMETA =
UINT2NUM(SDLK_RMETA)
K_LMETA =
UINT2NUM(SDLK_LMETA)
K_LSUPER =
UINT2NUM(SDLK_LSUPER)
K_RSUPER =
UINT2NUM(SDLK_RSUPER)
K_MODE =
UINT2NUM(SDLK_MODE)
K_HELP =

Miscellaneous keys

UINT2NUM(SDLK_HELP)
K_PRINT =
UINT2NUM(SDLK_PRINT)
K_SYSREQ =
UINT2NUM(SDLK_SYSREQ)
K_BREAK =
UINT2NUM(SDLK_BREAK)
K_MENU =
UINT2NUM(SDLK_MENU)
K_POWER =
UINT2NUM(SDLK_POWER)
K_EURO =
UINT2NUM(SDLK_EURO)
K_LAST =
UINT2NUM(SDLK_LAST)
DOUBLEBUF =

Screen initialization flags

UINT2NUM(SDL_DOUBLEBUF)
FULLSCREEN =
UINT2NUM(SDL_FULLSCREEN)
OPENGL =
UINT2NUM(SDL_OPENGL)
OPENGLBLIT =
UINT2NUM(SDL_OPENGLBLIT)
RESIZABLE =
UINT2NUM(SDL_RESIZABLE)
NOFRAME =
UINT2NUM(SDL_NOFRAME)
VERSIONS =

A Hash containing the version s of rubygame and it’s

compile-time dependencies.
rb_hash_new()
SWSURFACE =

Surface initialization flags

UINT2NUM(SDL_SWSURFACE)
HWSURFACE =
UINT2NUM(SDL_HWSURFACE)
ASYNCBLIT =
UINT2NUM(SDL_ASYNCBLIT)
ANYFORMAT =
UINT2NUM(SDL_ANYFORMAT)
HWPALETTE =
UINT2NUM(SDL_HWPALETTE)
HWACCEL =
UINT2NUM(SDL_HWACCEL)
SRCCOLORKEY =
UINT2NUM(SDL_SRCCOLORKEY)
RLEACCELOK =
UINT2NUM(SDL_RLEACCELOK)
RLEACCEL =
UINT2NUM(SDL_RLEACCEL)
SRCALPHA =
UINT2NUM(SDL_SRCALPHA)
PREALLOC =
UINT2NUM(SDL_PREALLOC)

Class Method Summary collapse

Class Method Details

.audio_driverString

Returns the name of the audio driver that SDL is using.

May raise an SDLError if initialization fails.

Returns:

  • (String)


421
422
423
424
425
426
427
428
429
430
431
432
433
434
# File 'ext/rubygame/rubygame_mixer.c', line 421

VALUE rbgm_mixer_audiodriver(VALUE module)
{
  if( ensure_open_audio() != 0 )
  {
    rb_raise(eSDLError, "Could not initialize audio: %s", Mix_GetError());
  }

  char driver_name[1024];
  if(SDL_AudioDriverName(driver_name, sizeof(driver_name)) == NULL)
  {	
    rb_raise(eSDLError, "Could not get audio driver name: %s", Mix_GetError());
  }
  return rb_str_new2(driver_name);
}

.close_audioBoolean

Deinitializes and closes the audio device. If audio was not open,

this method does nothing, and returns false. See also #open_audio().

NOTE: The audio will be automatically closed when the program
exits. You only need to close audio manually if you want to
call #open_audio with different settings.

Returns::  true if the audio changed from open to closed, or
           false if the audio was not open before this action.

Returns:

  • (Boolean)


317
318
319
320
321
322
323
324
325
326
327
328
# File 'ext/rubygame/rubygame_mixer.c', line 317

VALUE rbgm_mixer_closeaudio2(VALUE module)
{
  if( audio_is_open() )
  {
    Mix_CloseAudio();
    return Qtrue;
  }
  else
  {
    return Qfalse;
  }
}

.deprecated(feature, version) ⇒ Object

Warn of a deprecated Rubygame feature.



29
30
31
32
33
34
# File 'lib/rubygame/shared.rb', line 29

def self.deprecated( feature, version ) # :nodoc:
  if $VERBOSE
    warn( "warning: #{feature} is DEPRECATED and will be removed in " + \
          "Rubygame #{version}! Please see the docs for more information." )
  end
end

.disable_key_repeatObject

Disable key repeat, undoing the effect of #enable_key_repeat.



399
400
401
402
403
404
405
406
407
408
409
# File 'ext/rubygame/rubygame_event.c', line 399

VALUE rg_disable_key_repeat(VALUE module)
{
	int result = SDL_EnableKeyRepeat( 0, 0 );

	if (result != 0) {
		rb_raise(eSDLError, "Could not disable key repeat: %s",
		         SDL_GetError());
	}

	return Qnil;
}

.enable_key_repeat(delay = :default, interval = :default) ⇒ Object

Enable key repeat, so that additional keyboard release and press events are automatically generated for as long as the key is held down. See also #disable_key_repeat.

delay

how many seconds to wait before starting to repeat. Default is 0.5 seconds. (Numeric or :default, optional)

interval

how many seconds to wait in between repetitions after the first one. Default is 0.03 seconds. (Numeric or :default, optional)



364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
# File 'ext/rubygame/rubygame_event.c', line 364

VALUE rg_enable_key_repeat(int argc, VALUE *argv, VALUE module)
{

	VALUE vdelay, vinterval;
	rb_scan_args(argc, argv, "02", &vdelay, &vinterval);


	int delay = rg_get_keyrepeat_value( vdelay,
	                                    SDL_DEFAULT_REPEAT_DELAY,
	                                    "delay" );

	int interval = rg_get_keyrepeat_value( vinterval,
	                                       SDL_DEFAULT_REPEAT_INTERVAL,
	                                       "interval" );


	int result = SDL_EnableKeyRepeat( delay, interval );

	if (result != 0) {
		rb_raise(eSDLError, "Could not enable key repeat: %s",
		         SDL_GetError());
	}

	return Qnil;
}

.fetch_sdl_eventsArray

Retrieves all pending events from SDL’s event stack and converts them into Rubygame Event objects. Returns an Array of all the events, in the order they were read.

This method is used by the EventQueue class, so don’t call it if you are using EventQueue for event management! If you do, the EventQueue will not receive all the events, because they will have been removed from SDL’s event stack by this method.

However, if you aren’t using EventQueue, you can safely use this method to make your own event management system.

Returns:

  • (Array)


287
288
289
290
291
292
293
294
295
296
297
298
299
300
# File 'ext/rubygame/rubygame_event.c', line 287

VALUE rbgm_fetchevents(VALUE self)
{
  SDL_Event event;
  VALUE event_array;

  event_array = rb_ary_new();
  /* put each in *event until no pending events are in SDL's queue */
  /* for now, we don't care what type the event in. Filtering comes later */
  while(SDL_PollEvent(&event)==1) 
  {
    rb_ary_push(event_array, rbgm_convert_sdlevent(event) );
  }
  return event_array;
}

.initnil

Initialize Rubygame. This should be called soon after you require Rubygame, so that everything will work properly.

Returns:

  • (nil)


76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'ext/rubygame/rubygame_main.c', line 76

VALUE rbgm_init(VALUE module)
{
	if(SDL_Init(SDL_INIT_EVERYTHING)==0)
	{
    SDL_EnableUNICODE(1);
		return Qnil;
	}
	else
	{
		rb_raise(eSDLError,"Could not initialize SDL.");
		return Qnil; /* should never get here */
	}
}

.key2str(sym, mods) ⇒ Object

Converts a keyboard symbol (keysym) into a human-readable text string. If either Shift key was being pressed, alphanumeric or punctuation keys will be made uppercase or alternate, based on U.S. keyboard layout. E.g. “a” becomes “A”, “1” becomes “!”, and “/” becomes “?”.



32
33
34
35
36
37
38
39
40
# File 'lib/rubygame/event.rb', line 32

def Rubygame.key2str( sym, mods )
	if (mods.include? K_LSHIFT) or (mods.include? K_RSHIFT)
		return (Rubygame::Key::KEY2UPPER[sym]\
			or Rubygame::Key::KEY2ASCII[sym] or "")
	else
		return (Rubygame::Key::KEY2LOWER[sym]\
			or Rubygame::Key::KEY2ASCII[sym] or "")
	end
end

.key_name(sym) ⇒ String

Given the sym of a key, returns a printable representation. This differs from key2str in that this will return a printable string for any key, even non-printable keys such as the arrow keys.

This method may raise SDLError if the SDL video subsystem could not be initialized for some reason.

Example:

Rubygame.key_name( Rubygame::K_A )       # => "a"
Rubygame.key_name( Rubygame::K_RETURN )  # => "return"
Rubygame.key_name( Rubygame::K_LEFT )    # => "left"

Returns:

  • (String)


52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'ext/rubygame/rubygame_main.c', line 52

VALUE rbgm_keyname(VALUE self, VALUE sym)
{
	/* SDL_GetKeyName only works when video system has been initialized. */
	if( init_video_system() == 0 )
	{
		SDLKey key = NUM2INT(sym);
		char *result = SDL_GetKeyName(key);
		return rb_str_new2(result);		
	}
	else
	{
		rb_raise(eSDLError,"Could not initialize SDL video subsystem.");
		return Qnil;
	}
}

.open_audio(options = { :buffer) ⇒ 1024

Initializes the audio device using the given settings.

NOTE: Audio will be automatically opened when Rubygame::Sound or
Rubygame::Music are first used. You only need to open audio
manually if you want settings different from the default, or if
you are using the older, deprecated Music and Sample classes from
the Rubygame::Mixer module.

If audio is already open, this method has no effect, and returns false.
If you want to change audio settings, you must #close_audio() and
then open it again.

options::    A Hash of any of the following options. (Hash, optional)

   :frequency::  output sample rate in audio samples per second
                 (Hz). Affects the quality of the sound output, at
                 the expense of CPU usage. If omitted, the default
                 (22050) is used. The default is recommended for
                 most games.

   :channels::   output sound channels. Use 2 for stereo, 1 for mono.
                 If omitted, the default (2) is used.

   :buffer::     size of the sound buffer, in bytes. Must be a
                 power of 2 (e.g. 512, 1024, 2048). If omitted,
                 the default (1024) is used. If your game is
                 fast-paced, you may want to use a smaller value
                 to reduce audio delay, the time between when you
                 play a sound and when it is heard.

Returns::    true if the audio was newly opened by this action, or
             false if it was already open before this action.

May raise::  SDLError, if initialization fails.
             ArgumentError, if an invalid value is given for any option.

Returns:

  • (1024)


217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
# File 'ext/rubygame/rubygame_mixer.c', line 217

VALUE rbgm_mixer_openaudio2(int argc, VALUE *argv, VALUE module)
{
  VALUE options;

  int buffer = 1024;
  int channels = 2;
  int frequency = MIX_DEFAULT_FREQUENCY;

  /* In general, format should always be the default. */
  Uint16 format = MIX_DEFAULT_FORMAT;


  /* Does nothing if audio is already open. */
  if( audio_is_open() )
  {
    return Qfalse;
  }


  rb_scan_args(argc, argv, "01", &options);


  if( RTEST(options) )
  {
    /* Make sure options is a Hash table */
    if( TYPE(options) != T_HASH )
    {
      rb_raise(rb_eTypeError, "wrong argument type %s (expected Hash)",
               rb_obj_classname(options));
    }

    VALUE temp;

    /* Buffer size */
    temp = rb_hash_aref(options, make_symbol("buffer"));
    if( RTEST(temp) )
    {
      buffer = NUM2INT(temp);

      if( buffer <= 0 )
      {
        rb_raise(rb_eArgError, "buffer size must be positive (got %d)", buffer);
      }

      /* Check to see if it's not a power of two */
      if( buffer & (buffer - 1) != 0 )
      {
        rb_raise(rb_eArgError, "buffer size must be a power of 2 (e.g. 512, 1024) (got %d)", buffer);
      }
    }

    /* Channels */
    temp = rb_hash_aref(options, make_symbol("channels"));
    if( RTEST(temp) )
    {
      channels = NUM2INT(temp);

      if( channels != 1 && channels != 2 )
      {
        rb_raise(rb_eArgError, "channels must be 1 (mono) or 2 (stereo) (got %d)", channels);
      }
    }

    /* Frequency */
    temp = rb_hash_aref(options, make_symbol("frequency"));
    if( RTEST(temp) )
    {
      frequency = NUM2INT(temp);

      if( frequency <= 0 )
      {
        rb_raise(rb_eArgError, "frequency must be positive (got %d)", frequency);
      }
    }
  }

  int result = Mix_OpenAudio(frequency, format, channels, buffer);

  if( result < 0 )
  {
    rb_raise(eSDLError, "Could not open audio: %s", Mix_GetError());
  }

  return Qtrue;
}

.quitnil

Quit Rubygame. This should be used before your program terminates, especially if you have been using a fullscreen Screen! (Otherwise, the desktop resolution might not revert to its previous setting on some platforms, and your users will be frustrated and confused!)

Returns:

  • (nil)


99
100
101
102
103
# File 'ext/rubygame/rubygame_main.c', line 99

VALUE rbgm_quit(VALUE module)
{
	SDL_Quit();
	return Qnil;
}