rdoc/gosu.rb in gosu-0.15.2 vs rdoc/gosu.rb in gosu-1.0.0.pre1

- old
+ new

@@ -30,10 +30,14 @@ KB_COMMA = :an_integer KB_DELETE = :an_integer KB_DOWN = :an_integer KB_END = :an_integer + KB_PRINTSCREEN = :an_integer + KB_SCROLLLOCK = :an_integer + KB_PAUSE = :an_integer + ## # This is the key on the numpad. KB_ENTER = :an_integer KB_EQUALS = :an_integer @@ -69,10 +73,11 @@ KB_RIGHT_CONTROL = :an_integer KB_RIGHT_META = :an_integer KB_RIGHT_SHIFT = :an_integer KB_SEMICOLON = :an_integer KB_SLASH = :an_integer + KB_CAPSLOCK = :an_integer KB_SPACE = :an_integer KB_TAB = :an_integer KB_UP = :an_integer MS_LEFT = :an_integer @@ -81,16 +86,36 @@ MS_WHEEL_DOWN = :an_integer MS_WHEEL_UP = :an_integer MS_OTHER_0…MS_OTHER_7 = :an_integer GP_BUTTON_0…GP_BUTTON_15 = :an_integer + GP_LEFT_STICK_X_AXIS = :an_integer + GP_RIGHT_STICK_X_AXIS = :an_integer + GP_LEFT_STICK_Y_AXIS = :an_integer + GP_RIGHT_STICK_Y_AXIS = :an_integer + GP_LEFT_TRIGGER_AXIS = :an_integer + GP_RIGHT_TRIGGER_AXIS = :an_integer + GP_DPAD_DOWN = :an_integer + GP_DPAD_LEFT = :an_integer + GP_DPAD_RIGHT = :an_integer + GP_DPAD_UP = :an_integer GP_DOWN = :an_integer GP_LEFT = :an_integer GP_RIGHT = :an_integer GP_UP = :an_integer GP_0_BUTTON_0…GP_3_BUTTON_15 = :an_integer + GP_0_LEFT_STICK_X_AXIS…GP_3_LEFT_STICK_X_AXIS = :an_integer + GP_0_RIGHT_STICK_X_AXIS…GP_3_RIGHT_STICK_X_AXIS = :an_integer + GP_0_LEFT_STICK_Y_AXIS…GP_3_LEFT_STICK_Y_AXIS = :an_integer + GP_0_RIGHT_STICK_Y_AXIS…GP_3_RIGHT_STICK_Y_AXIS = :an_integer + GP_0_LEFT_TRIGGER_AXIS…GP_3_LEFT_TRIGGER_AXIS = :an_integer + GP_0_RIGHT_TRIGGER_AXIS…GP_3_RIGHT_TRIGGER_AXIS = :an_integer + GP_0_DPAD_DOWN…GP_3_DPAD_DOWN = :an_integer + GP_0_DPAD_LEFT…GP_3_DPAD_LEFT = :an_integer + GP_0_DPAD_RIGHT…GP_3_DPAD_RIGHT = :an_integer + GP_0_DPAD_UP…GP_3_DPAD_UP = :an_integer GP_0_DOWN…GP_3_DOWN = :an_integer GP_0_LEFT…GP_3_LEFT = :an_integer GP_0_RIGHT…GP_3_RIGHT = :an_integer GP_0_UP…GP_3_UP = :an_integer @@ -191,18 +216,18 @@ # @!endgroup ## # @return [Integer] a 32-bit representation of the color in 0xAARRGGBB format. def argb; end - + alias_method :to_i, :argb # Returns a 32-bit representation of the color suitable for use with OpenGL calls. This color is stored in a fixed format in memory and its integer value may vary depending on your system's byte order. # # @return [Integer] a 32-bit OpenGL color. def gl; end - + # Returns an OpenGL integer constant that identifies the RGBA color format that Gosu uses. GL_FORMAT = :some_integer ## # @return [Color] a copy of the color. @@ -314,11 +339,11 @@ # Returns the width of a single line of text, in pixels, if it were drawn. # # @return [Integer] the width of the text, in pixels. # @param text [String] def text_width(text, scale_x=1); end - + ## # Like {#text_width}, but supports the following markup tags: `<b>bold</b>`, `<i>italic</i>`, `<c=rrggbb>colors</c>`. def markup_width(markup, scale_x=1); end end @@ -418,17 +443,17 @@ # @see https://github.com/gosu/gosu/wiki/Basic-Concepts#tileability Tileability explained in the Gosu Wiki def self.load_tiles(source, tile_width, tile_height, options = {}); end ## # Returns an image that is a smaller, rectangular view of this {Image}. - # + # # This is a very fast operation, and no new textures will be allocated. # If you update this {Image} or the {#subimage} using {#insert}, the other {Image} will be affected as well. - # + # # Caveats: # * If you stretch or rotate a {#subimage}, the pixels adjacent to it might bleed into it, as Gosu does not manage the 'tileability' of subimages. - # + # # @return [Image?] an image that represents a portion of the containing image def subimage(left, top, width, height); end # @!endgroup @@ -448,11 +473,11 @@ # # @see #draw_rot # @see #draw_as_quad # @see https://github.com/gosu/gosu/wiki/Basic-Concepts#drawing-with-colours Drawing with colors, explained in the Gosu Wiki # @see https://github.com/gosu/gosu/wiki/Basic-Concepts#z-ordering Z-ordering explained in the Gosu Wiki - def draw(x, y, z, scale_x=1, scale_y=1, color=0xff_ffffff, mode=:default); end + def draw(x, y, z=0, scale_x=1, scale_y=1, color=0xff_ffffff, mode=:default); end ## # Draws the image rotated, with its rotational center at (x, y). # # @return [void] @@ -462,11 +487,11 @@ # @param (see #draw) # # @see #draw # @see https://github.com/gosu/gosu/wiki/Basic-Concepts#drawing-with-colours Drawing with colors, explained in the Gosu Wiki # @see https://github.com/gosu/gosu/wiki/Basic-Concepts#z-ordering Z-ordering explained in the Gosu Wiki - def draw_rot(x, y, z, angle, center_x=0.5, center_y=0.5, scale_x=1, scale_y=1, color=0xff_ffffff, mode=:default); end + def draw_rot(x, y, z=0, angle=0, center_x=0.5, center_y=0.5, scale_x=1, scale_y=1, color=0xff_ffffff, mode=:default); end ## # Draws the image as an arbitrary quad. This method can be used for advanced non-rectangular drawing techniques, e.g., faking perspective or isometric projection. # # @return [void] @@ -574,20 +599,20 @@ ## # Sets the playback volume, in the range [0.0; 1.0], where 0 is completely silent and 1 is full volume. Values outside of this range will be clamped to [0.0; 1.0]. # @param [Float] # @return [Float] attr_writer :volume - + ## # Sets the playback speed. A value of 2.0 will play the sample at 200% speed and one octave higher. A value of 0.5 will play the sample at 50% speed and one octave lower. The valid range of this property depends on the operating system, but values up to 8.0 should work. - # @param [Float] + # @param [Float] # @return [Float] attr_writer :speed - + ## # Set the amount of panning, i.e. the position of the sound when using stereo speakers. 0.0 is the centre, negative values are to the left, positive values are to the right. If something happens on the edge of the screen, a good value for pan would be ±0.1. - # @param [Float] + # @param [Float] # @return [Float] attr_writer :pan ## # Stops playback of this sample instance. After calling this method, the sample instance is useless and can be discarded. @@ -779,11 +804,11 @@ def fullscreen?; end ## # Toggles between windowed mode and fullscreen. attr_writer :fullscreen - + ## # @return [true, false] whether this window is resizable. def resizable?; end ## @@ -793,11 +818,11 @@ ## # Creates a new window with the requested size. # # Resizable fullscreen windows always use the full desktop resolution. # Windows that are larger than the desktop resolution will be shrunk. - # + # # @overload initialize(width, height, options = {}) # @overload initialize(width, height, fullscreen, update_interval = 16.666666) # # @param width [Integer] the desired window width. # @param height [Integer] the desired window height. @@ -810,22 +835,22 @@ ## # Enters a modal loop where the Window is visible on screen and receives calls to draw, update etc. # # @return [void] def show; end - + ## # EXPERIMENTAL - MAY DISAPPEAR WITHOUT WARNING. - # + # # Performs a single step in the main loop. # This can be useful for integrating Gosu with other libraries that have their own main loop, e.g. Ruby/Tk. - # + # # See: https://www.libgosu.org/cgi-bin/mwf/topic_show.pl?tid=1218 - # + # # If you find a good way to use {#tick}, please let us know on the forum and we can make this a part of Gosu's stable interface. # Thank you! - # + # # @return [true, false] whether the {Window} should still be shown after this tick def tick; end ## # Tells the window to end the current run loop as soon as possible. @@ -869,11 +894,11 @@ # If you do not want the window to close immediately, you should override this method and # call the {#close!} when needed. # # @return [bool] def close; end - + ## # This method is called before {#update} if a button is pressed while the window has focus. # # By default, this will toggle fullscreen mode if the user presses Alt+Enter (Windows, # Linux), cmd+F (macOS), or F11 (on all operating systems). @@ -901,10 +926,28 @@ # Called when a file is dropped onto the window. # # @param filename [String] the filename of the dropped file. When multiple files are dropped, this method will be called several times. def drop(filename); end + ## + # Called when a gamepad is connected. + # If a gamepad is momentarily disconnected and then reconnected, before another gamepad, it will have the same index. + # + # @param index [integer] index for looking up gamepad. + # + # @see Gosu.gamepad_name + def gamepad_connected(index); end + + ## + # Called when a gamepad is disconnected. + # + # @param index [integer] index for looking up gamepad. + # + # @see #gamepad_connected + # @see Gosu.gamepad_name + def gamepad_disconnected(index); end + # @!endgroup end ## # Holds information about the underlying OpenGL texture and UV coordinates of an image. @@ -942,9 +985,41 @@ # @param (see #button_down) # # @see Window#button_down # @see Window#button_up def button_down?(id); end + + ## + # Returns the name of a Gosu::KB_{*} constant. Returns nil if no name is found. + # + # @example + # Gosu.button_name(Gosu::KB_SPACE) #=> "Space" + # + # @return [String, nil] + # @param id [Integer] + # + def button_name(id); end + + ## + # Returns the name for gamepad at `index` or nil if there is no connected at the specified index. + # + # @example + # Gosu.gamepad_name(0) #=> "PS4 Controller" + # + # @return [String, nil] + # @param index [Integer] + def gamepad_name(index); end + + ## + # Returns the value for the specified gamepad axis in the range -1.0..1.0 for joysticks and 0.0..1.0 for triggers. + # + # @example + # Gosu.axis(Gosu::GP_0_LEFT_STICK_Y_AXIS) #=> 0.75 + # + # @return [Float] + # @param id [Integer] + # + def axis(id); end # @!group Drawing primitives ## # Draws a line from one point to another---inconsistently.