Interface of this lib is very close to SDL. So you also had better refer to SDL document.
nAll classes/modules in Ruby/SDL are in "module SDL". In this module number starts 0,not 1.
SDL::Error is exception class. Almost all of errors in Ruby/SDL are reported by this class.
StandardError
SDL.init(flag)Initialize SDL. This should be called before all other SDL functions. The flags parameter specifies what part(s) of SDL to initialize.
SDL::INIT_AUDIO initialize audio output functions SDL::INIT_VIDEO initialize video output functions and input functions SDL::INIT_CDROM initialize CD playback fucntions SDL::INIT_JOYSTICK initialize joystick input functions
You should call this method before calling other Ruby/SDL methods.
SDL.quitSDL.initedSystem(flag)SDL.inited_system(flag)SDL.getenvSDL.putenv(envstr)Change or add an environment variable on Win32. On other platforms this method is equal to ENV.
envstr should be of the form "name=value".
Returns nil, raise exception `SDL::Error' when it fails.
You should use this method to set SDL_WINDOWID or SDL_VIDEODRIVER.
some functions need SGE or SDL_image
SDL.getVideoSurfaceSDL.get_video_surfaceSDL.setVideoMode(w,h,bpp,flags)SDL.set_video_mode(w,h,bpp,flags)SDL::SWSURFACE
Create the video surface in system memory.
SDL::HWSURFACE
Create the video surface in video memory.
SDL::FULLSCREEN
SDL will attempt to use a fullscreen mode.
SDL::SDL_DOUBLEBUF
Enable double buffering. Calling SDL::Screen#flip will flip the buffers and update the screen.
SDL.checkVideoMode(w,h,bpp,flags)SDL.check_video_mode(w,h,bpp,flags)Check to see if a particular video mode is supported. Returns 0 if the requested mode is not supported under any bit depth, or returns the bits-per-pixel of the closest available mode with the given width, height and requested surface flags (see SDL_SetVideoMode).
The bits-per-pixel value returned is only a suggested mode. You can usually request and bpp you want when setting the video mode and SDL will emulate that color depth with a shadow video surface.
The arguments to checkVideoMode are the same ones you would pass to SDL.setVideoMode.
SDL.listModes(flags)SDL.list_modes(flags)SDL.videoDriverNameSDL.video_driver_nameSDL.setGamma(redgamma,greengamma,bluegamma)SDL.set_gamma(redgamma,greengamma,bluegamma)SDL.getGammaRampSDL.get_gamma_rampSDL.setGammaRamp(table)SDL.set_gamma_ramp(table)SDL.autoLockSDL.auto_lockSDL.autoLock?SDL.auto_lock?Needs SGE
Returns whether Ruby/SDL locks surface automatically when need.Default is true.
Please see SDL::Surface#lock to know more.
SDL.autoLock=(autolocking)SDL.auto_lock=(autolocking)SDL.autoLockONSDL.auto_lock_onSDL.autoLockOFFSDL.auto_lock_offNeeds SGE
Set whether Ruby/SDL locks surface automatically when needed.
SDL.videoInfoSDL.video_infoReturn video information in the object of VideoInfo . The contents are following. Values represent boolean value are true/false . Please read SDL document to know about this information.
SDL::VideoInfo#hw_available SDL::VideoInfo#wm_available SDL::VideoInfo#blit_hw SDL::VideoInfo#blit_hw_CC SDL::VideoInfo#blit_hw_A SDL::VideoInfo#blit_sw SDL::VideoInfo#blit_sw_CC SDL::VideoInfo#blit_sw_A SDL::VideoInfo#blit_fill SDL::VideoInfo#video_mem SDL::VideoInfo#bpp
SDL.blitSurface(src,srcX,srcY,srcW,srcH,dst,dstX,dstY)SDL.blit_surface(src,srcX,srcY,srcW,srcH,dst,dstX,dstY)This performs a fast blit from the source surface to the destination surface.
If srcX=srcY=srcW=srcH=0,the entire surface is copied.
The blit function should not be called on a locked surface.
SDL.blitSurface2(src,srcRect,dst,dstRect)SDL.blit_surface2(src,src_rect,dst,dst_rect)You use this function like:
blitSurface2(src,[0,32,32,32],dst,[100,200])
or
Rect = Struct.new( 'Rect', :x, :y, :w, :h ) rect1 = Rect.new( 16, 0, 16, 16 ) rect2 = Rect.new( 120, 0, 0, 0 ) blitSurface2( src, rect1, dst, rect2 )
SDL.rotateXYScaled(src,dst,x,y,angle,xscale,yscale)SDL.rotateXY_scaled(src,dst,x,y,angle,xscale,yscale)Needs SGE
Note that this function is different from SGE sge_rotate_xyscaled API in that src and dst are changing. Following two functions are same. This is equal to blitSurface.
And note that this function ignores colorkey.
This method is obsolete. Please use SDL.transform or SDL.transformBlit
SDL.rotateScaled(src,dst,x,y,angle,scale)SDL.rotate_scaled(src,dst,x,y,angle,scale)SDL.rotate(src,dst,x,y,angle)SDL.rotateScaledBlit(src,dst,x,y,angle,scale)SDL.rotate_scaled_blit(src,dst,x,y,angle,scale)Needs SGE
Same as rotateScaled,but respect colorkey.
SDL.rotateBlit(src,dst,x,y,angle)SDL.rotate_blit(src,dst,x,y,angle)SDL.transform(src,dst,angle,xscale,yscale,px,py,qx,qy,flags)Need SGE
Draw src surface to dst surface with scaling and rotation. Ignore colorkey.
SDL.transformBlit(src,dst,angle,xscale,yscale,px,py,qx,qy,flags)SDL.transform_blit(src,dst,angle,xscale,yscale,px,py,qx,qy,flags)Need SGE
Blit src surface to dst surface with scaling and rotation. Same as SDL.transform , but respect colorkey.
This class have image.
Object
SDL::Surface.new(flag,w,h,format)SDL::Surface.new(flags,w,h,depth,Rmask,Gmask,Bmask,Amask)Create an empty surface. You must call this method after SDL.setVideoMode
format must be the instance of SDL::Surface, and create the surface that has same bpp as specified surface.
The flags specifies the type of surface that should be created, it is an OR'd combination of the following possible values.
SDL::SWSURFACE
SDL will create the surface in system memory.
SDL::HWSURFACE
SDL will attempt to create the surface in video memory.
SDL::SRCCOLORKEY
With this flag SDL will attempt to find the best location for this surface, either in system memory or video memory, to obtain hardware colorkey blitting support.
SDL::SRCALPHA
With this flag SDL will attempt to find the best location for this surface, either in system memory or video memory, to obtain hardware alpha support.
SDL::Surface.new_from(pixels,w,h,depth,pitch,Rmask,Gmask,Bmask,Amask)SDL::Surface.loadBMP(filename)SDL::Surface.load_bmp(filename)Loads a image from a named Windows BMP file and return the instance of SDL::Screen.
Raise SDL::Error if you have an error,for example file didn't exist.
SDL::Surface.load(filename)Needs SDL_image Loads a image from a named Windows BMP file and return the instance of SDL::Screen.
Available formats are BMP,PPX,XPM,PCX,GIF,JPEG,PNG,TGA.
SDL::Surface#saveBMP(filename)SDL::Surface#save_bmp(filename)SDL::Surface#displayFormatSDL::Surface#display_formatThis method copies self to a new surface of the pixel format and colors of the video framebuffer, suitable for fast blitting onto the display surface.
If you want to take advantage of hardware colorkey or alpha blit acceleration, you should set the colorkey and alpha value before calling this method.
SDL::Surface#displayFormatAlphaSDL::Surface#display_format_alphaSDL::Surface#setColorKey(flag,key)SDL::Surface#set_color_key(flag,key)SDL::Surface#fillRect(x,y,w,h)SDL::Surface#fill_rect(x,y,w,h)SDL::Surface#setClipRect(x,y,w,h)SDL::Surface#set_clip_rect(x,y,w,h)Sets the clipping rectangle for a surface. When this surface is the destination of a blit, only the area within the clip rectangle will be drawn into.
The rectangle pointed to by rect will be clipped to the edges of the surface so that the clip rectangle for a surface can never fall outside the edges of the surface.
SDL::Surface#getClipRectSDL::Surface#get_clip_rectSDL::Surface#setAlpha(flag,alpha)SDL::Surface#set_alpha(flag,alpha)SDL_SetAlpha is used for setting the per-surface alpha and/or enabling and disabling per-pixel alpha blending.
flags is used to specify whether alpha blending should be used (SDL::SRCALPHA) and whether the surface should use RLE acceleration for blitting (SDL::RLEACCEL). flags can be an OR'd combination of these two options, one of these options or 0. If SDL_SRCALPHA is not passed as a flag then all alpha information is ignored when blitting the surface. The alpha parameter is the per-surface alpha value, a surface need not have an alpha channel to use per-surface alpha and blitting can still be accelerated with SDL_RLEACCEL. Setting the per-surface alpha value to 0 disables per-surface alpha blending.
SDL::Surface#hSDL::Surface#wSDL::Surface#formatSDL::Surface#put(image,x,y)SDL::Surface#copyRect(x,y,w,h)SDL::Surface#copy_rect(x,y,w,h)SDL::Surface#lockThis method sets up a surface for directly accessing the pixels.You call this before calling SDL::Surface#getPixel , SDL::Surface#drawLine or some other mehtods of Surface.
Between calls to SDL::Surface#lock and SDL::Surface#unlock, you can use methods that 'need locking'. Once you are done accessing the surface, you should use SDL::Surface#unlock to release it.
Not all surfaces require locking. If SDL::Surface#mustLock? returns false, then you can read and write to the surface at any time, and the pixel format of the surface will not change.
No operating system or library calls should be made between lock/unlock pairs, as critical system locks may be held during this time.
If SDL.autoLock returns true,you don't have to call this methods because this library locks surface automatically.
SDL::Surface#unlockSDL::Surface#mustLock?SDL::Surface#must_lock?SDL::Surface#getPixel(x,y)SDL::Surface#get_pixel(x,y)SDL::Surface#[x,y]SDL::Surface#putPixel(x,y,color)SDL::Surface#put_pixel(x,y,color)SDL::Surface#[x, y] = colorSDL::Surface#drawLine(x1,y1,x2,y2,color)SDL::Surface#draw_line(x1,y1,x2,y2,color)SDL::Surface#drawRect(x,y,w,h,color)SDL::Surface#draw_rect(x,y,w,h,color)SDL::Surface#drawCircle(x,y,r,color)SDL::Surface#draw_circle(x,y,r,color)SDL::Surface#drawFilledCircle(x,y,r,color)SDL::Surface#draw_filled_circle(x,y,r,color)SDL::Surface#drawEllipse(x,y,rx,ry,color)SDL::Surface#draw_ellipse(x,y,rx,ry,color)SDL::Surface#drawEllispe(x,y,rx,ry,color)SDL::Surface#drawFilledEllipse(x,y,rx,ry,color)SDL::Surface#draw_filled_ellipse(x,y,rx,ry,color)SDL::Surface#drawFilledEllispe(x,y,rx,ry,color)SDL::Surface#drawAALine(x1,y1,x2,y2,color)SDL::Surface#draw_aa_line(x1,y1,x2,y2,color)Needs SGE ,Needs lock
Draws an antialiased line from (x1,y1) to (x2,y2).
SDL::Surface#drawAACircle(x,y,r,color)SDL::Surface#draw_aa_circle(x,y,r,color)Needs SGE ,Needs lock
Draws an antialiased circle.
SDL::Surface#drawAAFilledCircle(x,y,r,color)SDL::Surface#draw_aa_filled_circle(x,y,r,color)Needs SGE ,Needs lock
Draws a filled antialiased circle.
SDL::Surface#drawAAEllipse(x,y,rx,ry,color)SDL::Surface#draw_aa_ellipse(x,y,rx,ry,color)Needs SGE ,Needs lock
Draws an antialiased ellipse.
SDL::Surface#drawLineAlpha(x1,y1,x2,y2,color,alpha)SDL::Surface#draw_line_alpha(x1,y1,x2,y2,color,alpha)Needs SGE ,Needs lock
Draws a line with alpha blending.
SDL::Surface#drawRectAlpha(x,y,w,h,color,alpha)SDL::Surface#draw_rect_alpha(x,y,w,h,color,alpha)Needs SGE ,Needs lock
Draws a rectangle with alpha blending.
SDL::Surface#drawFilledRectAlpha(x,y,w,h,color,alpha)SDL::Surface#draw_filled_rect_alpha(x,y,w,h,color,alpha)Needs SGE ,Needs lock
x
SDL::Surface#drawCircleAlpha(x,y,r,color,alpha)SDL::Surface#draw_circle_alpha(x,y,r,color,alpha)Needs SGE ,Needs lock
Draws a circle with alpha blending.
SDL::Surface#drawFilledCircleAlpha(x,y,r,color,alpha)SDL::Surface#draw_filled_circle_alpha(x,y,r,color,alpha)Needs SGE ,Needs lock
Draws a filled circle with alpha blending.
SDL::Surface#drawEllipseAlpha(x,y,rx,ry,color,alpha)SDL::Surface#draw_ellipse_alpha(x,y,rx,ry,color,alpha)Needs SGE ,Needs lock
Draws an ellipse with alpha blending.
SDL::Surface#drawFilledEllipseAlpha(x,y,rx,ry,color,alpha)SDL::Surface#draw_filled_ellipse_alpha(x,y,rx,ry,color,alpha)Needs SGE ,Needs lock
Draws a filled ellipse with alpha blending.
SDL::Surface#drawAALineAlpha(x1,y1,x2,y2,color,alpha)SDL::Surface#draw_aa_line_alpha(x1,y1,x2,y2,color,alpha)Needs SGE ,Needs lock
Draws an antialiased line with alpha blending.
SDL::Surface#drawAACircleAlpha(x,y,r,color,alpha)SDL::Surface#draw_aa_circle_alpha(x,y,r,color,alpha)Needs SGE ,Needs lock
Draws an antialiased circle with alpha blending.
SDL::Surface#drawAAEllipseAlpha(x,y,rx,ry,color,alpha)SDL::Surface#draw_aa_ellipse_alpha(x,y,rx,ry,color,alpha)Needs SGE ,Needs lock
Draws an antialiased ellipse with alpha blending.
SDL::Surface#drawBezier(x1,y1,x2,y2,x3,y3,x4,y4,level,color)SDL::Surface#draw_bezier(x1,y1,x2,y2,x3,y3,x4,y4,level,color)Needs SGE ,Needs lock
Draws a bezier curve from (x1,y1) to (x4,y4) with the control points (x2,y2) and (x3,y3). level indicates how good precision the function should use, 4-7 is normal.
SDL::Surface#drawAABezier(x1,y1,x2,y2,x3,y3,x4,y4,level,color)SDL::Surface#draw_aa_bezier(x1,y1,x2,y2,x3,y3,x4,y4,level,color)Needs SGE ,Needs lock
Draws a antialiased bezier curve from (x1,y1) to (x4,y4) with the control points (x2,y2) and (x3,y3). level indicates how good precision the function should use, 4-7 is normal.
SDL::Surface#drawBezierAlpha(x1,y1,x2,y2,x3,y3,x4,y4,level,color,alpha)SDL::Surface#draw_bezier_alpha(x1,y1,x2,y2,x3,y3,x4,y4,level,color,alpha)Needs SGE ,Needs lock
Draws an alpha bezier curve from (x1,y1) to (x4,y4) with the control points (x2,y2) and (x3,y3). level indicates how good precision the function should use, 4-7 is normal.
SDL::Surface#drawAABezierAlpha(x1,y1,x2,y2,x3,y3,x4,y4,level,color,alpha)SDL::Surface#draw_aa_bezier_alpha(x1,y1,x2,y2,x3,y3,x4,y4,level,color,alpha)Needs SGE ,Needs lock
Draws an antialiased alpha bezier curve from (x1,y1) to (x4,y4)
with the control
points (x2,y2) and (x3,y3). level indicates how good precision the function should use, 4-7 is normal.
SDL::Surface#rotateScaledSurface(angle,scale,bgcolor)SDL::Surface#rotate_scaled_surface(angle,scale,bgcolor)Needs SGE This function makes the instance of Surface with a rotated and scaled copy of "self". "angle" is the rotation angle in degrees. "scale" is the scaling value , 1.0 is the normal size.
This method is obsolete. Please use SDL::Surface#transformSurface.
SDL::Surface#rotateSurface(angle,bgcolor)SDL::Surface#rotate_surface(angle,bgcolor)SDL::Surface#transformSurface(bgcolor,angle,xscale,yscale,flags)SDL::Surface#transform_surface(bgcolor,angle,xscale,yscale,flags)SDL::Surface#mapRGB(r,g,b)SDL::Surface#map_rgb(r,g,b)SDL::Surface#mapRGBA(r,g,b,a)SDL::Surface#map_rgba(r,g,b,a)SDL::Surface#getRGB(pixel)SDL::Surface#get_rgb(pixel)SDL::Surface#getRGBA(pixel)SDL::Surface#get_rgba(pixel)SDL::Surface#bppSDL::Surface#colorkeySDL::Surface#alphaSDL::Surface#flagsSDL::Surface#RmaskSDL::Surface#GmaskSDL::Surface#BmaskSDL::Surface#AmaskSDL::Surface#pixelsSDL::Surface#setPalette(flag,colors,firstcolor)SDL::Surface#set_palette(flag,colors,firstcolor)Sets a portion of the palette for the given 8-bit surface.
Palettized (8-bit) screen surfaces with the SDL_HWPALETTE flag have two palettes, a logical palette that is used for mapping blits to/from the surface and a physical palette (that determines how the hardware will map the colors to the display).
This method can modify either the logical or physical palette by specifing SDL::LOGPAL or SDL::PHYSPAL in the flags parameter.
If you want to modify the palette from Xth to th, you will give following array as colors, and X as firstcolor.
[ [rX,gX,bX],[rX+1,gX+1,bX+1], ... ,[rY,gY,bY] ]
SDL::Surface#setColors(colors,firstcolor)SDL::Surface#set_colors(colors,firstcolor)SDL::Surface#getPaletteSDL::Surface#get_paletteReturns the palette of the specified surface. Return value is array as following.
[ [r0,g0,b0],[r1,g1,b1], ... ,[r255,g255,b255] ]
Returns nil if the surface have no palette.
SDL::Surface#makeCollisionMapNeed SGE
Create a collision map. Call SetColorKey first. Every non-transparent pixel in the surface is set to solid in the collision map. Returns an instance of CollisionMap.
Need SGE
This is a map of which pixels in a surface are solid and which are transparent. Its methods can quickly determine whether or not two surfaces would overlap if drawn at particular coordinates.
Only SDL::Surface#makeCollisionMap makes this object.
SDL::CollisionMap#boundingBoxCheck(x1, y1, w1, h1, x2, y2, w2, h2)SDL::CollisionMap#collisionCheck(x1, y1, collisionMap, x2, y2)Determine if this collision map, if drawn with its upper-left corner at (x1, y1), would collide with collisionMap if drawn with its upper-left corner at (x2, y2). If so, return the coordinate of the last collision found as an array ([x, y]). If no collision, returns nil.
This method calls boundingBoxCheck automatically.
SDL::CollisionMap#boundingBoxCheck(x1, y1, collisionMap, x2, y2)SDL::CollisionMap#clear(x1, y1, w, h)SDL::CollisionMap#set(x1, y1, w, h)SDL display the image that the instance of "Screen" have. Only SDL.setVideoMode makes this object. In fact the class named "Screen" doesn't exist,and the object that SDL::setVideoMode returns is the instance of Surface with following singleton methods.
SDL::Screen#updateRect(x,y,w,h)SDL::Screen#update_rect(x,y,w,h)Makes sure the given rectangle is updated on the given screen. Thhis function should not be called while screen is locked.
If 'x', 'y', 'w' and 'h' are all 0, SDL_UpdateRect will update the entire screen.
SDL::Screen#flipOn hardware that supports double-buffering, this method sets up a flip and returns. The hardware will wait for vertical retrace, and then swap video buffers before the next video surface blit or lock will return. On hardware that doesn't support double-buffering, this is equivalent to calling SDL::Screen#updateRect(0, 0, 0, 0)
The SDL::DOUBLEBUF flag must have been passed to SDL.setVideoMode, when setting the video mode for this method to perform hardware flipping.
SDL::Surface has all methods of SDL::PixelFormat. This class is obsolete, and you should use SDL::Surface instead of SDL::PixelFormat.
In SDL you can use some type surface,for example 32bit color surface and 16bit surface.Therefore you need the information about that type,and object of PixelFormat represents this information.
In this lib,you use one integer to specify color.To change from r,g,b value to this integer you use SDL::PixelFormat#mapRGB and to change this integer to r,g,b value SDL::PixelFormat#getRGB
Object
nothing
SDL::PixelFormat#mapRGB(r,g,b)SDL::PixelFormat#mapRGBA(r,g,b,a)SDL::PixelFormat#getRGB(pixel)SDL::PixelFormat#getRGBA(pixel)SDL::PixelFormat#bppSDL::PixelFormat#colorkeySDL::PixelFormat#alphaThe class handling event. You had better use SDL::Event2 instead of this class.
Object
SDL::Event.newSDL::Event.appStateSDL::Event.app_stateReturns the current state of the application. The value returned is a bitwise combination of:
SDL::Event::APPMOUSEFOCUS SDL::Event::APPINPUTFOCUS SDL::Event::APPACTIVE
SDL::Event.enableUNICODESDL::Event.enable_unicodeSDL::Event.disableUNICODESDL::Event.disable_unicodeSDL::Event.enableUNICODE?SDL::Event.enable_unicode?SDL::Event#pollSDL::Event#waitSDL::Event#typeReturns the type of stored event.
SDL::Event::ACTIVEEVENT SDL::Event::KEYDOWN SDL::Event::KEYUP SDL::Event::MOUSEMOTION SDL::Event::MOUSEBUTTONDOWN SDL::Event::MOUSEBUTTONUP SDL::Event::JOYAXISMOTION SDL::Event::JOYBALLMOTION SDL::Event::JOYHATMOTION SDL::Event::JOYBUTTONDOWN SDL::Event::JOYBUTTONUP SDL::Event::QUIT SDL::Event::SYSWMEVENT SDL::Event::VIDEORESIZE
SDL::Event#infoSDL::Event#keyPress?SDL::Event#key_press?SDL::Event#keySymSDL::Event#key_symSDL::Event#keyModSDL::Event#key_modSDL::Event#gain?SDL::Event#appStateSDL::Event#app_stateReturns the kind of ActiveEvent. This value is following.
SDL::Event::APPMOUSEFOCUS SDL::Event::APPINPUTFOCUS SDL::Event::APPACTIVE
SDL::Event#mouseXSDL::Event#mouse_xSDL::Event#mouseYSDL::Event#mouse_ySDL::Event#mouseXrelSDL::Event#mouse_xrelSDL::Event#mouseYrelSDL::Event#mouse_yrelSDL::Event#mouseButtonSDL::Event#mouse_buttonReturns the mouse button index.
SDL::Mouse::BUTTON_LEFT SDL::Mouse::BUTTON_MIDDLE SDL::Mouse::BUTTON_RIGHT
SDL::Event#mousePress?SDL::Event#mouse_press?Another event handling class. I think SDL::Event2 is easier to use than SDL::Event
Object
SDL::Event2.pollPolls for currently pending events, and returns the instance represents that event.Returns nil if there is no pending event. The class of that instance is following.
SDL::Event2::Active SDL::Event2::KeyDown SDL::Event2::KeyUp SDL::Event2::MouseMotion SDL::Event2::MouseButtonDown SDL::Event2::MouseButtonUp SDL::Event2::JoyAxis SDL::Event2::JoyBall SDL::Event2::JoyHat SDL::Event2::JoyButtonUp SDL::Event2::JoyButtonDown SDL::Event2::Quit SDL::Event2::SysWM SDL::Event2::VideoResize
All of these classes are subclass of SDL::Event2.
SDL::Event2.waitSDL::Event2.push(event)SDL::Event2.newSDL::Event2.appStateSDL::Event2.app_stateSDL::Event2.enableUNICODESDL::Event2.enable_unicodeSDL::Event2.disableUNICODESDL::Event2.disable_unicodeSDL::Event2.enableUNICODE?SDL::Event2.enable_unicode?Nothing
SDL::Event2.poll and SDL::Event2.wait return the instance of the subclasses of SDL::Event2. These classes and following.
This event occurs when mouse/keyboard focus gains/loss.
SDL::Event2::Active#gainSDL::Event2::Active#stateReturns the kind of event.
SDL::Event::APPMOUSEFOCUS SDL::Event::APPINPUTFOCUS SDL::Event::APPACTIVE iconify or restored.
This event occurs when a key is pressed.
SDL::Event2::KeyDown#pressSDL::Event2::KeyDown#symSDL::Event2::KeyDown#modSDL::Event2::KeyDown#unicodeThis event occurs when a key is released.
SDL::Event2::KeyUp#pressSDL::Event2::KeyUp#symSDL::Event2::KeyUp#modThis event occurs when mouse is moved.
SDL::Event2::MouseMotion#stateSDL::Event2::MouseMotion#xSDL::Event2::MouseMotion#ySDL::Event2::MouseMotion#xrelSDL::Event2::MouseMotion#yrelThis event occurs when a mouse button is pressed.
SDL::Event2::MouseButtonDown#buttonReturns the which button is pressed.
SDL::Mouse::BUTTON_LEFT SDL::Mouse::BUTTON_MIDDLE SDL::Mouse::BUTTON_RIGHT
SDL::Event2::MouseButtonDown#pressSDL::Event2::MouseButtonDown#xSDL::Event2::MouseButtonDown#yThis event occurs when a mouse button is pressed.
SDL::Event2::MouseButtonUp#buttonReturns the which button is released.
SDL::Mouse::BUTTON_LEFT SDL::Mouse::BUTTON_MIDDLE SDL::Mouse::BUTTON_RIGHT
SDL::Event2::MouseButtonUp#pressSDL::Event2::MouseButtonUp#xSDL::Event2::MouseButtonUp#yThis event occurs when axis of joystick is moved.
SDL::Event2::JoyAxis#whichSDL::Event2::JoyAxis#axisSDL::Event2::JoyAxis#valueThis event occurs when joystick trackball moves.
SDL::Event2::JoyBall#whichSDL::Event2::JoyBall#ballSDL::Event2::JoyBall#xrelSDL::Event2::JoyBall#yrelThis event occurs when joystick hat moves.
SDL::Event2::JoyHat#whichSDL::Event2::JoyHat#hatSDL::Event2::JoyHat#valueReturns hat position. That values is a logically OR'd combination of the following values.
SDL::Joystick::HAT_CENTERED SDL::Joystick::HAT_UP SDL::Joystick::HAT_RIGHT SDL::Joystick::HAT_DOWN SDL::Joystick::HAT_LEFT
The following defines are also provided
SDL::Joystick::HAT_RIGHTUP SDL::Joystick::HAT_RIGHTDOWN SDL::Joystick::HAT_LEFTUP SDL::Joystick::HAT_LEFTDOWN
This event occurs when joystick button is released.
SDL::Event2::JoyButtonUp#whichSDL::Event2::JoyButtonUp#buttonSDL::Event2::JoyButtonUp#pressThis event occurs when joysick button is pressed.
SDL::Event2::JoyButtonDown#whichSDL::Event2::JoyButtonDown#buttonSDL::Event2::JoyButtonDown#pressThis event occurs when quit requested, such as pressed exit button.
This event occurs when platform-dependent window manager occurs. You can't get more information.
This event occurs when window are resized. You will get this event only when you call SDL.setVideoMode with SDL::RESIZABLE.
SDL::Event2::VideoResize#wSDL::Event2::VideoResize#hThe module defines key constants. This module has some functions to get the key state.
SDL::Key.scanSDL::Key.press?(key)SDL::Key.modStateSDL::Key.mod_stateReturns the current of the modifier keys (CTRL,ATL,etc.). The return value can be an OR'd combination of following constants.
SDL::Key::MOD_NONE SDL::Key::MOD_LSHIFT SDL::Key::MOD_RSHIFT SDL::Key::MOD_LCTRL SDL::Key::MOD_RCTRL SDL::Key::MOD_LALT SDL::Key::MOD_RALT SDL::Key::MOD_LMETA SDL::Key::MOD_RMETA SDL::Key::MOD_NUM SDL::Key::MOD_CAPS SDL::Key::MOD_MODE SDL::Key::MOD_RESERVED SDL::Key::MOD_CTRL = SDL::Key::MOD_LCTRL|SDL::Key::MOD_RCTRL SDL::Key::MOD_SHIFT = SDL::Key::MOD_LSHIFT|SDL::Key::MOD_RSHIFT SDL::Key::MOD_ALT = SDL::Key::MOD_LALT|SDL::Key::MOD_RALT SDL::Key::MOD_META = SDL::Key::MOD_LMETA|SDL::Key::MOD_RMETA
SDL::Key.enableKeyRepeat(delay,interval)SDL::Key.enable_key_repeat(delay,interval)SDL::Key.disableKeyRepeatSDL::Key.disable_key_repeatSDL::Key.getKeyName(key)SDL::Key.get_key_name(key)The module mouse constants and mouse functions.
SDL::Mouse.stateReturn mouse state in array. Return value is following,
[ x , y , pressLButton? , pressMButton? , pressRButton? ]
SDL::Mouse.warp(x,y)SDL::Mouse.showSDL::Mouse.hideSDL::Mouse.setCursor(bitmap,white,black,transparent,inverted,hot_x=0,hot_y=0)SDL::Mouse.set_cursor(bitmap,white,black,transparent,inverted,hot_x=0,hot_y=0)The module that have sound functions and constants. Note that volume is between 0 and 128. Needs SDL_mixer to use functions if this module.
SDL::Mixer.open(frequency=Mixer::DEFAULT_FREQUENCY,format=Mixer::DEFAULT_FORMAT,cannels=Mixer::DEFAULT_CHANNELS,chunksize=4096)SDL::Mixer.specReturns the audio spec in array.
[ rate,format,channels ]
SDL::Mixer.allocateChannels(numchannels)SDL::Mixer.allocate_channels(numchannels)SDL::Mixer.playChannel(channel,wave,looping)SDL::Mixer.play_channel(channel,wave,looping)Play a wave on a specific channel.
If the specified channel is -1, play on the first free channel. If 'loops' is greater than zero, loop the sound that many times. If 'loops' is -1, loop inifinitely (~65000 times).
Returns which channel was used to play the sound.
SDL::Mixer.play?(channel)Returns whether specific channel is playing or not.
If the specified channel is -1, check all channels.
SDL::Mixer.setVolume(channel,volume)SDL::Mixer.set_volume(channel,volume)SDL::Mixer.halt(channel)SDL::Mixer.pause(chennel)SDL::Mixer.resume(channel)SDL::Mixer.pause?(channel)SDL::Mixer.playMusic(music,loops)SDL::Mixer.play_music(music,loops)SDL::Mixer.fadeInMusic(music,loops,ms)SDL::Mixer.fade_in_music(music,loops,ms)SDL::Mixer.setVolumeMusic(volume)SDL::Mixer.set_volume_music(volume)SDL::Mixer.haltMusicSDL::Mixer.halt_musicSDL::Mixer.fadeOutMusic(ms)SDL::Mixer.fade_out_music(ms)SDL::Mixer.pauseMusicSDL::Mixer.pause_musicSDL::Mixer.resumeMusicSDL::Mixer.resume_musicSDL::Mixer.rewindMusicSDL::Mixer.rewind_musicSDL::Mixer.pauseMusic?SDL::Mixer.pause_music?SDL::Mixer.playMusic?SDL::Mixer.play_music?The class handling wave
Object
SDL::Mixer::Wave.load(filename)SDL::Mixer::Wave#setVolume(volume)SDL::Mixer::Wave#set_volume(volume)Object
SDL::Mixer::Music.load(filename)Loads a music (.mod .s3m .it .xm .mid .mp3, .ogg) file and returns the object of SDL::Mixer::Music.
You have to setup your environment to play MIDI, Ogg Vorbis, and MP3 file.
The module that have the functions for window management.
SDL::WM.captionSDL::WM.setCaption(title,icon)SDL::WM.set_caption(title,icon)SDL::WM.icon=(iconImage)SDL::WM.icon=(icon_image)Sets the icon for the display window.
This function must be called before the first call to setVideoMode.
It takes an icon surface.
SDL::WM.iconifySDL::Screen#toggleFullScreenSDL::Screen#toggle_fullscreenThe class represents CDROM drive.
Note that the information that you get with SDL::CD#numTracks is stored when you call SDL::CD#status.
A CD-ROM is organized into one or more tracks, each consisting of a certain number of "frames". Each frame is ~2K in size, and at normal playing speed, a CD plays 75 frames per second. SDL works with the number of frames on a CD.
SDL::CD.numDriveSDL::CD.num_driveSDL::CD.indexName(drive)SDL::CD.index_name(drive)SDL::CD.open(drive)SDL::CD#statusStores the information of currentTrack,currentFrame,numTracks,trackType, trackLenght . This function returns the current status. Status is described like so:
SDL::CD::TRAYEMPTY SDL::CD::STOPPED SDL::CD::PLAYING SDL::CD::PAUSED SDL::CD::ERROR
SDL::CD#play(start,length)SDL::CD#playTrack(start_track,start_frame,ntracks,nframes)SDL::CD#play_track(start_track,start_frame,ntracks,nframes)SDL_CDPlayTracks plays the given CD starting at track start_track, for ntracks tracks.
start_frame is the frame offset, from the beginning of the start_track, at which to start. nframes is the frame offset, from the beginning of the last track (start_track+ntracks), at which to end playing.
SDL::CD#playTracks should only be called after calling SDL::CD#status to get track information about the CD.
SDL::CD#pauseSDL::CD#resumeSDL::CD#stopSDL::CD#ejectSDL::CD#numTracksSDL::CD#num_tracksSDL::CD#currentTrackSDL::CD#current_trackSDL::CD#currentFrameSDL::CD#current_frameSDL::CD#trackType(track)SDL::CD#track_type(track)SDL::CD#trackLength(track)SDL::CD#track_length(track)The class represents one joystick.
Object
SDL::Joystick.pallSDL::JoyStick.pall=(polling)SDL::Joystick.numSDL::Joystick.indexName(index)SDL::Joystick.index_name(index)SDL::Joystick.open(index)SDL::Joystick.open?(index)SDL::Joystick.updateAllSDL::Joystick.update_allSDL::Joystick#indexSDL::Joystick#numAxesSDL::Joystick#num_axesSDL::Joystick#numBallsSDL::Joystick#num_ballsSDL::Joystick#numButtonsSDL::Joystick#num_buttonsSDL::Joystick#axis(axis_index)SDL::Joystick#hat(hat_index)The current state is returned as a 8bit unsigned integer which is defined as an OR'd combination of one or more of the following
SDL::Joystick::HAT_CENTERED SDL::Joystick::HAT_UP SDL::Joystick::HAT_RIGHT SDL::Joystick::HAT_DOWN SDL::Joystick::HAT_LEFT SDL::Joystick::HAT_RIGHTUP SDL::Joystick::HAT_RIGHTDOWN SDL::Joystick::HAT_LEFTUP SDL::Joystick::HAT_LEFTDOWN
SDL::Joystick#button(button_index)SDL::Joystick#ball(ball_index)The class handles BitMap Font. This needs SGE.
Object
SDL::BMFont.open(filename,flags)SDL::BMFont::TRANSPARENT
Transparent(Should usually be set)
SDL::BMFont#setColor(r,g,b)SDL::BMFont#set_colorSDL::BMFont#heightSDL::BMFont#widthSDL::BMFont#textout(surface,string,x,y)This class handles bdf fonts. You can draw Japanese character with this class.
Object
SDL::Kanji.open(filename,size)SDL::Kanji#add(filename)SDL::Kanji#setCodingSystemSDL::Kanji#set_coding_systemSet Character coding system. You can use following.
Default is SDL::Kanji::EUC.
SDL::Kanji#textwidth(text)SDL::Kanji#widthSDL::Kanji#heightSDL::Kanji#put(surface,text,x,y,r,g,b)SDL::Kanji#putTate(surface,text,x,y,r,g,b)SDL::Kanji#put_tate(surface,text,x,y,r,g,b)The class handles True Type Font. This needs SDL_ttf.
Object
SDL::TTF.initSDL::TTF.open(filename,size,index=0)Open a font file and create a font of the specified point size.
And you can specify font face with index. Need SDL_ttf 2.0.4 or later to use this feature.
SDL::TTF#styleSDL::TTF#style=(style)Set font style. style is an OR'd conbination of one or more of the following
SDL::TTF::STYLE_NORMAL SDL::TTF::STYLE_BOLD SDL::TTF::STYLE_ITALIC SDL::TTF::STYLE_UNDERLINE
SDL::TTF#textSize(text)SDL::TTF#text_size(text)SDL::TTF#facesSDL::TTF#fixedWidth?SDL::TTF#fixed_width?SDL::TTF#familyNameSDL::TTF#family_nameSDL::TTF#styleNameSDL::TTF#style_nameSDL::TTF#heightSDL::TTF#ascentSDL::TTF#descentSDL::TTF#lineSkipSDL::TTF#line_skipSDL::TTF#drawSolidUTF8(dest,text,x,y,r,g,b)SDL::TTF#draw_solid_utf8(dest,text,x,y,r,g,b)SDL::TTF#drawBlendedUTF8(dest,text,x,y,r,g,b)SDL::TTF#draw_blended_utf8(dest,text,x,y,r,g,b)SDL::TTF#drawShadedUTF8(dest,text,x,y,fg_r,fg_g,fg_b,bg_r,bg_g,bg_b)SDL::TTF#draw_shaded_utf8(dest,text,x,y,fg_r,fg_g,fg_b,bg_r,bg_g,bg_b)SDL::TTF#renderSolidUTF8(text,r,g,b)SDL::TTF#render_solid_utf8(text,r,g,b)SDL::TTF#renderBlendedUTF8(text,r,g,b)SDL::TTF#render_blended_utf8(text,r,g,b)SDL::TTF#renderShadedUTF8(text,fg_r,fg_g,fg_b,bg_r,bg_g,bg_b)SDL::TTF#render_shaded_utf8(text,fg_r,fg_g,fg_b,bg_r,bg_g,bg_b)Needs SMPEG library.
If you will play mpeg with sound, you should call SDL.init with SDL::INIT_AUDIO, and call SDL::Mixer.open.
Don't touch the destination surface while playing mpeg, because smpeg uses native thread.
Don't play sound with SDL::Mixer when playing mpeg, because smpeg hooks SDL_Mixer's playback functions.
This class handles MPEG stream
Object
SDL::MPEG.load(filename)SDL::MPEG.new(filename)SDL::MPEG#infoSDL::MPEG#enableAudio(enable)SDL::MPEG#enable_audio(enable)SDL::MPEG#enableVideo(enable)SDL::MPEG#enable_video(enable)SDL::MPEG#statusReturns the current status.Returns following value.
SDL::MPEG::ERROR SDL::MPEG::STOPPED SDL::MPEG::PLAYING
SDL::MPEG#setVolume(volume)SDL::MPEG#set_volume(volume)SDL::MPEG#setDisplay(surface)SDL::MPEG#set_display(surface)SDL::MPEG#setLoop(repeat)SDL::MPEG#set_loop(repeat)SDL::MPEG#scaleXY(w,h)SDL::MPEG#scale_xy(w,h)SDL::MPEG#scale(scale)SDL::MPEG#move(x,y)SDL::MPEG#setDisplayRegion(x,y,w,h)SDL::MPEG#set_display_region(x,y,w,h)SDL::MPEG#playPlay an MPEG stream.
Warning: Don't access the surface while playing.
SDL::MPEG#pauseSDL::MPEG#stopSDL::MPEG#rewindSDL::MPEG#seek(bytes)SDL::MPEG#skip(seconds)SDL::MPEG#renderFrame(framenum)SDL::MPEG#render_frame(framenum)SDL::MPEG#setFilter(filter)SDL::MPEG#set_filter(filter)Set video filter. Available filter is following.
SDL::MPEG::NULL_FILTER No filter SDL::MPEG::BILINEAR_FILTER Bilinear filter SDL::MPEG::DEBLOCKING_FILTER Deblocking filter
The instance of this class has the information of SDL::MPEG. Get that with SDL::MPEG#info.
Object
SDL::MPEG::Info#has_audioSDL::MPEG::Info#has_videoSDL::MPEG::Info#widthSDL::MPEG::Info#heightSDL::MPEG::Info#current_frameSDL::MPEG::Info#current_fpsSDL::MPEG::Info#audio_stringSDL::MPEG::Info#audio_current_frameSDL::MPEG::Info#current_offsetSDL::MPEG::Info#total_sizeSDL::MPEG::Info#current_timeSDL::MPEG::Info#total_timeSDL.getTicksSDL.get_ticksSDL.delay(ms)Needs SDLSKK library.
You need calling SDL::Event2.enableUNICODE after calling SDL.init to use SDLSKK.
SDL::SKK.encoding=(encoding)SDL::SKK.encodingThis class represents the state of input.
Object
SDL::SKK::Context.new(dict,romkana_table,keybind,use_minibuffer)SDL::SKK::Context#input(event)SDL::SKK::Context#strSDL::SKK::Context#render_str(font,r,g,b)SDL::SKK::Context#render_minibuffer_str(font,r,g,b)SDL::SKK::Context#clearSDL::SKK::Context#get_basic_modeReturns whether context's state is basic mode.
If this method returns true, and you get return, you can stop inputting.
Object
SDL::SKK::Dictionary.newSDL::SKK::Dictionary#load(dictfile,users)SDL::SKK::Dictionary#save(filename)This class represents the rule of conversion from Alphabet to Japanese kana.
Object
SDL::SKK::RomKanaRuleTable.new(table_file)This class represents the keybind in SDLSKK input system.
Object
SDL::SKK::Keybind.newSDL::SKK::Keybind#set_key(key_str,cmd_str)Set keybind.
You can use following string as key_str.
And you can following as cmd_str
You should not set any command on one ascii character like "a" or "/".
SDL::SKK::Keybind#set_default_keySDL::SKK::Keybind#unset_key(key_str)You can draw 3D graphics with OpenGL.
How to use OpenGL.
Please see sample/opengl.rb .
SDL.setGLAttr(attr,val)SDL.set_GL_attr(attr,val)Set the value of special SDL/OpenGL attribute.
List of attribute:
SDL.getGLAttr(attr)SDL.get_GL_attr(attr)SDL.GLSwapBuffersSDL.GL_swap_buffersYou can possibly avoid Ruby/SDL pthread problem when you put following in your script.
require 'rbconfig'
if RUBY_PLATFORM =~ /linux/
  trap('INT','EXIT')
  trap('EXIT','EXIT')
end