gosu 0.9.2 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gosu/Bitmap.hpp +3 -3
- data/Gosu/Directories.hpp +6 -3
- data/Gosu/Gosu.hpp +0 -1
- data/Gosu/GraphicsBase.hpp +12 -8
- data/Gosu/Input.hpp +5 -16
- data/Gosu/Platform.hpp +1 -0
- data/Gosu/Version.hpp +3 -5
- data/Gosu/Window.hpp +7 -8
- data/README.txt +3 -3
- data/ext/gosu/extconf.rb +17 -16
- data/ext/gosu/gosu_wrap.cxx +59 -58
- data/ext/gosu/gosu_wrap.h +1 -1
- data/rdoc/gosu.rb +285 -283
- data/src/{MacUtility.hpp → AppleUtility.hpp} +24 -42
- data/src/Audio/ALChannelManagement.hpp +1 -1
- data/src/Audio/{AudioOpenAL.cpp → Audio.cpp} +6 -7
- data/src/Audio/Audio.mm +1 -0
- data/src/Audio/AudioFile.hpp +2 -2
- data/src/Audio/AudioToolboxFile.hpp +5 -20
- data/src/Audio/OggFile.hpp +44 -56
- data/src/Audio/SndFile.hpp +2 -2
- data/src/Bitmap/Bitmap.cpp +98 -2
- data/src/Bitmap/BitmapIO.cpp +156 -0
- data/src/DirectoriesApple.mm +76 -0
- data/src/DirectoriesUnix.cpp +5 -12
- data/src/DirectoriesWin.cpp +5 -0
- data/src/Graphics/BlockAllocator.hpp +2 -2
- data/src/Graphics/ClipRectStack.hpp +2 -2
- data/src/Graphics/Common.hpp +2 -2
- data/src/Graphics/DrawOp.hpp +2 -2
- data/src/Graphics/DrawOpQueue.hpp +2 -2
- data/src/Graphics/Graphics.cpp +7 -2
- data/src/Graphics/LargeImageData.cpp +6 -6
- data/src/Graphics/LargeImageData.hpp +3 -3
- data/src/Graphics/Macro.hpp +2 -2
- data/src/Graphics/RenderState.hpp +2 -2
- data/src/Graphics/Resolution.cpp +1 -1
- data/src/Graphics/TexChunk.hpp +2 -2
- data/src/Graphics/Texture.cpp +21 -16
- data/src/Graphics/Texture.hpp +7 -5
- data/src/Graphics/TransformStack.hpp +2 -2
- data/src/Iconv.hpp +2 -2
- data/src/Input/Input.cpp +3 -1
- data/src/Input/{InputTouch.mm → InputUIKit.mm} +32 -26
- data/src/Input/TextInput.cpp +1 -1
- data/src/Text/FormattedString.hpp +2 -2
- data/src/Text/TextApple.mm +8 -8
- data/src/Text/TextMac.cpp +1 -1
- data/src/Text/TextUnix.cpp +1 -1
- data/src/UIKit/GosuAppDelegate.h +8 -0
- data/src/UIKit/GosuAppDelegate.mm +24 -0
- data/src/UIKit/GosuGLView.h +8 -0
- data/src/UIKit/GosuGLView.mm +130 -0
- data/src/UIKit/GosuViewController.h +13 -0
- data/src/UIKit/GosuViewController.mm +214 -0
- data/src/UtilityApple.mm +5 -18
- data/src/Window.cpp +1 -3
- data/src/WindowUIKit.mm +124 -0
- data/src/stb_image.h +6437 -0
- data/src/stb_image_write.h +730 -0
- data/src/stb_vorbis.c +5459 -0
- metadata +18 -26
- data/Gosu/Sockets.hpp +0 -156
- data/src/Audio/AudioOpenAL.mm +0 -1
- data/src/Bitmap/BitmapApple.mm +0 -226
- data/src/Bitmap/BitmapBMP.cpp +0 -79
- data/src/Bitmap/BitmapColorKey.cpp +0 -50
- data/src/Bitmap/BitmapFreeImage.cpp +0 -174
- data/src/Bitmap/BitmapGDIplus.cpp +0 -212
- data/src/Bitmap/BitmapUtils.cpp +0 -76
- data/src/DirectoriesMac.mm +0 -38
- data/src/DirectoriesTouch.mm +0 -38
- data/src/GosuView.hpp +0 -15
- data/src/GosuView.mm +0 -208
- data/src/Input/AccelerometerReader.hpp +0 -10
- data/src/Input/AccelerometerReader.mm +0 -31
- data/src/Sockets/CommSocket.cpp +0 -305
- data/src/Sockets/ListenerSocket.cpp +0 -59
- data/src/Sockets/MessageSocket.cpp +0 -128
- data/src/Sockets/Socket.cpp +0 -145
- data/src/Sockets/Socket.hpp +0 -66
- data/src/WindowTouch.mm +0 -243
- data/src/X11vroot.h +0 -118
data/ext/gosu/gosu_wrap.h
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/* ----------------------------------------------------------------------------
|
2
2
|
* This file was automatically generated by SWIG (http://www.swig.org).
|
3
|
-
* Version 3.0.
|
3
|
+
* Version 3.0.6
|
4
4
|
*
|
5
5
|
* This file is not intended to be easily readable and contains a number of
|
6
6
|
* coding conventions designed to improve portability and efficiency. Do not make
|
data/rdoc/gosu.rb
CHANGED
@@ -25,11 +25,11 @@ module Gosu
|
|
25
25
|
KbDelete = :implementation_defined
|
26
26
|
KbDown = :implementation_defined
|
27
27
|
KbEnd = :implementation_defined
|
28
|
-
|
28
|
+
|
29
29
|
##
|
30
30
|
# This is the key on the numpad.
|
31
31
|
KbEnter = :implementation_defined
|
32
|
-
|
32
|
+
|
33
33
|
KbEscape = :implementation_defined
|
34
34
|
KbF1 KbF2 KbF3 KbF4 KbF5 KbF6 KbF7 KbF8 KbF9 KbF10 KbF11 KbF12 = :implementation_defined
|
35
35
|
KbHome = :implementation_defined
|
@@ -45,11 +45,11 @@ module Gosu
|
|
45
45
|
KbNumpadSubtract = :implementation_defined
|
46
46
|
KbPageDown = :implementation_defined
|
47
47
|
KbPageUp = :implementation_defined
|
48
|
-
|
48
|
+
|
49
49
|
##
|
50
50
|
# This is the key above the right shift key.
|
51
51
|
KbReturn = :implementation_defined
|
52
|
-
|
52
|
+
|
53
53
|
KbRight = :implementation_defined
|
54
54
|
KbRightAlt = :implementation_defined
|
55
55
|
KbRightControl = :implementation_defined
|
@@ -68,149 +68,149 @@ module Gosu
|
|
68
68
|
KbComma = :implementation_defined
|
69
69
|
KbPeriod = :implementation_defined
|
70
70
|
KbSlash = :implementation_defined
|
71
|
-
|
71
|
+
|
72
72
|
MsLeft = :implementation_defined
|
73
73
|
MsMiddle = :implementation_defined
|
74
74
|
MsRight = :implementation_defined
|
75
75
|
MsWheelDown = :implementation_defined
|
76
76
|
MsWheelUp = :implementation_defined
|
77
77
|
MsOther0 MsOther1 MsOther2 MsOther3 MsOther4 MsOther5 MsOther6 MsOther7 = :implementation_defined
|
78
|
-
|
78
|
+
|
79
79
|
GpButton0 GpButton1 GpButton2 GpButton3 GpButton4 GpButton5 GpButton6 GpButton7 GpButton8 GpButton9 GpButton10 GpButton11 GpButton12 GpButton13 GpButton14 GpButton15 = :implementation_defined
|
80
80
|
GpDown = :implementation_defined
|
81
81
|
GpLeft = :implementation_defined
|
82
82
|
GpRight = :implementation_defined
|
83
83
|
GpUp = :implementation_defined
|
84
|
-
|
84
|
+
|
85
85
|
Gp0Button0 Gp0Button1 Gp0Button2 Gp0Button3 Gp0Button4 Gp0Button5 Gp0Button6 Gp0Button7 Gp0Button8 Gp0Button9 Gp0Button10 Gp0Button11 Gp0Button12 Gp0Button13 Gp0Button14 Gp0Button15 = :implementation_defined
|
86
86
|
Gp0Down = :implementation_defined
|
87
87
|
Gp0Left = :implementation_defined
|
88
88
|
Gp0Right = :implementation_defined
|
89
89
|
Gp0Up = :implementation_defined
|
90
|
-
|
90
|
+
|
91
91
|
Gp1Button0 Gp1Button1 Gp1Button2 Gp1Button3 Gp1Button4 Gp1Button5 Gp1Button6 Gp1Button7 Gp1Button8 Gp1Button9 Gp1Button10 Gp1Button11 Gp1Button12 Gp1Button13 Gp1Button14 Gp1Button15 = :implementation_defined
|
92
92
|
Gp1Down = :implementation_defined
|
93
93
|
Gp1Left = :implementation_defined
|
94
94
|
Gp1Right = :implementation_defined
|
95
95
|
Gp1Up = :implementation_defined
|
96
|
-
|
96
|
+
|
97
97
|
Gp2Button0 Gp2Button1 Gp2Button2 Gp2Button3 Gp2Button4 Gp2Button5 Gp2Button6 Gp2Button7 Gp2Button8 Gp2Button9 Gp2Button10 Gp2Button11 Gp2Button12 Gp2Button13 Gp2Button14 Gp2Button15 = :implementation_defined
|
98
98
|
Gp2Down = :implementation_defined
|
99
99
|
Gp2Left = :implementation_defined
|
100
100
|
Gp2Right = :implementation_defined
|
101
101
|
Gp2Up = :implementation_defined
|
102
|
-
|
102
|
+
|
103
103
|
Gp3Button0 Gp3Button1 Gp3Button2 Gp3Button3 Gp3Button4 Gp3Button5 Gp3Button6 Gp3Button7 Gp3Button8 Gp3Button9 Gp3Button10 Gp3Button11 Gp3Button12 Gp3Button13 Gp3Button14 Gp3Button15 = :implementation_defined
|
104
104
|
Gp3Down = :implementation_defined
|
105
105
|
Gp3Left = :implementation_defined
|
106
106
|
Gp3Right = :implementation_defined
|
107
107
|
Gp3Up = :implementation_defined
|
108
|
-
|
108
|
+
|
109
109
|
##
|
110
110
|
# Represents an ARGB color value with 8 bits for each channel. Colors can be used interchangeably with integer literals of the form 0xAARRGGBB in all Gosu APIs.
|
111
111
|
class Color
|
112
112
|
##
|
113
113
|
# @return [Fixnum] the color's alpha channel.
|
114
114
|
attr_accessor :alpha
|
115
|
-
|
115
|
+
|
116
116
|
##
|
117
117
|
# @return [Fixnum] the color's red channel.
|
118
118
|
attr_accessor :red
|
119
|
-
|
119
|
+
|
120
120
|
##
|
121
121
|
# @return [Fixnum] the color's green channel.
|
122
122
|
attr_accessor :green
|
123
|
-
|
123
|
+
|
124
124
|
##
|
125
125
|
# @return [Fixnum] the color's blue channel.
|
126
126
|
attr_accessor :blue
|
127
|
-
|
127
|
+
|
128
128
|
##
|
129
129
|
# @return [Fixnum] the color's hue in the range (0...360).
|
130
130
|
attr_accessor :hue
|
131
|
-
|
131
|
+
|
132
132
|
##
|
133
133
|
# @return [Float] the color's saturation in the range (0..1).
|
134
134
|
attr_accessor :saturation
|
135
|
-
|
135
|
+
|
136
136
|
##
|
137
137
|
# @return [Float] the color's value in the range (0..1).
|
138
138
|
attr_accessor :value
|
139
|
-
|
139
|
+
|
140
140
|
# @!group Creating colors.
|
141
|
-
|
141
|
+
|
142
142
|
##
|
143
143
|
# @overload initialize(argb)
|
144
144
|
# @param argb [Fixnum] an integer of the form 0xAARRGGBB.
|
145
|
-
#
|
145
|
+
#
|
146
146
|
# @overload initialize(a, r, g, b)
|
147
147
|
# @param a [Fixnum] the color's alpha channel in the range (0..255).
|
148
148
|
# @param r [Fixnum] the color's red channel in the range (0..255).
|
149
149
|
# @param g [Fixnum] the color's green channel in the range (0..255).
|
150
150
|
# @param b [Fixnum] the color's blue channel in the range (0..255).
|
151
|
-
#
|
151
|
+
#
|
152
152
|
# @see from_hsv
|
153
153
|
# @see from_ahsv
|
154
154
|
# @see rgba
|
155
155
|
# @see argb
|
156
156
|
def initialize(*args); end
|
157
|
-
|
157
|
+
|
158
158
|
##
|
159
159
|
# @return (see #initialize)
|
160
|
-
#
|
160
|
+
#
|
161
161
|
# @overload rgba(rgba)
|
162
162
|
# @param argb [Fixnum] an integer of the form 0xRRGGBBAA.
|
163
|
-
#
|
163
|
+
#
|
164
164
|
# @overload rgba(r, g, b, a)
|
165
165
|
# @param r [Fixnum] the color's red channel in the range (0..255).
|
166
166
|
# @param g [Fixnum] the color's green channel in the range (0..255).
|
167
167
|
# @param b [Fixnum] the color's blue channel in the range (0..255).
|
168
168
|
# @param a [Fixnum] the color's alpha channel in the range (0..255).
|
169
|
-
#
|
169
|
+
#
|
170
170
|
# @see #initialize
|
171
171
|
# @see argb
|
172
172
|
def self.rgba(*args); end
|
173
|
-
|
173
|
+
|
174
174
|
# This method is equivalent to calling `Color.new`, but the name makes the parameter order explicit.
|
175
|
-
#
|
175
|
+
#
|
176
176
|
# @return (see #initialize)
|
177
177
|
# @overload argb(argb)
|
178
178
|
# @overload argb(a, r, g, b)
|
179
|
-
#
|
179
|
+
#
|
180
180
|
# @see #initialize
|
181
181
|
# @see rgba
|
182
182
|
def self.argb(*args); end
|
183
|
-
|
183
|
+
|
184
184
|
# Converts an HSV triplet to an opaque color.
|
185
|
-
#
|
185
|
+
#
|
186
186
|
# @return [Color] a color corresponding to the HSV triplet.
|
187
187
|
# @param h [Fixnum] the color's hue in the range (0..360).
|
188
188
|
# @param s [Float] the color's saturation in the range (0..1).
|
189
189
|
# @param v [Float] the color's value in the range (0..1).
|
190
|
-
#
|
190
|
+
#
|
191
191
|
# @see from_ahsv
|
192
192
|
def self.from_hsv(h, s, v); end
|
193
|
-
|
193
|
+
|
194
194
|
# Converts an HSV triplet to a color with the alpha channel set to a given value.
|
195
|
-
#
|
195
|
+
#
|
196
196
|
# @return (see from_hsv)
|
197
197
|
# @param a [Fixnum] the color's opacity in the range (0..255).
|
198
198
|
# @param (see from_hsv)
|
199
|
-
#
|
199
|
+
#
|
200
200
|
# @see from_hsv
|
201
201
|
def self.from_ahsv(a, h, s, v); end
|
202
|
-
|
202
|
+
|
203
203
|
# @!endgroup
|
204
|
-
|
204
|
+
|
205
205
|
# Returns a 32-bit representation of the color suitable for use with OpenGL calls. This color is stored in a fixed order in memory and its integer value may vary depending on your system's byte order.
|
206
|
-
#
|
206
|
+
#
|
207
207
|
# @return [Fixnum] a 32-bit OpenGL color.
|
208
208
|
def gl; end
|
209
|
-
|
209
|
+
|
210
210
|
##
|
211
211
|
# @return [Color] a copy of the color.
|
212
212
|
def dup; end
|
213
|
-
|
213
|
+
|
214
214
|
NONE = Gosu::Color.argb(0x00_000000)
|
215
215
|
BLACK = Gosu::Color.argb(0xff_000000)
|
216
216
|
GRAY = Gosu::Color.argb(0xff_808080)
|
@@ -223,7 +223,7 @@ module Gosu
|
|
223
223
|
FUCHSIA = Gosu::Color.argb(0xff_ff00ff)
|
224
224
|
CYAN = Gosu::Color.argb(0xff_00ffff)
|
225
225
|
end
|
226
|
-
|
226
|
+
|
227
227
|
##
|
228
228
|
# A Font can be used to draw text on a Window object very flexibly.
|
229
229
|
# Fonts are ideal for small texts that change regularly.
|
@@ -231,42 +231,42 @@ module Gosu
|
|
231
231
|
class Font
|
232
232
|
##
|
233
233
|
# The font's name. This may be the name of a system font or a filename.
|
234
|
-
#
|
234
|
+
#
|
235
235
|
# @return [String] the font's name.
|
236
236
|
attr_reader :name
|
237
|
-
|
237
|
+
|
238
238
|
##
|
239
239
|
# @return [Fixnum] the font's height in pixels.
|
240
240
|
attr_reader :height
|
241
|
-
|
241
|
+
|
242
242
|
##
|
243
243
|
# Load a font from the system fonts or a file.
|
244
|
-
#
|
244
|
+
#
|
245
245
|
# (Passing a Window reference is not necessary anymore, please use the first overload from now on.)
|
246
|
-
#
|
246
|
+
#
|
247
247
|
# @param height [Fixnum] the height of the font, in pixels.
|
248
248
|
# @param [Hash] options
|
249
249
|
# @option options [String] :name the name of a system font, or a path to a TrueType Font (TTF) file. A path must contain at least one '/' character to distinguish it from a system font.
|
250
|
-
#
|
250
|
+
#
|
251
251
|
# @overload initialize(height, options = {})
|
252
252
|
# @overload initialize(window, font_name, height)
|
253
253
|
def initialize(height, options = {}); end
|
254
|
-
|
254
|
+
|
255
255
|
##
|
256
256
|
# Overrides the image for a character.
|
257
|
-
#
|
257
|
+
#
|
258
258
|
# @note For any given character, this method MUST NOT be called more than once, and MUST NOT be called if a string containing the character has already been drawn.
|
259
|
-
#
|
259
|
+
#
|
260
260
|
# @return [void]
|
261
261
|
# @param character [String] the character to replace.
|
262
262
|
# @param image [Image] the image to use for the character.
|
263
263
|
def []=(character, image); end
|
264
|
-
|
264
|
+
|
265
265
|
# @!group Drawing text
|
266
|
-
|
266
|
+
|
267
267
|
##
|
268
268
|
# Draws a single line of text with its top left corner at (x, y).
|
269
|
-
#
|
269
|
+
#
|
270
270
|
# @return [void]
|
271
271
|
# @param text [String]
|
272
272
|
# @param x [Number] the X coordinate
|
@@ -276,92 +276,93 @@ module Gosu
|
|
276
276
|
# @param scale_y [Float] the vertical scaling factor.
|
277
277
|
# @param color [Color, Fixnum]
|
278
278
|
# @param mode [:default, :additive] the blending mode to use.
|
279
|
-
#
|
279
|
+
#
|
280
280
|
# @see #draw_rel
|
281
281
|
# @see Gosu::Image.from_text
|
282
|
-
# @see https://github.com/
|
283
|
-
# @see https://github.com/
|
282
|
+
# @see https://github.com/gosu/gosu/wiki/Basic-Concepts#drawing-with-colours Drawing with colors, explained in the Gosu Wiki
|
283
|
+
# @see https://github.com/gosu/gosu/wiki/Basic-Concepts#z-ordering Z-ordering explained in the Gosu Wiki
|
284
284
|
def draw(text, x, y, z, scale_x=1, scale_y=1, color=0xff_ffffff, mode=:default); end
|
285
|
-
|
285
|
+
|
286
286
|
##
|
287
287
|
# Draws a single line of text relative to (x, y).
|
288
|
-
#
|
288
|
+
#
|
289
289
|
# The text is aligned to the drawing location according to the `rel_x` and `rel_y` parameters: a value of 0.0 corresponds to top and left, while 1.0 corresponds to bottom and right. A value of 0.5 naturally corresponds to the center of the text.
|
290
|
-
#
|
290
|
+
#
|
291
291
|
# All real numbers are valid alignment values and will be interpolated (or extrapolated) accordingly.
|
292
|
-
#
|
292
|
+
#
|
293
293
|
# @return [void]
|
294
294
|
# @param rel_x [Float] the horizontal alignment.
|
295
295
|
# @param rel_y [Float] the vertical alignment.
|
296
296
|
# @param (see #draw)
|
297
|
-
#
|
297
|
+
#
|
298
298
|
# @see #draw
|
299
|
-
# @see https://github.com/
|
300
|
-
# @see https://github.com/
|
299
|
+
# @see https://github.com/gosu/gosu/wiki/Basic-Concepts#drawing-with-colours Drawing with colors, explained in the Gosu Wiki
|
300
|
+
# @see https://github.com/gosu/gosu/wiki/Basic-Concepts#z-ordering Z-ordering explained in the Gosu Wiki
|
301
301
|
def draw_rel(text, x, y, z, rel_x, rel_y, scale_x=1, scale_y=1, color=0xff_ffffff, mode=:default); end
|
302
|
-
|
302
|
+
|
303
303
|
##
|
304
304
|
# @deprecated Use {#draw} in conjunction with {Gosu.rotate} instead.
|
305
|
-
#
|
305
|
+
#
|
306
306
|
# @see #draw
|
307
307
|
# @see Gosu::Window#rotate
|
308
308
|
def draw_rot(text, x, y, z, angle, scale_x=1, scale_y=1, color=0xff_ffffff, mode=:default); end
|
309
|
-
|
309
|
+
|
310
310
|
# @!endgroup
|
311
|
-
|
311
|
+
|
312
312
|
##
|
313
313
|
# Returns the width of a single line of text, in pixels, if it were drawn.
|
314
|
-
#
|
314
|
+
#
|
315
315
|
# @return [Fixnum] the width of the text, in pixels.
|
316
316
|
# @param text [String]
|
317
317
|
def text_width(text, scale_x=1); end
|
318
318
|
end
|
319
|
-
|
319
|
+
|
320
320
|
##
|
321
321
|
# Provides functionality for drawing rectangular images.
|
322
322
|
class Image
|
323
323
|
##
|
324
324
|
# @return [Fixnum] the image's width, in pixels.
|
325
325
|
attr_reader :width
|
326
|
-
|
326
|
+
|
327
327
|
##
|
328
328
|
# @return [Fixnum] the image's height, in pixels.
|
329
329
|
attr_reader :height
|
330
|
-
|
330
|
+
|
331
331
|
# @!group Creating and loading images
|
332
|
-
|
332
|
+
|
333
333
|
##
|
334
334
|
# Loads an image from a file or an RMagick image.
|
335
|
-
#
|
335
|
+
#
|
336
336
|
# (Passing a Window reference is not necessary anymore, please use the first overload from now on.)
|
337
|
-
#
|
337
|
+
#
|
338
338
|
# @note For Windows Bitmap (BMP) images, magenta (FF00FF, often called "magic pink" in this context) is treated as a chroma key and all pixels of that color are automatically rendered fully transparent.
|
339
|
-
#
|
339
|
+
#
|
340
340
|
# @param [String, Magick::Image] source the filename or RMagick image to load from.
|
341
341
|
# @param [Hash] options
|
342
342
|
# @option options [true, false] :tileable (false) if true, the Image will not have soft edges when scaled
|
343
|
+
# @option options [true, false] :retro (false) if true, the image will not be interpolated when it is scaled up or down. When :retro it set, :tileable has no effect.
|
343
344
|
# @option options [Array] :rect ([0, 0, image_width, image_height]) the source rectangle in the image
|
344
|
-
#
|
345
|
+
#
|
345
346
|
# @overload initialize(source, options = {})
|
346
347
|
# @overload initialize(window, source, tileable = false)
|
347
348
|
# @overload initialize(window, source, tileable, left, top, width, height)
|
348
|
-
#
|
349
|
+
#
|
349
350
|
# @see load_tiles
|
350
351
|
# @see from_text
|
351
|
-
# @see https://github.com/
|
352
|
+
# @see https://github.com/gosu/gosu/wiki/Basic-Concepts#tileability Tileability explained in the Gosu Wiki
|
352
353
|
def initialize(source, options = {}); end
|
353
|
-
|
354
|
+
|
354
355
|
##
|
355
356
|
# Creates a reusable image from one or more lines of text.
|
356
357
|
#
|
357
358
|
# (Passing a Window reference is not necessary anymore, please use the first overload from now on.)
|
358
|
-
#
|
359
|
+
#
|
359
360
|
# @note The text is always rendered in white. To draw it in a different color, use the color parameter of {#draw}, et al.
|
360
|
-
#
|
361
|
+
#
|
361
362
|
# @overload from_text(text, line_height, options = {})
|
362
363
|
# @overload from_text(window, text, font_name, line_height)
|
363
364
|
# @overload from_text(window, text, font_name, line_height, line_spacing, width, align)
|
364
|
-
#
|
365
|
+
#
|
365
366
|
# @return [Gosu::Image]
|
366
367
|
# @param [String] text
|
367
368
|
# @param [Fixnum] line_height the line height, in pixels.
|
@@ -370,14 +371,14 @@ module Gosu
|
|
370
371
|
# @option options [Fixnum] :width the width of the image, in pixels. Long lines will be automatically wrapped around to avoid overflow, but overlong words will be truncated. If this option is omitted, lines will not be wrapped, and :align and :spacing will be ignored as well.
|
371
372
|
# @option options [Fixnum] :spacing (0) the spacing between lines, in pixels.
|
372
373
|
# @option options [:left, :right, :center, :justify] :align (:left) the text alignment.
|
373
|
-
#
|
374
|
+
#
|
374
375
|
# @see Gosu::Font
|
375
|
-
# @see https://github.com/
|
376
|
+
# @see https://github.com/gosu/gosu/wiki/Basic-Concepts#drawing-with-colours Drawing with colors, explained in the Gosu Wiki
|
376
377
|
def self.from_text(text, line_height, options = {}); end
|
377
|
-
|
378
|
+
|
378
379
|
##
|
379
380
|
# Loads an image from a file or an RMagick image, then divides the image into an array of equal-sized tiles.
|
380
|
-
#
|
381
|
+
#
|
381
382
|
# @note For Windows Bitmap (BMP) images, magenta (FF00FF, often called "magic pink" in this context) is treated as a chroma key and all pixels of that color are automatically rendered fully transparent.
|
382
383
|
#
|
383
384
|
# @return [Array<Gosu::Image>]
|
@@ -386,281 +387,282 @@ module Gosu
|
|
386
387
|
# @param tile_height [Fixnum] If positive, this is the height of the individual tiles; if negative, the image is divided into -tile_height rows.
|
387
388
|
# @param [Hash] options
|
388
389
|
# @option options [true, false] :tileable (false) if true, the Image will not have soft edges when scaled
|
389
|
-
#
|
390
|
+
# @option options [true, false] :retro (false) if true, the image will not be interpolated when it is scaled up or down. When :retro it set, :tileable has no effect.
|
391
|
+
#
|
390
392
|
# @overload initialize(source, tile_width, tile_height, options = {})
|
391
393
|
# @overload initialize(window, source, tile_width, tile_height, tileable = false)
|
392
|
-
#
|
394
|
+
#
|
393
395
|
# (Passing a Window reference is not necessary anymore, please use the first overload from now on.)
|
394
|
-
#
|
395
|
-
# @see https://github.com/
|
396
|
+
#
|
397
|
+
# @see https://github.com/gosu/gosu/wiki/Basic-Concepts#tileability Tileability explained in the Gosu Wiki
|
396
398
|
def self.load_tiles(source, tile_width, tile_height, options = {}); end
|
397
|
-
|
399
|
+
|
398
400
|
# @!endgroup
|
399
|
-
|
401
|
+
|
400
402
|
# @!group Drawing an image
|
401
|
-
|
403
|
+
|
402
404
|
##
|
403
405
|
# Draws the image with its top left corner at (x, y).
|
404
|
-
#
|
406
|
+
#
|
405
407
|
# @return [void]
|
406
408
|
# @param x [Float] the X coordinate.
|
407
|
-
# @param y [Float] the
|
409
|
+
# @param y [Float] the Y coordinate.
|
408
410
|
# @param z [Float] the Z-order.
|
409
411
|
# @param scale_x [Float] the horizontal scaling factor.
|
410
412
|
# @param scale_y [Float] the vertical scaling factor.
|
411
413
|
# @param color [Gosu::Color, Integer]
|
412
414
|
# @param mode [:default, :additive] the blending mode to use.
|
413
|
-
#
|
415
|
+
#
|
414
416
|
# @see #draw_rot
|
415
417
|
# @see #draw_as_quad
|
416
|
-
# @see https://github.com/
|
417
|
-
# @see https://github.com/
|
418
|
+
# @see https://github.com/gosu/gosu/wiki/Basic-Concepts#drawing-with-colours Drawing with colors, explained in the Gosu Wiki
|
419
|
+
# @see https://github.com/gosu/gosu/wiki/Basic-Concepts#z-ordering Z-ordering explained in the Gosu Wiki
|
418
420
|
def draw(x, y, z, scale_x=1, scale_y=1, color=0xff_ffffff, mode=:default); end
|
419
|
-
|
421
|
+
|
420
422
|
##
|
421
423
|
# Draws the image rotated, with its rotational center at (x, y).
|
422
|
-
#
|
424
|
+
#
|
423
425
|
# @return [void]
|
424
426
|
# @param angle [Float]
|
425
427
|
# @param center_x [Float] the relative horizontal rotation origin.
|
426
428
|
# @param center_y [Float] the relative vertical rotation origin.
|
427
429
|
# @param (see #draw)
|
428
|
-
#
|
430
|
+
#
|
429
431
|
# @see #draw
|
430
|
-
# @see https://github.com/
|
431
|
-
# @see https://github.com/
|
432
|
+
# @see https://github.com/gosu/gosu/wiki/Basic-Concepts#drawing-with-colours Drawing with colors, explained in the Gosu Wiki
|
433
|
+
# @see https://github.com/gosu/gosu/wiki/Basic-Concepts#z-ordering Z-ordering explained in the Gosu Wiki
|
432
434
|
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
|
433
|
-
|
435
|
+
|
434
436
|
##
|
435
437
|
# 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.
|
436
|
-
#
|
438
|
+
#
|
437
439
|
# @return [void]
|
438
440
|
# @param (see Gosu.draw_quad)
|
439
|
-
#
|
441
|
+
#
|
440
442
|
# @see #draw
|
441
443
|
# @see Gosu.draw_quad
|
442
|
-
# @see https://github.com/
|
443
|
-
# @see https://github.com/
|
444
|
-
# @see https://github.com/
|
444
|
+
# @see https://github.com/gosu/gosu/wiki/Basic-Concepts#drawing-with-colours Drawing with colors, explained in the Gosu Wiki
|
445
|
+
# @see https://github.com/gosu/gosu/wiki/Basic-Concepts#order-of-corners The order of corners explained in the Gosu Wiki
|
446
|
+
# @see https://github.com/gosu/gosu/wiki/Basic-Concepts#z-ordering Z-ordering explained in the Gosu Wiki
|
445
447
|
def draw_as_quad(x1, y1, c1, x2, y2, c2, x3, y3, c3, x4, y4, c4, z, mode=:default); end
|
446
|
-
|
448
|
+
|
447
449
|
# @!endgroup
|
448
|
-
|
450
|
+
|
449
451
|
##
|
450
452
|
# Returns an object that holds information about the underlying OpenGL texture and UV coordinates of the image.
|
451
|
-
#
|
453
|
+
#
|
452
454
|
# @note Some images may be too large to fit on a single texture; this method returns nil in those cases.
|
453
|
-
#
|
455
|
+
#
|
454
456
|
# @return [Gosu::GLTexInfo?] information about the underlying OpenGL texture.
|
455
|
-
#
|
457
|
+
#
|
456
458
|
# @see Gosu::GLTexInfo
|
457
459
|
# @see file:examples/OpenGLIntegration.rb
|
458
460
|
def gl_tex_info; end
|
459
|
-
|
461
|
+
|
460
462
|
##
|
461
463
|
# Returns the associated texture contents as binary string of packed RGBA values, useful for use with RMagick (Magick::Image.from_blob).
|
462
|
-
#
|
464
|
+
#
|
463
465
|
# @return [String] a binary string of packed RGBA values.
|
464
466
|
def to_blob; end
|
465
|
-
|
467
|
+
|
466
468
|
##
|
467
469
|
# Overwrites part of the image with the contents of another. If the source image is partially out of bounds, it will be clipped to fit.
|
468
|
-
#
|
470
|
+
#
|
469
471
|
# This can be used to e.g. overwrite parts of a landscape.
|
470
|
-
#
|
472
|
+
#
|
471
473
|
# @return [void]
|
472
474
|
# @param source [String, Magick::Image] the filename or RMagick image to load from.
|
473
475
|
# @param x [Fixnum] the X coordinate of the top left corner.
|
474
476
|
# @param y [Fixnum] the Y coordinate of the top left corner.
|
475
477
|
def insert(source, x, y); end
|
476
|
-
|
478
|
+
|
477
479
|
##
|
478
480
|
# Saves the image to a file. The file format is determined from the file extension.
|
479
|
-
#
|
481
|
+
#
|
480
482
|
# Useful for, e.g., pre-rendering text on a development machine where the necessary fonts are known to be available.
|
481
|
-
#
|
483
|
+
#
|
482
484
|
# @return [void]
|
483
485
|
# @param filename [String] the path to save the file under.
|
484
486
|
def save(filename); end
|
485
487
|
end
|
486
|
-
|
488
|
+
|
487
489
|
##
|
488
490
|
# A sample is a short sound that is completely loaded in memory, can be
|
489
491
|
# played multiple times at once and offers very flexible playback
|
490
492
|
# parameters. Use samples for everything that's not music.
|
491
|
-
#
|
493
|
+
#
|
492
494
|
# @see Gosu::Song
|
493
495
|
class Sample
|
494
496
|
##
|
495
497
|
# Loads a sample from a file.
|
496
|
-
#
|
498
|
+
#
|
497
499
|
# (Passing a Window reference is not necessary anymore, please use the first overload from now on.)
|
498
|
-
#
|
500
|
+
#
|
499
501
|
# @overload initialize(filename)
|
500
502
|
# @overload initialize(window, filename)
|
501
503
|
#
|
502
504
|
# @param filename [String] the path to load the sample from.
|
503
505
|
def initialize(filename); end
|
504
|
-
|
506
|
+
|
505
507
|
##
|
506
508
|
# Plays the sample without panning.
|
507
|
-
#
|
509
|
+
#
|
508
510
|
# Playback speed is limited only by the underlying audio library, and both very large and very small values should work just fine.
|
509
511
|
#
|
510
512
|
# @return [SampleInstance]
|
511
513
|
# @param volume [Float] the playback volume, in the range (0..1), where 0 is completely silent and 1 is full volume.
|
512
514
|
# @param speed [Float] the playback speed.
|
513
515
|
# @param looping [true, false] whether the sample should play in a loop.
|
514
|
-
#
|
516
|
+
#
|
515
517
|
# @see #play_pan
|
516
518
|
def play(volume=1, speed=1, looping=false); end
|
517
|
-
|
519
|
+
|
518
520
|
##
|
519
521
|
# Plays the sample with panning.
|
520
|
-
#
|
522
|
+
#
|
521
523
|
# @note Samples played with this method will not be as loud as those played with {#play}, even if `pan` is 0. This is due to a limitation in the way panning works.
|
522
524
|
#
|
523
525
|
# @return [SampleInstance]
|
524
526
|
# @param pan [Float] the amount of panning. 0 is centered.
|
525
527
|
# @param (see #play)
|
526
|
-
#
|
528
|
+
#
|
527
529
|
# @see #play
|
528
530
|
def play_pan(pan=0, volume=1, speed=1, looping=false); end
|
529
531
|
end
|
530
|
-
|
532
|
+
|
531
533
|
##
|
532
534
|
# An instance of a {Gosu::Sample} playing. Can be used to stop sounds dynamically, or to check if they are finished.
|
533
|
-
#
|
535
|
+
#
|
534
536
|
# It is recommended to throw away sample instances as soon as possible, as holding onto them for a long time can prevent unneeded samples being properly disposed.
|
535
537
|
class SampleInstance
|
536
538
|
attr_writer :volume
|
537
539
|
attr_writer :speed
|
538
540
|
attr_writer :pan
|
539
|
-
|
541
|
+
|
540
542
|
##
|
541
543
|
# Stops playback of this sample instance. After calling this method, the sample instance is useless and can be discarded.
|
542
|
-
#
|
544
|
+
#
|
543
545
|
# Calling `stop` after the sample has finished is harmless and has no effect.
|
544
|
-
#
|
546
|
+
#
|
545
547
|
# @return [void]
|
546
548
|
def stop; end
|
547
|
-
|
549
|
+
|
548
550
|
##
|
549
551
|
# Pauses the sample, to be resumed afterwards.
|
550
|
-
#
|
552
|
+
#
|
551
553
|
# @note The sample will still occupy a playback channel while paused.
|
552
|
-
#
|
554
|
+
#
|
553
555
|
# @return [void]
|
554
556
|
def pause; end
|
555
|
-
|
557
|
+
|
556
558
|
##
|
557
559
|
# Resumes playback of the sample.
|
558
|
-
#
|
560
|
+
#
|
559
561
|
# @return [void]
|
560
562
|
def resume; end
|
561
|
-
|
563
|
+
|
562
564
|
##
|
563
565
|
# @return [true, false] whether the sample is paused.
|
564
566
|
def paused?; end
|
565
|
-
|
567
|
+
|
566
568
|
##
|
567
569
|
# @return [true, false] whether the sample is playing.
|
568
570
|
def playing?; end
|
569
571
|
end
|
570
|
-
|
572
|
+
|
571
573
|
##
|
572
574
|
# Songs are less flexible than samples in that only one can be played at a time, with no panning or speed control.
|
573
|
-
#
|
575
|
+
#
|
574
576
|
# @see Gosu::Sample
|
575
577
|
class Song
|
576
578
|
class <<Song
|
577
579
|
##
|
578
580
|
# Returns the song currently being played (even if it's paused), or nil if no song is playing.
|
579
|
-
#
|
581
|
+
#
|
580
582
|
# @return [Gosu::Song?] the currently playing song.
|
581
583
|
attr_reader :current_song
|
582
584
|
end
|
583
|
-
|
585
|
+
|
584
586
|
##
|
585
587
|
# @return [Float] the song's playback volume.
|
586
588
|
attr_accessor :volume
|
587
|
-
|
589
|
+
|
588
590
|
##
|
589
591
|
# Loads a song from a file.
|
590
|
-
#
|
592
|
+
#
|
591
593
|
# (Passing a Window reference is not necessary anymore, please use the first overload instead.)
|
592
|
-
#
|
594
|
+
#
|
593
595
|
# @overload initialize(filename)
|
594
596
|
# @overload initialize(window, filename)
|
595
597
|
#
|
596
598
|
# @param filename [String] the path to load the song from.
|
597
599
|
def initialize(window, filename); end
|
598
|
-
|
600
|
+
|
599
601
|
##
|
600
602
|
# Starts or resumes playback of the song.
|
601
|
-
#
|
603
|
+
#
|
602
604
|
# If another song is currently playing, it will be stopped and this song will be set as the current song.
|
603
|
-
#
|
605
|
+
#
|
604
606
|
# If `looping` is false, the current song will be set to `nil` when this song finishes.
|
605
|
-
#
|
607
|
+
#
|
606
608
|
# @return [void]
|
607
609
|
# @param looping [true, false] whether the song should play in a loop.
|
608
610
|
def play(looping=false); end
|
609
|
-
|
611
|
+
|
610
612
|
##
|
611
613
|
# Pauses playback of the song. The current song is unchanged.
|
612
|
-
#
|
614
|
+
#
|
613
615
|
# @return [void]
|
614
616
|
def pause; end
|
615
|
-
|
617
|
+
|
616
618
|
# Returns true if this song is the current song and playback is paused.
|
617
|
-
#
|
619
|
+
#
|
618
620
|
# @return [true, false] whether the song is paused.
|
619
621
|
def paused?; end
|
620
|
-
|
622
|
+
|
621
623
|
##
|
622
624
|
# Stops playback if this song is the current song. The current song is set to `nil`.
|
623
|
-
#
|
625
|
+
#
|
624
626
|
# @return [void]
|
625
627
|
def stop; end
|
626
|
-
|
628
|
+
|
627
629
|
##
|
628
630
|
# @return [true, false] whether the song is playing.
|
629
631
|
def playing?; end
|
630
632
|
end
|
631
|
-
|
633
|
+
|
632
634
|
##
|
633
635
|
# A TextInput is an invisible object that handles input using the operating system's input manager.
|
634
636
|
#
|
635
637
|
# At its most basic, you only need to set {Gosu::Window#text_input} to an instance of this class. The TextInput will then handle all keyboard input until {Gosu::Window#text_input} is set to `nil`. Any text the user has typed is available through {#text}.
|
636
638
|
#
|
637
639
|
# This class is purely back-end and does not come with a GUI; drawing the input field is up to you, the programmer. The best way to do that is left completely open. TextInput only aims to provide a foundation for you to build your own GUI.
|
638
|
-
#
|
640
|
+
#
|
639
641
|
# @see Gosu::Window#text_input
|
640
642
|
# @see file:examples/TextInput.rb
|
641
643
|
class TextInput
|
642
644
|
##
|
643
645
|
# @return [String] the text that the user has typed.
|
644
646
|
attr_accessor :text
|
645
|
-
|
647
|
+
|
646
648
|
##
|
647
649
|
# @return [Fixnum] the position of the editing caret.
|
648
650
|
attr_accessor :caret_pos
|
649
|
-
|
651
|
+
|
650
652
|
##
|
651
653
|
# @return [Fixnum] the starting position of the currently selected text.
|
652
654
|
attr_accessor :selection_start
|
653
|
-
|
655
|
+
|
654
656
|
##
|
655
657
|
# This method is an overridable filter that is applied to all newly entered text. This allows for restricting input characters or format, automatic macro or abbreviation expansion and so on.
|
656
|
-
#
|
658
|
+
#
|
657
659
|
# The return value of this method will be inserted at the current caret position.
|
658
|
-
#
|
660
|
+
#
|
659
661
|
# The default implementation returns its argument unchanged.
|
660
|
-
#
|
662
|
+
#
|
661
663
|
# @return [String] the string to be inserted.
|
662
664
|
# @param text_in [String] the text typed by the user.
|
663
|
-
#
|
665
|
+
#
|
664
666
|
# @example Forcing input to all uppercase, alphanumeric characters.
|
665
667
|
# input = TextInput.new
|
666
668
|
# def input.filter(text_in)
|
@@ -670,7 +672,7 @@ module Gosu
|
|
670
672
|
text_in
|
671
673
|
end
|
672
674
|
end
|
673
|
-
|
675
|
+
|
674
676
|
##
|
675
677
|
# Main class that serves as the foundation of a standard
|
676
678
|
# Gosu application. Manages initialization of all of Gosu's core components
|
@@ -682,127 +684,127 @@ module Gosu
|
|
682
684
|
# @note There should really only be one instance of this class at a time. This may or may not change later.
|
683
685
|
class Window
|
684
686
|
##
|
685
|
-
# @return [String] the window's caption, usually
|
687
|
+
# @return [String] the window's caption, usually displayed in the title bar.
|
686
688
|
attr_accessor :caption
|
687
|
-
|
689
|
+
|
688
690
|
##
|
689
691
|
# @return [Float] the mouse pointer's window-based X coordinate.
|
690
692
|
attr_accessor :mouse_x
|
691
|
-
|
693
|
+
|
692
694
|
##
|
693
695
|
# @return [Float] the mouse pointer's window-based Y coordinate.
|
694
696
|
attr_accessor :mouse_y
|
695
|
-
|
697
|
+
|
696
698
|
##
|
697
699
|
# The currently active {TextInput}. If not nil, all keyboard input will be handled by this object.
|
698
|
-
#
|
700
|
+
#
|
699
701
|
# @return [TextInput?] the currently active text input, if any.
|
700
702
|
attr_accessor :text_input
|
701
|
-
|
703
|
+
|
702
704
|
##
|
703
705
|
# The window's width, in pixels. This only counts the drawable area and does not include any borders or decorations added by the window manager.
|
704
|
-
#
|
706
|
+
#
|
705
707
|
# @return [Fixnum] the window's width, in pixels.
|
706
708
|
attr_reader :width
|
707
|
-
|
709
|
+
|
708
710
|
##
|
709
711
|
# The window's height, in pixels. This only counts the drawable area and does not include any borders or decorations added by the window manager.
|
710
|
-
#
|
712
|
+
#
|
711
713
|
# @return [Fixnum] the window's height, in pixels.
|
712
714
|
attr_reader :height
|
713
|
-
|
715
|
+
|
714
716
|
##
|
715
717
|
# @return [true, false] whether this is a full-screen window.
|
716
718
|
attr_reader :fullscreen?
|
717
|
-
|
719
|
+
|
718
720
|
##
|
719
721
|
# @return [Float] the interval between calls to {#update}, in milliseconds.
|
720
722
|
attr_reader :update_interval
|
721
|
-
|
723
|
+
|
722
724
|
##
|
723
725
|
# Creates a new window with the requested size.
|
724
|
-
#
|
726
|
+
#
|
725
727
|
# @note The actual window may be smaller if the requested size is too large for the current display resolution; in that case, Gosu will automatically scale all coordinates to transparently emulate a larger window. No need to thank us.
|
726
|
-
#
|
728
|
+
#
|
727
729
|
# @overload initialize(width, height, options = {})
|
728
730
|
# @overload initialize(width, height, fullscreen, update_interval = 16.666666)
|
729
|
-
#
|
731
|
+
#
|
730
732
|
# @param width [Fixnum] the desired window width.
|
731
733
|
# @param height [Fixnum] the desired window height.
|
732
734
|
# @param [Hash] options
|
733
735
|
# @option options [true, false] :fullscreen (false) whether to present the window in fullscreen mode.
|
734
736
|
# @option options [Float] :update_interval (16.666666) the interval between frames, in milliseconds.
|
735
737
|
def initialize(width, height, options); end
|
736
|
-
|
738
|
+
|
737
739
|
##
|
738
740
|
# Enters a modal loop where the Window is visible on screen and receives calls to draw, update etc.
|
739
|
-
#
|
741
|
+
#
|
740
742
|
# @return [void]
|
741
743
|
def show; end
|
742
|
-
|
744
|
+
|
743
745
|
##
|
744
746
|
# Tells the window to end the current run loop as soon as possible. Calling this method will not prevent execution of lines after it.
|
745
|
-
#
|
747
|
+
#
|
746
748
|
# @return [void]
|
747
|
-
def close; end
|
748
|
-
|
749
|
+
def close; end
|
750
|
+
|
749
751
|
# @!group Callbacks
|
750
|
-
|
752
|
+
|
751
753
|
##
|
752
754
|
# This method is called once every {#update_interval} milliseconds while the window is being shown. Your application's main logic should go here.
|
753
|
-
#
|
755
|
+
#
|
754
756
|
# @return [void]
|
755
757
|
def update; end
|
756
|
-
|
758
|
+
|
757
759
|
##
|
758
760
|
# This method is called after every update and whenever the OS wants the window to repaint itself. Your application's rendering code should go here.
|
759
|
-
#
|
761
|
+
#
|
760
762
|
# @return [void]
|
761
|
-
#
|
763
|
+
#
|
762
764
|
# @see #needs_redraw?
|
763
765
|
def draw; end
|
764
|
-
|
766
|
+
|
765
767
|
##
|
766
768
|
# This method can be overriden to give the game a chance to opt out of a call to {#draw}; however, the operating system can still force a redraw for any reason.
|
767
769
|
#
|
768
770
|
# @return [true, false] whether the window needs to be redrawn.
|
769
|
-
#
|
771
|
+
#
|
770
772
|
# @see #draw
|
771
773
|
def needs_redraw?; end
|
772
|
-
|
774
|
+
|
773
775
|
##
|
774
776
|
# This method can be overriden to control the visibility of the system cursor over your window, e.g., for level editors or other situations where introducing a custom cursor or hiding the default one is not desired.
|
775
|
-
#
|
777
|
+
#
|
776
778
|
# @return [true, false] whether the system cursor should be shown.
|
777
779
|
def needs_cursor?; end
|
778
|
-
|
780
|
+
|
779
781
|
##
|
780
782
|
# This method is called before {#update} if a button was pressed while the window had focus.
|
781
|
-
#
|
783
|
+
#
|
782
784
|
# @return [void]
|
783
785
|
# @param id [Fixnum] the button's platform-defined id.
|
784
|
-
#
|
786
|
+
#
|
785
787
|
# @see #button_up
|
786
788
|
# @see Gosu.button_down?
|
787
789
|
def button_down(id); end
|
788
|
-
|
790
|
+
|
789
791
|
##
|
790
792
|
# This method is called before {#update} if a button was released while the window had focus.
|
791
|
-
#
|
793
|
+
#
|
792
794
|
# @return [void]
|
793
795
|
# @param (see #button_down)
|
794
|
-
#
|
796
|
+
#
|
795
797
|
# @see #button_down
|
796
798
|
# @see Gosu.button_down?
|
797
799
|
def button_up(id); end
|
798
|
-
|
800
|
+
|
799
801
|
# @!endgroup
|
800
|
-
|
802
|
+
|
801
803
|
##
|
802
804
|
# @deprecated Use {#mouse_x=} and {#mouse_y=} instead.
|
803
805
|
def set_mouse_position(x, y); end
|
804
806
|
end
|
805
|
-
|
807
|
+
|
806
808
|
##
|
807
809
|
# Holds information about the underlying OpenGL texture and UV coordinates of an image.
|
808
810
|
#
|
@@ -814,19 +816,19 @@ module Gosu
|
|
814
816
|
##
|
815
817
|
# @return [Fixnum] OpenGL texture id
|
816
818
|
attr_reader :tex_name
|
817
|
-
|
819
|
+
|
818
820
|
##
|
819
821
|
# @return [Float] the U coordinate of the left edge of the image.
|
820
822
|
attr_reader :left
|
821
|
-
|
823
|
+
|
822
824
|
##
|
823
825
|
# @return [Float] the U coordinate of the right edge of the image.
|
824
826
|
attr_reader :right
|
825
|
-
|
827
|
+
|
826
828
|
##
|
827
829
|
# @return [Float] the V coordinate of the top edge of the image.
|
828
830
|
attr_reader :top
|
829
|
-
|
831
|
+
|
830
832
|
##
|
831
833
|
# @return [Float] the V coordinate of the bottom edge of the image.
|
832
834
|
attr_reader :bottom
|
@@ -835,21 +837,21 @@ module Gosu
|
|
835
837
|
class << self
|
836
838
|
##
|
837
839
|
# Returns whether the button `id` is currently pressed. Button states are updated once per tick, so repeated calls during the same tick will always yield the same result.
|
838
|
-
#
|
840
|
+
#
|
839
841
|
# @return [true, false] whether the button is currently pressed.
|
840
842
|
# @param (see #button_down)
|
841
|
-
#
|
843
|
+
#
|
842
844
|
# @see Window#button_down
|
843
845
|
# @see Window#button_up
|
844
846
|
def button_down?(id); end
|
845
|
-
|
847
|
+
|
846
848
|
# @!group Drawing primitives
|
847
|
-
|
849
|
+
|
848
850
|
##
|
849
851
|
# Draws a line from one point to another---inconsistently.
|
850
|
-
#
|
852
|
+
#
|
851
853
|
# @note OpenGL lines are not reliable at all and may have a missing pixel at the start or end point. Relying on your machine's behavior can only end in tears. Recommended for debugging purposes only.
|
852
|
-
#
|
854
|
+
#
|
853
855
|
# @return [void]
|
854
856
|
# @param x1 [Float] the X coordinate of the start point.
|
855
857
|
# @param y1 [Float] the Y coordinate of the start point.
|
@@ -859,16 +861,16 @@ module Gosu
|
|
859
861
|
# @param c2 [Gosu::Color] the color of the end point.
|
860
862
|
# @param z [Float] the Z-order.
|
861
863
|
# @param mode [:default, :additive] the blending mode to use.
|
862
|
-
#
|
864
|
+
#
|
863
865
|
# @see draw_triangle
|
864
866
|
# @see draw_quad
|
865
|
-
# @see https://github.com/
|
866
|
-
# @see https://github.com/
|
867
|
+
# @see https://github.com/gosu/gosu/wiki/Basic-Concepts#drawing-with-colours Drawing with colors, explained in the Gosu Wiki
|
868
|
+
# @see https://github.com/gosu/gosu/wiki/Basic-Concepts#z-ordering Z-ordering explained in the Gosu Wiki
|
867
869
|
def draw_line(x1, y1, c1, x2, y2, c2, z=0, mode=:default); end
|
868
|
-
|
870
|
+
|
869
871
|
##
|
870
872
|
# Draws a triangle.
|
871
|
-
#
|
873
|
+
#
|
872
874
|
# @return [void]
|
873
875
|
# @param x1 [Float] the X coordinate of the first vertex.
|
874
876
|
# @param y1 [Float] the Y coordinate of the first vertex.
|
@@ -885,13 +887,13 @@ module Gosu
|
|
885
887
|
# @see draw_line
|
886
888
|
# @see draw_rect
|
887
889
|
# @see draw_quad
|
888
|
-
# @see https://github.com/
|
889
|
-
# @see https://github.com/
|
890
|
+
# @see https://github.com/gosu/gosu/wiki/Basic-Concepts#drawing-with-colours Drawing with colors, explained in the Gosu Wiki
|
891
|
+
# @see https://github.com/gosu/gosu/wiki/Basic-Concepts#z-ordering Z-ordering explained in the Gosu Wiki
|
890
892
|
def draw_triangle(x1, y1, c1, x2, y2, c2, x3, y3, c3, z=0, mode=:default); end
|
891
|
-
|
893
|
+
|
892
894
|
##
|
893
895
|
# Draws a rectangle (actually a quad, or two triangles).
|
894
|
-
#
|
896
|
+
#
|
895
897
|
# @return [void]
|
896
898
|
# @param x [Float] the X coordinate of the rectangle’s top left corner.
|
897
899
|
# @param y [Float] the Y coordinate of the rectangle’s top left corner.
|
@@ -904,14 +906,14 @@ module Gosu
|
|
904
906
|
# @see draw_line
|
905
907
|
# @see draw_triangle
|
906
908
|
# @see draw_quad
|
907
|
-
# @see https://github.com/
|
908
|
-
# @see https://github.com/
|
909
|
-
# @see https://github.com/
|
909
|
+
# @see https://github.com/gosu/gosu/wiki/Basic-Concepts#drawing-with-colours Drawing with colors, explained in the Gosu Wiki
|
910
|
+
# @see https://github.com/gosu/gosu/wiki/Basic-Concepts#order-of-corners The order of corners explained in the Gosu Wiki
|
911
|
+
# @see https://github.com/gosu/gosu/wiki/Basic-Concepts#z-ordering Z-ordering explained in the Gosu Wiki
|
910
912
|
def draw_rect(x, y, width, height, c, z=0, mode=:default); end
|
911
|
-
|
913
|
+
|
912
914
|
##
|
913
915
|
# Draws a quad (actually two triangles).
|
914
|
-
#
|
916
|
+
#
|
915
917
|
# @return [void]
|
916
918
|
# @param x1 [Float] the X coordinate of the first vertex.
|
917
919
|
# @param y1 [Float] the Y coordinate of the first vertex.
|
@@ -931,54 +933,54 @@ module Gosu
|
|
931
933
|
# @see draw_line
|
932
934
|
# @see draw_triangle
|
933
935
|
# @see draw_rect
|
934
|
-
# @see https://github.com/
|
935
|
-
# @see https://github.com/
|
936
|
-
# @see https://github.com/
|
936
|
+
# @see https://github.com/gosu/gosu/wiki/Basic-Concepts#drawing-with-colours Drawing with colors, explained in the Gosu Wiki
|
937
|
+
# @see https://github.com/gosu/gosu/wiki/Basic-Concepts#order-of-corners The order of corners explained in the Gosu Wiki
|
938
|
+
# @see https://github.com/gosu/gosu/wiki/Basic-Concepts#z-ordering Z-ordering explained in the Gosu Wiki
|
937
939
|
def draw_quad(x1, y1, c1, x2, y2, c2, x3, y3, c3, x4, y4, c4, z=0, mode=:default); end
|
938
|
-
|
940
|
+
|
939
941
|
# @!endgroup
|
940
942
|
# @!group Manipulating the current drawing context
|
941
|
-
|
943
|
+
|
942
944
|
##
|
943
945
|
# Flushes all drawing operations to OpenGL so that Z-ordering can start anew. This is useful for drawing multiple layers that may not have knowledge of each other's Z-ordering, e.g., drawing a HUD on top of the game world or ensuring that a custom cursor is always drawn above everything else.
|
944
|
-
#
|
946
|
+
#
|
945
947
|
# @return [void]
|
946
948
|
def flush; end
|
947
|
-
|
949
|
+
|
948
950
|
##
|
949
951
|
# Runs the block in a clean OpenGL environment.
|
950
|
-
#
|
952
|
+
#
|
951
953
|
# If a Z-order is given, the block will be scheduled to run between Gosu drawing operations as normal; otherwise, all prior drawing operations will be flushed and the block will be executed immediately.
|
952
|
-
#
|
954
|
+
#
|
953
955
|
# @note Gosu does not provide access to the underlying OpenGL APIs. A gem like ruby-opengl is required to use custom OpenGL drawing code.
|
954
956
|
#
|
955
957
|
# @note Gosu rendering functions MUST NOT be used within the block, and {gl} MUST be used only within the call tree of {Window#draw}.
|
956
|
-
#
|
958
|
+
#
|
957
959
|
# @return [void]
|
958
960
|
# @param z [Float] the Z-order.
|
959
961
|
# @yield OpenGL code.
|
960
|
-
#
|
962
|
+
#
|
961
963
|
# @see Window#draw
|
962
964
|
# @see file:reference/Z-Ordering
|
963
965
|
# @see file:examples/OpenGLIntegration.rb
|
964
966
|
def gl(z=nil); end
|
965
|
-
|
967
|
+
|
966
968
|
##
|
967
969
|
# Masks the drawing area inside the block.
|
968
|
-
#
|
970
|
+
#
|
969
971
|
# @return [void]
|
970
972
|
# @param x [Float] the X coordinate of the top left corner,.
|
971
973
|
# @param y [Float] the Y coordinate of the top left corner.
|
972
974
|
# @param w [Float] the width of the clipping area.
|
973
975
|
# @param h [Float] the height of the clipping area.
|
974
976
|
# @yield rendering code.
|
975
|
-
#
|
977
|
+
#
|
976
978
|
# @see Window#draw
|
977
979
|
def clip_to(x, y, w, h); end
|
978
|
-
|
980
|
+
|
979
981
|
##
|
980
982
|
# Records all drawing operations inside the block as a reusable "image". This method can be used to speed rendering of multiple static images, e.g., a fixed tile map.
|
981
|
-
#
|
983
|
+
#
|
982
984
|
# @note Because the returned object is not a true image---it's implemented using vertex buffers and is not backed by a texture---there are restrictions on how it can be used.
|
983
985
|
#
|
984
986
|
# @note The width and height of the returned object will be the same values you passed to {record}, regardless of the area you draw on. It is important to pass accurate values if you plan on using {Gosu::Image#draw_as_quad} or {Gosu::Image#draw_rot} with the result later.
|
@@ -987,62 +989,62 @@ module Gosu
|
|
987
989
|
# @param width [Float] the width of the recorded image.
|
988
990
|
# @param height [Float] the height of the recorded image.
|
989
991
|
# @yield rendering code.
|
990
|
-
#
|
992
|
+
#
|
991
993
|
# @see Window#draw
|
992
994
|
# @see Gosu::Image
|
993
995
|
def record(width, height); end
|
994
|
-
|
996
|
+
|
995
997
|
##
|
996
998
|
# Rotates all drawing operations inside the block.
|
997
|
-
#
|
999
|
+
#
|
998
1000
|
# @return [void]
|
999
1001
|
# @param angle [Float] the rotation angle.
|
1000
|
-
# @param around_x [Float] the X
|
1002
|
+
# @param around_x [Float] the X coordinate of the rotation origin.
|
1001
1003
|
# @param around_y [Float] the Y coordinate of the rotation origin.
|
1002
1004
|
# @yield rendering code.
|
1003
|
-
#
|
1005
|
+
#
|
1004
1006
|
# @see Window#draw
|
1005
1007
|
# @see scale
|
1006
1008
|
# @see translate
|
1007
1009
|
# @see transform
|
1008
1010
|
def rotate(angle, around_x=0, around_y=0); end
|
1009
|
-
|
1011
|
+
|
1010
1012
|
##
|
1011
1013
|
# Scales all drawing operations inside the block.
|
1012
|
-
#
|
1014
|
+
#
|
1013
1015
|
# @overload scale(scale_x, scale_y = scale_x) { ... }
|
1014
1016
|
# @overload scale(scale_x, scale_y, around_x, around_y) { ... }
|
1015
|
-
#
|
1017
|
+
#
|
1016
1018
|
# @return [void]
|
1017
1019
|
# @param scale_x [Float] the horizontal scaling factor.
|
1018
1020
|
# @param scale_y [Float] the vertical scaling factor.
|
1019
1021
|
# @param around_x [Float] the X coordinate of the scaling origin.
|
1020
1022
|
# @param around_y [Float] the Y coordinate of the scaling origin.
|
1021
1023
|
# @yield rendering code.
|
1022
|
-
#
|
1024
|
+
#
|
1023
1025
|
# @see Window#draw
|
1024
1026
|
# @see rotate
|
1025
1027
|
# @see translate
|
1026
1028
|
# @see transform
|
1027
1029
|
def scale(scale_x, scale_y, around_x, around_y); end
|
1028
|
-
|
1030
|
+
|
1029
1031
|
##
|
1030
1032
|
# Offsets all drawing operations inside the block.
|
1031
|
-
#
|
1033
|
+
#
|
1032
1034
|
# @return [void]
|
1033
1035
|
# @param x [Float] the X offset.
|
1034
1036
|
# @param y [Float] the Y offset.
|
1035
1037
|
# @yield rendering code.
|
1036
|
-
#
|
1038
|
+
#
|
1037
1039
|
# @see Window#draw
|
1038
1040
|
# @see rotate
|
1039
1041
|
# @see scale
|
1040
1042
|
# @see transform
|
1041
1043
|
def translate(x, y); end
|
1042
|
-
|
1044
|
+
|
1043
1045
|
##
|
1044
1046
|
# Applies a free-form matrix transformation to everything drawn in the block.
|
1045
|
-
#
|
1047
|
+
#
|
1046
1048
|
# @return [void]
|
1047
1049
|
# @param m0 [Float]
|
1048
1050
|
# @param m1 [Float]
|
@@ -1061,39 +1063,39 @@ module Gosu
|
|
1061
1063
|
# @param m14 [Float]
|
1062
1064
|
# @param m15 [Float]
|
1063
1065
|
# @yield rendering code.
|
1064
|
-
#
|
1066
|
+
#
|
1065
1067
|
# @see Window#draw
|
1066
1068
|
# @see rotate
|
1067
1069
|
# @see scale
|
1068
1070
|
# @see translate
|
1069
1071
|
def transform(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15); end
|
1070
|
-
|
1072
|
+
|
1071
1073
|
# @!endgroup
|
1072
|
-
|
1074
|
+
|
1073
1075
|
##
|
1074
1076
|
# Returns the character a button usually produces, if any.
|
1075
|
-
#
|
1077
|
+
#
|
1076
1078
|
# @note For real text input, look at {TextInput} instead.
|
1077
|
-
#
|
1079
|
+
#
|
1078
1080
|
# @return [String?] the character the button usually produces.
|
1079
1081
|
# @param id [Fixnum] the button's platform-defined id.
|
1080
|
-
#
|
1082
|
+
#
|
1081
1083
|
# @see char_to_button_id
|
1082
1084
|
# @see Window#text_input
|
1083
1085
|
# @see TextInput
|
1084
1086
|
def self.button_id_to_char(id); end
|
1085
|
-
|
1087
|
+
|
1086
1088
|
##
|
1087
1089
|
# Returns the button that usually produces a character, if any.
|
1088
|
-
#
|
1090
|
+
#
|
1089
1091
|
# @return [Fixnum?] the button that usually produces the character.
|
1090
1092
|
# @param char [String] the character to query.
|
1091
|
-
#
|
1093
|
+
#
|
1092
1094
|
# @see button_id_to_char
|
1093
1095
|
# @see Window#text_input
|
1094
1096
|
# @see TextInput
|
1095
1097
|
def self.char_to_button_id(char); end
|
1096
|
-
|
1098
|
+
|
1097
1099
|
##
|
1098
1100
|
# @return [Float] a random number in the range (min...max).
|
1099
1101
|
# @param min [Float] the minimum value, inclusive.
|
@@ -1136,7 +1138,7 @@ module Gosu
|
|
1136
1138
|
|
1137
1139
|
##
|
1138
1140
|
# @note For long-running games, this counter will eventually wrap around to 0 again.
|
1139
|
-
#
|
1141
|
+
#
|
1140
1142
|
# @return [Fixnum] the number of milliseconds elapsed.
|
1141
1143
|
def milliseconds(); end
|
1142
1144
|
|
@@ -1145,7 +1147,7 @@ module Gosu
|
|
1145
1147
|
def fps(); end
|
1146
1148
|
|
1147
1149
|
# @return [String] the name of a neutral font that is available on the current platform.
|
1148
|
-
#
|
1150
|
+
#
|
1149
1151
|
# @see Gosu::Font
|
1150
1152
|
# @see Gosu::Image#from_text
|
1151
1153
|
def default_font_name(); end
|
@@ -1170,7 +1172,7 @@ module Gosu
|
|
1170
1172
|
# Returns the language code for the user's preferred language.
|
1171
1173
|
# Expect return values such as 'en_US', 'de_DE.UTF-8', 'ja', 'zh-Hans', etc.
|
1172
1174
|
# You can rely only the first two letters being a language abbreviation.
|
1173
|
-
#
|
1175
|
+
#
|
1174
1176
|
# @return [String] the user's preferred language.
|
1175
1177
|
def language(); end
|
1176
1178
|
end
|
@@ -1182,25 +1184,25 @@ end
|
|
1182
1184
|
class ::Numeric
|
1183
1185
|
##
|
1184
1186
|
# Converts radians to a Gosu-compatible angle using the formula <tt>self * 180.0 / Math::PI + 90</tt>.
|
1185
|
-
#
|
1187
|
+
#
|
1186
1188
|
# @return [Float] degrees.
|
1187
1189
|
def radians_to_gosu(); end
|
1188
1190
|
|
1189
1191
|
##
|
1190
1192
|
# Converts a Gosu-compatible angle to radians using the formula <tt>(self - 90) * Math::PI / 180.0</tt>.
|
1191
|
-
#
|
1193
|
+
#
|
1192
1194
|
# @return [Float] radians.
|
1193
1195
|
def gosu_to_radians(); end
|
1194
|
-
|
1196
|
+
|
1195
1197
|
##
|
1196
1198
|
# Converts degrees to radians.
|
1197
|
-
#
|
1199
|
+
#
|
1198
1200
|
# @return [Float] radians.
|
1199
1201
|
def degrees_to_radians(); end
|
1200
|
-
|
1202
|
+
|
1201
1203
|
##
|
1202
1204
|
# Converts radians to degrees.
|
1203
|
-
#
|
1205
|
+
#
|
1204
1206
|
# @return [Float] degrees.
|
1205
1207
|
def radians_to_degrees(); end
|
1206
1208
|
end
|