Module: Rubygame
- Defined in:
- lib/rubygame/rect.rb,
lib/rubygame/ftor.rb,
lib/rubygame/main.rb,
lib/rubygame/audio.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/old_rect.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
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
- VERSIONS =
{ :rubygame => [2, 6, 4], :sdl => SDL.Linked_Version().to_ary }
- SWSURFACE =
SDL::SWSURFACE
- HWSURFACE =
SDL::HWSURFACE
- ASYNCBLIT =
SDL::ASYNCBLIT
- ANYFORMAT =
SDL::ANYFORMAT
- HWPALETTE =
SDL::HWPALETTE
- HWACCEL =
SDL::HWACCEL
- SRCCOLORKEY =
SDL::SRCCOLORKEY
- RLEACCELOK =
SDL::RLEACCELOK
- RLEACCEL =
SDL::RLEACCEL
- SRCALPHA =
SDL::SRCALPHA
- PREALLOC =
SDL::PREALLOC
- DOUBLEBUF =
SDL::DOUBLEBUF
- FULLSCREEN =
SDL::FULLSCREEN
- OPENGL =
SDL::OPENGL
- OPENGLBLIT =
SDL::OPENGLBLIT
- RESIZABLE =
SDL::RESIZABLE
- NOFRAME =
SDL::NOFRAME
- 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]
- NOEVENT =
Event constants
SDL::NOEVENT
- ACTIVEEVENT =
SDL::ACTIVEEVENT
- KEYDOWN =
SDL::KEYDOWN
- KEYUP =
SDL::KEYUP
- MOUSEMOTION =
SDL::MOUSEMOTION
- MOUSEBUTTONDOWN =
SDL::MOUSEBUTTONDOWN
- MOUSEBUTTONUP =
SDL::MOUSEBUTTONUP
- JOYAXISMOTION =
SDL::JOYAXISMOTION
- JOYBALLMOTION =
SDL::JOYBALLMOTION
- JOYHATMOTION =
SDL::JOYHATMOTION
- JOYBUTTONDOWN =
SDL::JOYBUTTONDOWN
- JOYBUTTONUP =
SDL::JOYBUTTONUP
- QUIT =
SDL::QUIT
- SYSWMEVENT =
SDL::SYSWMEVENT
- VIDEORESIZE =
SDL::VIDEORESIZE
- VIDEOEXPOSE =
SDL::VIDEOEXPOSE
- USEREVENT =
SDL::USEREVENT
- HAT_CENTERED =
Joystick constants
SDL::HAT_CENTERED
- HAT_UP =
SDL::HAT_UP
- HAT_RIGHT =
SDL::HAT_RIGHT
- HAT_DOWN =
SDL::HAT_DOWN
- HAT_LEFT =
SDL::HAT_LEFT
- HAT_RIGHTUP =
SDL::HAT_RIGHTUP
- HAT_RIGHTDOWN =
SDL::HAT_RIGHTDOWN
- HAT_LEFTUP =
SDL::HAT_LEFTUP
- HAT_LEFTDOWN =
SDL::HAT_LEFTDOWN
- MOUSE_LEFT =
Mouse constants
SDL::BUTTON_LEFT
- MOUSE_MIDDLE =
SDL::BUTTON_MIDDLE
- MOUSE_RIGHT =
SDL::BUTTON_RIGHT
- MOUSE_LMASK =
SDL::BUTTON_LMASK
- MOUSE_MMASK =
SDL::BUTTON_MMASK
- MOUSE_RMASK =
SDL::BUTTON_RMASK
- K_UNKNOWN =
ASCII key symbols
SDL::K_UNKNOWN
- K_FIRST =
SDL::K_FIRST
- K_BACKSPACE =
SDL::K_BACKSPACE
- K_TAB =
SDL::K_TAB
- K_CLEAR =
SDL::K_CLEAR
- K_RETURN =
SDL::K_RETURN
- K_PAUSE =
SDL::K_PAUSE
- K_ESCAPE =
SDL::K_ESCAPE
- K_SPACE =
SDL::K_SPACE
- K_EXCLAIM =
SDL::K_EXCLAIM
- K_QUOTEDBL =
SDL::K_QUOTEDBL
- K_HASH =
SDL::K_HASH
- K_DOLLAR =
SDL::K_DOLLAR
- K_AMPERSAND =
SDL::K_AMPERSAND
- K_QUOTE =
SDL::K_QUOTE
- K_LEFTPAREN =
SDL::K_LEFTPAREN
- K_RIGHTPAREN =
SDL::K_RIGHTPAREN
- K_ASTERISK =
SDL::K_ASTERISK
- K_PLUS =
SDL::K_PLUS
- K_COMMA =
SDL::K_COMMA
- K_MINUS =
SDL::K_MINUS
- K_PERIOD =
SDL::K_PERIOD
- K_SLASH =
SDL::K_SLASH
- K_0 =
SDL::K_0
- K_1 =
SDL::K_1
- K_2 =
SDL::K_2
- K_3 =
SDL::K_3
- K_4 =
SDL::K_4
- K_5 =
SDL::K_5
- K_6 =
SDL::K_6
- K_7 =
SDL::K_7
- K_8 =
SDL::K_8
- K_9 =
SDL::K_9
- K_COLON =
SDL::K_COLON
- K_SEMICOLON =
SDL::K_SEMICOLON
- K_LESS =
SDL::K_LESS
- K_EQUALS =
SDL::K_EQUALS
- K_GREATER =
SDL::K_GREATER
- K_QUESTION =
SDL::K_QUESTION
- K_AT =
SDL::K_AT
- K_LEFTBRACKET =
SDL::K_LEFTBRACKET
- K_BACKSLASH =
SDL::K_BACKSLASH
- K_RIGHTBRACKET =
SDL::K_RIGHTBRACKET
- K_CARET =
SDL::K_CARET
- K_UNDERSCORE =
SDL::K_UNDERSCORE
- K_BACKQUOTE =
SDL::K_BACKQUOTE
- K_A =
SDL::K_a
- K_B =
SDL::K_b
- K_C =
SDL::K_c
- K_D =
SDL::K_d
- K_E =
SDL::K_e
- K_F =
SDL::K_f
- K_G =
SDL::K_g
- K_H =
SDL::K_h
- K_I =
SDL::K_i
- K_J =
SDL::K_j
- K_K =
SDL::K_k
- K_L =
SDL::K_l
- K_M =
SDL::K_m
- K_N =
SDL::K_n
- K_O =
SDL::K_o
- K_P =
SDL::K_p
- K_Q =
SDL::K_q
- K_R =
SDL::K_r
- K_S =
SDL::K_s
- K_T =
SDL::K_t
- K_U =
SDL::K_u
- K_V =
SDL::K_v
- K_W =
SDL::K_w
- K_X =
SDL::K_x
- K_Y =
SDL::K_y
- K_Z =
SDL::K_z
- K_DELETE =
SDL::K_DELETE
- K_WORLD_0 =
International keyboard symbols
SDL::K_WORLD_0
- K_WORLD_1 =
SDL::K_WORLD_1
- K_WORLD_2 =
SDL::K_WORLD_2
- K_WORLD_3 =
SDL::K_WORLD_3
- K_WORLD_4 =
SDL::K_WORLD_4
- K_WORLD_5 =
SDL::K_WORLD_5
- K_WORLD_6 =
SDL::K_WORLD_6
- K_WORLD_7 =
SDL::K_WORLD_7
- K_WORLD_8 =
SDL::K_WORLD_8
- K_WORLD_9 =
SDL::K_WORLD_9
- K_WORLD_10 =
SDL::K_WORLD_10
- K_WORLD_11 =
SDL::K_WORLD_11
- K_WORLD_12 =
SDL::K_WORLD_12
- K_WORLD_13 =
SDL::K_WORLD_13
- K_WORLD_14 =
SDL::K_WORLD_14
- K_WORLD_15 =
SDL::K_WORLD_15
- K_WORLD_16 =
SDL::K_WORLD_16
- K_WORLD_17 =
SDL::K_WORLD_17
- K_WORLD_18 =
SDL::K_WORLD_18
- K_WORLD_19 =
SDL::K_WORLD_19
- K_WORLD_20 =
SDL::K_WORLD_20
- K_WORLD_21 =
SDL::K_WORLD_21
- K_WORLD_22 =
SDL::K_WORLD_22
- K_WORLD_23 =
SDL::K_WORLD_23
- K_WORLD_24 =
SDL::K_WORLD_24
- K_WORLD_25 =
SDL::K_WORLD_25
- K_WORLD_26 =
SDL::K_WORLD_26
- K_WORLD_27 =
SDL::K_WORLD_27
- K_WORLD_28 =
SDL::K_WORLD_28
- K_WORLD_29 =
SDL::K_WORLD_29
- K_WORLD_30 =
SDL::K_WORLD_30
- K_WORLD_31 =
SDL::K_WORLD_31
- K_WORLD_32 =
SDL::K_WORLD_32
- K_WORLD_33 =
SDL::K_WORLD_33
- K_WORLD_34 =
SDL::K_WORLD_34
- K_WORLD_35 =
SDL::K_WORLD_35
- K_WORLD_36 =
SDL::K_WORLD_36
- K_WORLD_37 =
SDL::K_WORLD_37
- K_WORLD_38 =
SDL::K_WORLD_38
- K_WORLD_39 =
SDL::K_WORLD_39
- K_WORLD_40 =
SDL::K_WORLD_40
- K_WORLD_41 =
SDL::K_WORLD_41
- K_WORLD_42 =
SDL::K_WORLD_42
- K_WORLD_43 =
SDL::K_WORLD_43
- K_WORLD_44 =
SDL::K_WORLD_44
- K_WORLD_45 =
SDL::K_WORLD_45
- K_WORLD_46 =
SDL::K_WORLD_46
- K_WORLD_47 =
SDL::K_WORLD_47
- K_WORLD_48 =
SDL::K_WORLD_48
- K_WORLD_49 =
SDL::K_WORLD_49
- K_WORLD_50 =
SDL::K_WORLD_50
- K_WORLD_51 =
SDL::K_WORLD_51
- K_WORLD_52 =
SDL::K_WORLD_52
- K_WORLD_53 =
SDL::K_WORLD_53
- K_WORLD_54 =
SDL::K_WORLD_54
- K_WORLD_55 =
SDL::K_WORLD_55
- K_WORLD_56 =
SDL::K_WORLD_56
- K_WORLD_57 =
SDL::K_WORLD_57
- K_WORLD_58 =
SDL::K_WORLD_58
- K_WORLD_59 =
SDL::K_WORLD_59
- K_WORLD_60 =
SDL::K_WORLD_60
- K_WORLD_61 =
SDL::K_WORLD_61
- K_WORLD_62 =
SDL::K_WORLD_62
- K_WORLD_63 =
SDL::K_WORLD_63
- K_WORLD_64 =
SDL::K_WORLD_64
- K_WORLD_65 =
SDL::K_WORLD_65
- K_WORLD_66 =
SDL::K_WORLD_66
- K_WORLD_67 =
SDL::K_WORLD_67
- K_WORLD_68 =
SDL::K_WORLD_68
- K_WORLD_69 =
SDL::K_WORLD_69
- K_WORLD_70 =
SDL::K_WORLD_70
- K_WORLD_71 =
SDL::K_WORLD_71
- K_WORLD_72 =
SDL::K_WORLD_72
- K_WORLD_73 =
SDL::K_WORLD_73
- K_WORLD_74 =
SDL::K_WORLD_74
- K_WORLD_75 =
SDL::K_WORLD_75
- K_WORLD_76 =
SDL::K_WORLD_76
- K_WORLD_77 =
SDL::K_WORLD_77
- K_WORLD_78 =
SDL::K_WORLD_78
- K_WORLD_79 =
SDL::K_WORLD_79
- K_WORLD_80 =
SDL::K_WORLD_80
- K_WORLD_81 =
SDL::K_WORLD_81
- K_WORLD_82 =
SDL::K_WORLD_82
- K_WORLD_83 =
SDL::K_WORLD_83
- K_WORLD_84 =
SDL::K_WORLD_84
- K_WORLD_85 =
SDL::K_WORLD_85
- K_WORLD_86 =
SDL::K_WORLD_86
- K_WORLD_87 =
SDL::K_WORLD_87
- K_WORLD_88 =
SDL::K_WORLD_88
- K_WORLD_89 =
SDL::K_WORLD_89
- K_WORLD_90 =
SDL::K_WORLD_90
- K_WORLD_91 =
SDL::K_WORLD_91
- K_WORLD_92 =
SDL::K_WORLD_92
- K_WORLD_93 =
SDL::K_WORLD_93
- K_WORLD_94 =
SDL::K_WORLD_94
- K_WORLD_95 =
SDL::K_WORLD_95
- K_KP0 =
Numeric keypad symbols
SDL::K_KP0
- K_KP1 =
SDL::K_KP1
- K_KP2 =
SDL::K_KP2
- K_KP3 =
SDL::K_KP3
- K_KP4 =
SDL::K_KP4
- K_KP5 =
SDL::K_KP5
- K_KP6 =
SDL::K_KP6
- K_KP7 =
SDL::K_KP7
- K_KP8 =
SDL::K_KP8
- K_KP9 =
SDL::K_KP9
- K_KP_PERIOD =
SDL::K_KP_PERIOD
- K_KP_DIVIDE =
SDL::K_KP_DIVIDE
- K_KP_MULTIPLY =
SDL::K_KP_MULTIPLY
- K_KP_MINUS =
SDL::K_KP_MINUS
- K_KP_PLUS =
SDL::K_KP_PLUS
- K_KP_ENTER =
SDL::K_KP_ENTER
- K_KP_EQUALS =
SDL::K_KP_EQUALS
- K_UP =
Arrows + Home/End pad
SDL::K_UP
- K_DOWN =
SDL::K_DOWN
- K_RIGHT =
SDL::K_RIGHT
- K_LEFT =
SDL::K_LEFT
- K_INSERT =
SDL::K_INSERT
- K_HOME =
SDL::K_HOME
- K_END =
SDL::K_END
- K_PAGEUP =
SDL::K_PAGEUP
- K_PAGEDOWN =
SDL::K_PAGEDOWN
- K_F1 =
Function keys
SDL::K_F1
- K_F2 =
SDL::K_F2
- K_F3 =
SDL::K_F3
- K_F4 =
SDL::K_F4
- K_F5 =
SDL::K_F5
- K_F6 =
SDL::K_F6
- K_F7 =
SDL::K_F7
- K_F8 =
SDL::K_F8
- K_F9 =
SDL::K_F9
- K_F10 =
SDL::K_F10
- K_F11 =
SDL::K_F11
- K_F12 =
SDL::K_F12
- K_F13 =
SDL::K_F13
- K_F14 =
SDL::K_F14
- K_F15 =
SDL::K_F15
- K_NUMLOCK =
Key state modifier keys
SDL::K_NUMLOCK
- K_CAPSLOCK =
SDL::K_CAPSLOCK
- K_SCROLLOCK =
SDL::K_SCROLLOCK
- K_RSHIFT =
SDL::K_RSHIFT
- K_LSHIFT =
SDL::K_LSHIFT
- K_RCTRL =
SDL::K_RCTRL
- K_LCTRL =
SDL::K_LCTRL
- K_RALT =
SDL::K_RALT
- K_LALT =
SDL::K_LALT
- K_RMETA =
SDL::K_RMETA
- K_LMETA =
SDL::K_LMETA
- K_LSUPER =
SDL::K_LSUPER
- K_RSUPER =
SDL::K_RSUPER
- K_MODE =
SDL::K_MODE
- K_HELP =
Miscellaneous keys
SDL::K_HELP
- K_PRINT =
SDL::K_PRINT
- K_SYSREQ =
SDL::K_SYSREQ
- K_BREAK =
SDL::K_BREAK
- K_MENU =
SDL::K_MENU
- K_POWER =
SDL::K_POWER
- K_EURO =
SDL::K_EURO
- K_LAST =
SDL::K_LAST
- 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"],\ }
Class Method Summary collapse
-
.audio_driver ⇒ Object
Returns the name of the audio driver that SDL is using.
-
.audio_open? ⇒ Boolean
:nodoc:.
-
.close_audio ⇒ Object
Deinitializes and closes the audio device.
-
.collapse_flags(flags) ⇒ Object
Take nil, an integer, or an Array of integers.
-
.deprecated(feature, version = nil) ⇒ Object
Warn of a deprecated Rubygame feature.
-
.disable_key_repeat ⇒ Object
Disable key repeat, undoing the effect of #enable_key_repeat.
-
.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.
-
.fetch_sdl_events ⇒ Object
Retrieves all pending events from SDL’s event stack and converts them into Rubygame Event objects.
-
.init ⇒ Object
Initialize Rubygame.
-
.init_video_system ⇒ Object
Initialize the SDL video system if necessary.
-
.key2str(sym, mods) ⇒ Object
Converts a keyboard symbol (keysym) into a human-readable text string.
-
.open_audio(options = {}) ⇒ Object
call-seq: open_audio( options=:channels=>2, :frequency=>22050 ).
-
.quit ⇒ Object
Quit Rubygame.
Class Method Details
.audio_driver ⇒ Object
Returns the name of the audio driver that SDL is using. This method opens the audio device if it is not open already.
May raise an SDLError if the audio device could not be opened.
142 143 144 145 |
# File 'lib/rubygame/audio.rb', line 142 def self.audio_driver open_audio return SDL.AudioDriverName end |
.audio_open? ⇒ Boolean
:nodoc:
132 133 134 |
# File 'lib/rubygame/audio.rb', line 132 def self.audio_open? # :nodoc: SDL::Mixer.QuerySpec(nil,nil,nil) > 0 end |
.close_audio ⇒ Object
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 was open before this action.
122 123 124 125 126 127 128 129 |
# File 'lib/rubygame/audio.rb', line 122 def self.close_audio if audio_open? SDL::Mixer.CloseAudio() return true else return false end end |
.collapse_flags(flags) ⇒ Object
Take nil, an integer, or an Array of integers. Returns an integer.
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/rubygame/shared.rb', line 58 def self.collapse_flags( flags ) # :nodoc: case flags when Array flags.inject(0){ |mem, flag| mem|flag } when Numeric flags when nil 0 else raise( ArgumentError, "Wrong type for flags " + "(wanted integer, Array, or nil; got #{flags.class})." ) end end |
.deprecated(feature, version = nil) ⇒ Object
Warn of a deprecated Rubygame feature.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/rubygame/shared.rb', line 29 def self.deprecated( feature, version=nil ) # :nodoc: @deprec_warned ||= {} if $VERBOSE and not @deprec_warned[feature] if version warn( "warning: #{feature} is DEPRECATED and will be removed " + "in Rubygame #{version}! Please see the docs for more " + "information." ) else warn( "warning: #{feature} is DEPRECATED and will be removed " + "in a future version of Rubygame! Please see the docs " + "for more information." ) end @deprec_warned[feature] = true end end |
.disable_key_repeat ⇒ Object
Disable key repeat, undoing the effect of #enable_key_repeat.
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/rubygame/events.rb', line 74 def self.disable_key_repeat result = SDL.EnableKeyRepeat( 0, 0 ) if result != 0 raise( Rubygame::SDLError, "Could not disable key repeat: #{SDL.GetError()}" ) end return nil end |
.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)
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/rubygame/events.rb', line 37 def self.enable_key_repeat( delay=:default, interval=:default ) delay = if delay == :default SDL::DEFAULT_REPEAT_DELAY else delay.to_f end interval = if interval == :default SDL::DEFAULT_REPEAT_INTERVAL else interval.to_f end if delay < 0.001 raise( ArgumentError, "delay must be at least 0.001 sec (got #{delay})" ) end if interval < 0.001 raise( ArgumentError, "interval must be at least 0.001 sec (got #{interval})" ) end result = SDL.EnableKeyRepeat( (delay * 1000).to_i, (interval * 1000).to_i ) if result != 0 raise( Rubygame::SDLError, "Could not enable key repeat: #{SDL.GetError()}" ) end return nil end |
.fetch_sdl_events ⇒ Object
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.
36 37 38 39 40 41 42 43 |
# File 'lib/rubygame/event.rb', line 36 def fetch_sdl_events deprecated("Rubygame.fetch_sdl_events", "3.0") events = [] until( ( event = SDL::PollEvent() ).nil? ) events << _convert_sdlevent(event) end return events end |
.init ⇒ Object
Initialize Rubygame. This should be called soon after you require Rubygame, so that everything will work properly.
36 37 38 39 40 41 42 |
# File 'lib/rubygame/main.rb', line 36 def self.init if( SDL.Init(SDL::INIT_EVERYTHING) == 0 ) SDL.EnableUNICODE(1) else raise Rubygame::SDLError, "Could not initialize SDL: #{SDL.GetError()}" end end |
.init_video_system ⇒ Object
Initialize the SDL video system if necessary.
48 49 50 51 52 53 54 |
# File 'lib/rubygame/shared.rb', line 48 def self.init_video_system # :nodoc: if( SDL::WasInit(SDL::INIT_VIDEO) == 0 ) return SDL::Init(SDL::INIT_VIDEO) else return 0 end end |
.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 “?”.
140 141 142 143 144 145 146 147 148 |
# File 'lib/rubygame/event.rb', line 140 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 |
.open_audio(options = {}) ⇒ Object
call-seq:
open_audio( ={:buffer=>1024, :channels=>2, :frequency=>22050} )
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.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/rubygame/audio.rb', line 63 def self.open_audio( ={} ) return false if audio_open? unless .kind_of? Hash raise TypeError, "invalid options Hash: #{.inspect}" end buff = ([:buffer] or 1024) chan = ([:channels] or 2) freq = ([:frequency] or SDL::Mixer::DEFAULT_FREQUENCY) # In general, format should always be the default. frmt = SDL::Mixer::DEFAULT_FORMAT buff = if( buff <= 0 ) raise ArgumentError, "buffer size must be positive (got #{buff})" elsif( buff & (buff - 1) != 0 ) raise( ArgumentError, "buffer size must be a power of 2 "+ "(e.g. 512, 1024) (got #{buff})" ) else buff.to_i end chan = if( chan != 1 && chan != 2 ) raise( ArgumentError, "channels must be 1 (mono) or 2 (stereo) (got #{chan})" ) else chan.to_i end freq = if( freq <= 0 ) raise ArgumentError, "frequency must be positive (got #{freq})" else freq.to_i end result = SDL::Mixer.OpenAudio(freq, frmt, chan, buff) if( result < 0 ) raise Rubygame::SDLError, "Could not open audio: #{SDL.GetError()}" end return true end |
.quit ⇒ Object
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!)
50 51 52 |
# File 'lib/rubygame/main.rb', line 50 def self.quit SDL.Quit end |