gosu 0.7.50-x86-mingw32 → 0.8.0.pre7-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Binary file
Binary file
Binary file
@@ -1,16 +1,15 @@
1
1
  require 'rbconfig'
2
2
 
3
- if defined? RUBY_PLATFORM and
4
- %w(-win32 win32- mswin mingw32).any? { |s| RUBY_PLATFORM.include? s } then
3
+ if RUBY_PLATFORM =~ /mswin|mingw32|mingw64|win32\-|\-win32/ then
4
+ # Add this gem to the PATH on Windows so that DLLs can be found
5
5
  ENV['PATH'] = "#{File.dirname(__FILE__)};#{ENV['PATH']}"
6
6
  end
7
7
 
8
- if File.exist? "#{File.dirname(__FILE__)}/gosu.#{RbConfig::CONFIG['DLEXT']}"
8
+ begin
9
+ RUBY_VERSION =~ /(\d+.\d+)/
10
+ require "#{$1}/gosu.#{RbConfig::CONFIG['DLEXT']}"
11
+ rescue LoadError
9
12
  require "gosu.#{RbConfig::CONFIG['DLEXT']}"
10
- elsif defined? RUBY_VERSION and RUBY_VERSION >= '1.9' then
11
- require "gosu.for_1_9.#{RbConfig::CONFIG['DLEXT']}"
12
- else
13
- require "gosu.for_1_8.#{RbConfig::CONFIG['DLEXT']}"
14
13
  end
15
14
 
16
15
  require "gosu/swig_patches"
@@ -23,6 +23,7 @@ class Gosu::Window
23
23
 
24
24
  def protected_draw_2
25
25
  protected_draw
26
+ $gosu_gl_blocks_2 = $gosu_gl_blocks
26
27
  $gosu_gl_blocks = nil
27
28
  end
28
29
 
@@ -24,6 +24,10 @@ module Gosu
24
24
  end
25
25
  end
26
26
 
27
+ def init &body
28
+ ZenWindow.send :define_method, :init, &body
29
+ end
30
+
27
31
  def button_down id = nil, &body
28
32
  m = id ? "button_down_#{id}" : :button_down_other
29
33
  ZenWindow.send :define_method, m, &body
@@ -57,6 +61,14 @@ module Gosu
57
61
  end
58
62
 
59
63
  class ZenWindow < Window
64
+ def initialize *args
65
+ super
66
+ init
67
+ end
68
+
69
+ def init
70
+ end
71
+
60
72
  def button_down id
61
73
  m = :"button_down_#{id}"
62
74
  respond_to?(m) ? send(m) : button_down_other(id)
metadata CHANGED
@@ -1,31 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gosu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.50
4
+ version: 0.8.0.pre7
5
5
  platform: x86-mingw32
6
6
  authors:
7
7
  - Julian Raschke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-06 00:00:00.000000000 Z
11
+ date: 2014-08-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2
14
- 2D game development library.
14
+ 2D game development library.
15
15
 
16
- Gosu features easy to use and game-friendly interfaces to 2D graphics
17
- and text (accelerated by 3D hardware), sound samples and music as well as
18
- keyboard, mouse and gamepad/joystick input.
16
+ Gosu features easy to use and game-friendly interfaces to 2D graphics
17
+ and text (accelerated by 3D hardware), sound samples and music as well as
18
+ keyboard, mouse and gamepad/joystick input.
19
19
 
20
- Also includes demos for integration with RMagick, Chipmunk and OpenGL.
20
+ Also includes demos for integration with RMagick, Chipmunk and OpenGL.
21
21
  email: julian@raschke.de
22
22
  executables: []
23
23
  extensions: []
24
24
  extra_rdoc_files: []
25
25
  files:
26
- - .yardopts
27
- - COPYING
28
- - README.txt
29
26
  - Gosu/Audio.hpp
30
27
  - Gosu/AutoLink.hpp
31
28
  - Gosu/Bitmap.hpp
@@ -53,12 +50,6 @@ files:
53
50
  - Gosu/Version.hpp
54
51
  - Gosu/WinUtility.hpp
55
52
  - Gosu/Window.hpp
56
- - lib/gosu.rb
57
- - lib/gosu/patches.rb
58
- - lib/gosu/preview.rb
59
- - lib/gosu/run.rb
60
- - lib/gosu/swig_patches.rb
61
- - lib/gosu/zen.rb
62
53
  - examples/ChipmunkIntegration.rb
63
54
  - examples/CptnRuby.rb
64
55
  - examples/GosuZen.rb
@@ -82,11 +73,17 @@ files:
82
73
  - examples/media/Space.png
83
74
  - examples/media/Star.png
84
75
  - examples/media/Starfighter.bmp
85
- - reference/gosu.rb
86
- - lib/gosu.for_1_8.so
87
- - lib/gosu.for_1_9.so
76
+ - lib/1.8/gosu.so
77
+ - lib/1.9/gosu.so
88
78
  - lib/FreeImage.dll
89
79
  - lib/OpenAL32.dll
80
+ - lib/SDL2.dll
81
+ - lib/gosu.rb
82
+ - lib/gosu/patches.rb
83
+ - lib/gosu/preview.rb
84
+ - lib/gosu/run.rb
85
+ - lib/gosu/swig_patches.rb
86
+ - lib/gosu/zen.rb
90
87
  - lib/libsndfile.dll
91
88
  homepage: http://www.libgosu.org/
92
89
  licenses: []
@@ -99,15 +96,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
99
96
  requirements:
100
97
  - - '>='
101
98
  - !ruby/object:Gem::Version
102
- version: 1.8.2
99
+ version: '0'
103
100
  required_rubygems_version: !ruby/object:Gem::Requirement
104
101
  requirements:
105
- - - '>='
102
+ - - '>'
106
103
  - !ruby/object:Gem::Version
107
- version: '0'
104
+ version: 1.3.1
108
105
  requirements: []
109
106
  rubyforge_project:
110
- rubygems_version: 2.0.3
107
+ rubygems_version: 2.3.0
111
108
  signing_key:
112
109
  specification_version: 4
113
110
  summary: 2D game development library.
data/.yardopts DELETED
@@ -1 +0,0 @@
1
- reference/*.rb - README.txt COPYING reference/*.md --markup markdown -M rdiscount --output reference/rdoc
data/COPYING DELETED
@@ -1,29 +0,0 @@
1
- Copyright (C) 2004-2013 Julian Raschke, Jan Lücker and all contributors.
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a
4
- copy of this software and associated documentation files (the "Software"),
5
- to deal in the Software without restriction, including without limitation
6
- the rights to use, copy, modify, merge, publish, distribute, sublicense,
7
- and/or sell copies of the Software, and to permit persons to whom the
8
- Software is furnished to do so, subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in
11
- all copies or substantial portions of the Software.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19
- DEALINGS IN THE SOFTWARE.
20
-
21
- Julian Raschke <julian@raschke.de> & contributors
22
- http://www.libgosu.org/
23
-
24
- ***
25
-
26
- This does NOT apply to libogg and libvorbis, which are included in all source
27
- and binary distributions of Gosu. These projects are licensed under a BSD-like
28
- license, and their copyright terms need to be supplied even with binary
29
- redistributions (e.g. Gosu games).
data/README.txt DELETED
@@ -1,25 +0,0 @@
1
-  Moin and welcome to Gosu!
2
-
3
-  Gosu's main website is http://www.libgosu.org/, which always has the latest
4
- links to all relevant information.
5
-
6
-  The actual source code, wiki, issue tracker etc. are all hosted on GitHub:
7
-
8
- http://github.com/jlnr/gosu/
9
-
10
-  The best entry point into Gosu's documentation is the wiki home page:
11
-
12
- http://github.com/jlnr/gosu/wiki
13
-
14
-  Try doing the tutorial there if you don't know how to start out. Or look at
15
- one of the games in the Gosu Users board.
16
-
17
-  Remember that Gosu is licensed under the MIT license and feel invited to fork,
18
- port and transmogrify all parts of it. The only license that may affect you by
19
- indirection is libogg's (BSD-style). If you release a Gosu game in any common
20
- binary form, you will need to mention use of libogg and libvorbis somewhere.
21
-
22
-  Complaints, questions, feedback?
23
- * Visit the boards, http://www.libgosu.org/
24
- * try your luck in the chat, irc://irc.freenode.org/gosu
25
- * or e-mail me. Have fun, write games! julian@raschke.de
Binary file
Binary file
@@ -1,1284 +0,0 @@
1
- ##
2
- # The first component of the version.
3
- GOSU_MAJOR_VERSION = :a_fixnum
4
-
5
- ##
6
- # The second component of the version.
7
- GOSU_MINOR_VERSION = :a_fixnum
8
-
9
- ##
10
- # The third component of the version.
11
- GOSU_POINT_VERSION = :a_fixnum
12
-
13
- ##
14
- # A version string of the form "0.1.2" or "0.1.2.3".
15
- GOSU_VERSION = "#{GOSU_MAJOR_VERSION}.#{GOSU_MINOR_VERSION}.#{GOSU_POINT_VERSION}"
16
-
17
- ##
18
- # A long block of legal copy that your game is obliged to display somewhere.
19
- GOSU_COPYRIGHT_NOTICE = :a_string
20
-
21
- module Gosu
22
- Kb0 = :implementation_defined
23
- Kb1 = :implementation_defined
24
- Kb2 = :implementation_defined
25
- Kb3 = :implementation_defined
26
- Kb4 = :implementation_defined
27
- Kb5 = :implementation_defined
28
- Kb6 = :implementation_defined
29
- Kb7 = :implementation_defined
30
- Kb8 = :implementation_defined
31
- Kb9 = :implementation_defined
32
- KbA = :implementation_defined
33
- KbB = :implementation_defined
34
- KbC = :implementation_defined
35
- KbD = :implementation_defined
36
- KbE = :implementation_defined
37
- KbF = :implementation_defined
38
- KbG = :implementation_defined
39
- KbH = :implementation_defined
40
- KbI = :implementation_defined
41
- KbJ = :implementation_defined
42
- KbK = :implementation_defined
43
- KbL = :implementation_defined
44
- KbM = :implementation_defined
45
- KbN = :implementation_defined
46
- KbO = :implementation_defined
47
- KbP = :implementation_defined
48
- KbQ = :implementation_defined
49
- KbR = :implementation_defined
50
- KbS = :implementation_defined
51
- KbT = :implementation_defined
52
- KbU = :implementation_defined
53
- KbV = :implementation_defined
54
- KbW = :implementation_defined
55
- KbX = :implementation_defined
56
- KbY = :implementation_defined
57
- KbZ = :implementation_defined
58
- KbBackspace = :implementation_defined
59
- KbDelete = :implementation_defined
60
- KbDown = :implementation_defined
61
- KbEnd = :implementation_defined
62
-
63
- ##
64
- # This is the key on the numpad.
65
- KbEnter = :implementation_defined
66
-
67
- KbEscape = :implementation_defined
68
- KbF1 = :implementation_defined
69
- KbF10 = :implementation_defined
70
- KbF11 = :implementation_defined
71
- KbF12 = :implementation_defined
72
- KbF2 = :implementation_defined
73
- KbF3 = :implementation_defined
74
- KbF4 = :implementation_defined
75
- KbF5 = :implementation_defined
76
- KbF6 = :implementation_defined
77
- KbF7 = :implementation_defined
78
- KbF8 = :implementation_defined
79
- KbF9 = :implementation_defined
80
- KbHome = :implementation_defined
81
- KbInsert = :implementation_defined
82
- KbLeft = :implementation_defined
83
- KbLeftAlt = :implementation_defined
84
- KbLeftControl = :implementation_defined
85
- KbLeftShift = :implementation_defined
86
- KbNumpad0 = :implementation_defined
87
- KbNumpad1 = :implementation_defined
88
- KbNumpad2 = :implementation_defined
89
- KbNumpad3 = :implementation_defined
90
- KbNumpad4 = :implementation_defined
91
- KbNumpad5 = :implementation_defined
92
- KbNumpad6 = :implementation_defined
93
- KbNumpad7 = :implementation_defined
94
- KbNumpad8 = :implementation_defined
95
- KbNumpad9 = :implementation_defined
96
- KbNumpadAdd = :implementation_defined
97
- KbNumpadDivide = :implementation_defined
98
- KbNumpadMultiply = :implementation_defined
99
- KbNumpadSubtract = :implementation_defined
100
- KbPageDown = :implementation_defined
101
- KbPageUp = :implementation_defined
102
-
103
- ##
104
- # This is the key above the right shift key.
105
- KbReturn = :implementation_defined
106
-
107
- KbRight = :implementation_defined
108
- KbRightAlt = :implementation_defined
109
- KbRightControl = :implementation_defined
110
- KbRightShift = :implementation_defined
111
- KbSpace = :implementation_defined
112
- KbTab = :implementation_defined
113
- KbUp = :implementation_defined
114
- KbBacktick = :implementation_defined
115
- KbMinus = :implementation_defined
116
- KbEqual = :implementation_defined
117
- KbBracketLeft = :implementation_defined
118
- KbBracketRight = :implementation_defined
119
- KbBackslash = :implementation_defined
120
- KbSemicolon = :implementation_defined
121
- KbApostrophe = :implementation_defined
122
- KbComma = :implementation_defined
123
- KbPeriod = :implementation_defined
124
- KbSlash = :implementation_defined
125
-
126
- MsLeft = :implementation_defined
127
- MsMiddle = :implementation_defined
128
- MsRight = :implementation_defined
129
- MsWheelDown = :implementation_defined
130
- MsWheelUp = :implementation_defined
131
- MsOther0 = :implementation_defined
132
- MsOther1 = :implementation_defined
133
- MsOther2 = :implementation_defined
134
- MsOther3 = :implementation_defined
135
- MsOther4 = :implementation_defined
136
- MsOther5 = :implementation_defined
137
- MsOther6 = :implementation_defined
138
- MsOther7 = :implementation_defined
139
-
140
- GpButton0 = :implementation_defined
141
- GpButton1 = :implementation_defined
142
- GpButton10 = :implementation_defined
143
- GpButton11 = :implementation_defined
144
- GpButton12 = :implementation_defined
145
- GpButton13 = :implementation_defined
146
- GpButton14 = :implementation_defined
147
- GpButton15 = :implementation_defined
148
- GpButton2 = :implementation_defined
149
- GpButton3 = :implementation_defined
150
- GpButton4 = :implementation_defined
151
- GpButton5 = :implementation_defined
152
- GpButton6 = :implementation_defined
153
- GpButton7 = :implementation_defined
154
- GpButton8 = :implementation_defined
155
- GpButton9 = :implementation_defined
156
- GpDown = :implementation_defined
157
- GpLeft = :implementation_defined
158
- GpRight = :implementation_defined
159
- GpUp = :implementation_defined
160
- Gp0Button0 = :implementation_defined
161
- Gp0Button1 = :implementation_defined
162
- Gp0Button10 = :implementation_defined
163
- Gp0Button11 = :implementation_defined
164
- Gp0Button12 = :implementation_defined
165
- Gp0Button13 = :implementation_defined
166
- Gp0Button14 = :implementation_defined
167
- Gp0Button15 = :implementation_defined
168
- Gp0Button2 = :implementation_defined
169
- Gp0Button3 = :implementation_defined
170
- Gp0Button4 = :implementation_defined
171
- Gp0Button5 = :implementation_defined
172
- Gp0Button6 = :implementation_defined
173
- Gp0Button7 = :implementation_defined
174
- Gp0Button8 = :implementation_defined
175
- Gp0Button9 = :implementation_defined
176
- Gp0Down = :implementation_defined
177
- Gp0Left = :implementation_defined
178
- Gp0Right = :implementation_defined
179
- Gp0Up = :implementation_defined
180
- Gp1Button0 = :implementation_defined
181
- Gp1Button1 = :implementation_defined
182
- Gp1Button10 = :implementation_defined
183
- Gp1Button11 = :implementation_defined
184
- Gp1Button12 = :implementation_defined
185
- Gp1Button13 = :implementation_defined
186
- Gp1Button14 = :implementation_defined
187
- Gp1Button15 = :implementation_defined
188
- Gp1Button2 = :implementation_defined
189
- Gp1Button3 = :implementation_defined
190
- Gp1Button4 = :implementation_defined
191
- Gp1Button5 = :implementation_defined
192
- Gp1Button6 = :implementation_defined
193
- Gp1Button7 = :implementation_defined
194
- Gp1Button8 = :implementation_defined
195
- Gp1Button9 = :implementation_defined
196
- Gp1Down = :implementation_defined
197
- Gp1Left = :implementation_defined
198
- Gp1Right = :implementation_defined
199
- Gp1Up = :implementation_defined
200
- Gp2Button0 = :implementation_defined
201
- Gp2Button1 = :implementation_defined
202
- Gp2Button10 = :implementation_defined
203
- Gp2Button11 = :implementation_defined
204
- Gp2Button12 = :implementation_defined
205
- Gp2Button13 = :implementation_defined
206
- Gp2Button14 = :implementation_defined
207
- Gp2Button15 = :implementation_defined
208
- Gp2Button2 = :implementation_defined
209
- Gp2Button3 = :implementation_defined
210
- Gp2Button4 = :implementation_defined
211
- Gp2Button5 = :implementation_defined
212
- Gp2Button6 = :implementation_defined
213
- Gp2Button7 = :implementation_defined
214
- Gp2Button8 = :implementation_defined
215
- Gp2Button9 = :implementation_defined
216
- Gp2Down = :implementation_defined
217
- Gp2Left = :implementation_defined
218
- Gp2Right = :implementation_defined
219
- Gp2Up = :implementation_defined
220
- Gp3Button0 = :implementation_defined
221
- Gp3Button1 = :implementation_defined
222
- Gp3Button10 = :implementation_defined
223
- Gp3Button11 = :implementation_defined
224
- Gp3Button12 = :implementation_defined
225
- Gp3Button13 = :implementation_defined
226
- Gp3Button14 = :implementation_defined
227
- Gp3Button15 = :implementation_defined
228
- Gp3Button2 = :implementation_defined
229
- Gp3Button3 = :implementation_defined
230
- Gp3Button4 = :implementation_defined
231
- Gp3Button5 = :implementation_defined
232
- Gp3Button6 = :implementation_defined
233
- Gp3Button7 = :implementation_defined
234
- Gp3Button8 = :implementation_defined
235
- Gp3Button9 = :implementation_defined
236
- Gp3Down = :implementation_defined
237
- Gp3Left = :implementation_defined
238
- Gp3Right = :implementation_defined
239
- Gp3Up = :implementation_defined
240
-
241
- ##
242
- # 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.
243
- class Color
244
- ##
245
- # @return [Fixnum] the color's alpha channel.
246
- attr_accessor :alpha
247
-
248
- ##
249
- # @return [Fixnum] the color's red channel.
250
- attr_accessor :red
251
-
252
- ##
253
- # @return [Fixnum] the color's green channel.
254
- attr_accessor :green
255
-
256
- ##
257
- # @return [Fixnum] the color's blue channel.
258
- attr_accessor :blue
259
-
260
- ##
261
- # @return [Fixnum] the color's hue in the range (0...360).
262
- attr_accessor :hue
263
-
264
- ##
265
- # @return [Float] the color's saturation in the range (0..1).
266
- attr_accessor :saturation
267
-
268
- ##
269
- # @return [Float] the color's value in the range (0..1).
270
- attr_accessor :value
271
-
272
- # @!group Creating colors.
273
-
274
- ##
275
- # @overload initialize(argb)
276
- # @param argb [Fixnum] an integer of the form 0xAARRGGBB.
277
- #
278
- # @overload initialize(a, r, g, b)
279
- # @param a [Fixnum] the color's alpha channel in the range (0..255).
280
- # @param r [Fixnum] the color's red channel in the range (0..255).
281
- # @param g [Fixnum] the color's green channel in the range (0..255).
282
- # @param b [Fixnum] the color's blue channel in the range (0..255).
283
- #
284
- # @see from_hsv
285
- # @see from_ahsv
286
- # @see rgba
287
- # @see argb
288
- def initialize(*args); end
289
-
290
- ##
291
- # @return (see #initialize)
292
- #
293
- # @overload rgba(rgba)
294
- # @param argb [Fixnum] an integer of the form 0xRRGGBBAA.
295
- #
296
- # @overload rgba(r, g, b, a)
297
- # @param r [Fixnum] the color's red channel in the range (0..255).
298
- # @param g [Fixnum] the color's green channel in the range (0..255).
299
- # @param b [Fixnum] the color's blue channel in the range (0..255).
300
- # @param a [Fixnum] the color's alpha channel in the range (0..255).
301
- #
302
- # @see #initialize
303
- # @see argb
304
- def self.rgba(*args); end
305
-
306
- # This method is equivalent to calling `Color.new`, but the name makes the parameter order explicit.
307
- #
308
- # @return (see #initialize)
309
- # @overload argb(argb)
310
- # @overload argb(a, r, g, b)
311
- #
312
- # @see #initialize
313
- # @see rgba
314
- def self.argb(*args); end
315
-
316
- # Converts an HSV triplet to an opaque color.
317
- #
318
- # @return [Color] a color corresponding to the HSV triplet.
319
- # @param h [Fixnum] the color's hue in the range (0..360).
320
- # @param s [Float] the color's saturation in the range (0..1).
321
- # @param v [Float] the color's value in the range (0..1).
322
- #
323
- # @see from_ahsv
324
- def self.from_hsv(h, s, v); end
325
-
326
- # Converts an HSV triplet to a color with the alpha channel set to a given value.
327
- #
328
- # @return (see from_hsv)
329
- # @param a [Fixnum] the color's opacity in the range (0..255).
330
- # @param (see from_hsv)
331
- #
332
- # @see from_hsv
333
- def self.from_ahsv(a, h, s, v); end
334
-
335
- # @!endgroup
336
-
337
- # 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.
338
- #
339
- # @return [Fixnum] a 32-bit OpenGL color.
340
- def gl; end
341
-
342
- ##
343
- # @return [Color] a copy of the color.
344
- def dup; end
345
-
346
- NONE = Gosu::Color.argb(0x00000000)
347
- BLACK = Gosu::Color.argb(0xff000000)
348
- GRAY = Gosu::Color.argb(0xff808080)
349
- WHITE = Gosu::Color.argb(0xffffffff)
350
- AQUA = Gosu::Color.argb(0xff00ffff)
351
- RED = Gosu::Color.argb(0xffff0000)
352
- GREEN = Gosu::Color.argb(0xff00ff00)
353
- BLUE = Gosu::Color.argb(0xff0000ff)
354
- YELLOW = Gosu::Color.argb(0xffffff00)
355
- FUCHSIA = Gosu::Color.argb(0xffff00ff)
356
- CYAN = Gosu::Color.argb(0xff00ffff)
357
- end
358
-
359
- ##
360
- # A font can be used to draw text on a Window object very flexibly.
361
- # Fonts are ideal for small texts that change regularly. For large,
362
- # static texts you should use {Gosu::Image#from_text}.
363
- class Font
364
- ##
365
- # The font's name. This may be the name of a system font or a filename.
366
- #
367
- # @return [String] the font's name.
368
- attr_reader :name
369
-
370
- ##
371
- # @return [Fixnum] The font's height in pixels.
372
- attr_reader :height
373
-
374
- ##
375
- # Load a font from the system fonts or a file.
376
- #
377
- # @param window [Gosu::Window]
378
- # @param font_name [String] 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.
379
- # @param height [Fixnum] the height of the font, in pixels.
380
- def initialize(window, font_name, height); end
381
-
382
- ##
383
- # Overrides the image for a character.
384
- #
385
- # @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.
386
- #
387
- # @return [void]
388
- # @param character [String] the character to replace.
389
- # @param image [Image] the image to use for the character.
390
- def []=(character, image); end
391
-
392
- # @!group Drawing text
393
-
394
- ##
395
- # Draws a single line of text with its top left corner at (x, y).
396
- #
397
- # @return [void]
398
- # @param text [String]
399
- # @param x [Number] the X coordinate
400
- # @param y [Number] the Y coordinate
401
- # @param z [Number] the Z-order.
402
- # @param factor_x [Float] the horizontal scaling factor.
403
- # @param factor_y [Float] the vertical scaling factor.
404
- # @param color [Color, Fixnum]
405
- # @param mode [:default, :additive] the blending mode to use.
406
- #
407
- # @see #draw_rel
408
- # @see Gosu::Image.from_text
409
- # @see file:reference/Drawing_with_Colors.md Drawing with Colors
410
- # @see file:reference/Z-Ordering.md
411
- def draw(text, x, y, z, factor_x=1, factor_y=1, color=0xffffffff, mode=:default); end
412
-
413
- ##
414
- # Draws a single line of text relative to (x, y).
415
- #
416
- # 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.
417
- #
418
- # All real numbers are valid alignment values and will be interpolated (or extrapolated) accordingly.
419
- #
420
- # @return [void]
421
- # @param rel_x [Float] the horizontal alignment.
422
- # @param rel_y [Float] the vertical alignment.
423
- # @param (see #draw)
424
- #
425
- # @see #draw
426
- # @see file:reference/Drawing_with_Colors.md Drawing with Colors
427
- # @see file:reference/Z-Ordering.md
428
- def draw_rel(text, x, y, z, rel_x, rel_y, factor_x=1, factor_y=1, color=0xffffffff, mode=:default); end
429
-
430
- ##
431
- # @deprecated Use {#draw} in conjunction with {Window#rotate} instead.
432
- #
433
- # @see #draw
434
- # @see Gosu::Window#rotate
435
- def draw_rot(text, x, y, z, angle, factor_x=1, factor_y=1, color=0xffffffff, mode=:default); end
436
-
437
- # @!endgroup
438
-
439
- ##
440
- # Returns the width of a single line of text, in pixels, if it were drawn.
441
- #
442
- # @return [Fixnum] the width of the text, in pixels.
443
- # @param text [String]
444
- def text_width(text, factor_x=1); end
445
- end
446
-
447
- ##
448
- # Provides functionality for drawing rectangular images.
449
- class Image
450
- ##
451
- # @return [Fixnum] the image's width, in pixels.
452
- attr_reader :width
453
-
454
- ##
455
- # @return [Fixnum] the image's height, in pixels.
456
- attr_reader :height
457
-
458
- # @!group Creating and loading images
459
-
460
- ##
461
- # Loads an image from a file or an RMagick image.
462
- #
463
- # @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.
464
- #
465
- # @param window [Window]
466
- # @param source [String, Magick::Image] the filename or RMagick image to load from.
467
- # @param tileable [true, false]
468
- # @param left [Fixnum]
469
- # @param top [Fixnum]
470
- # @param width [Fixnum]
471
- # @param height [Fixnum]
472
- #
473
- # @overload initialize(window, source, tileable)
474
- # @overload initialize(window, source, tileable, left, top, width, height)
475
- # Loads a rectangular slice of the image.
476
- #
477
- # If you need to load multiple tiles from a texture atlas, {load_tiles} is almost always a better choice.
478
- #
479
- #
480
- # @see load_tiles
481
- # @see from_text
482
- # @see file:reference/Tileability.md
483
- def initialize(window, source, tileable, left, top, width, height); end
484
-
485
- ##
486
- # Creates a reusable image from one or more lines of text.
487
- #
488
- # The text is always rendered in white. To draw it in a different color, use the `color` parameter of {#draw}, et al.
489
- #
490
- # @overload from_text(window, text, font_name, font_height)
491
- # @overload from_text(window, text, font_name, font_height, line_spacing, width, align)
492
- #
493
- # @return [Gosu::Image]
494
- # @param window [Gosu::Window]
495
- # @param text [String]
496
- # @param font_name [String] 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.
497
- # @param font_height [Fixnum] the height of the font, in pixels.
498
- # @param line_spacing [Fixnum] the vertical spacing beteen lines.
499
- # @param width [Fixnum] the width of the image, in pixels. Long lines will be automatically wrapped around to avoid overflow, but overlong words will be truncated.
500
- # @param align [:left, :right, :center, :justify] the text alignment.
501
- #
502
- # @see Gosu::Font
503
- def self.from_text(window, text, font_name, font_height, line_spacing, width, align); end
504
-
505
- ##
506
- # Loads an image from a file or an RMagick image, then divides the image into an array of equal-sized tiles.
507
- #
508
- # @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.
509
- #
510
- # @return [Array<Gosu::Image>]
511
- # @param window [Window]
512
- # @param source [String, Magick::Image]
513
- # @param tile_width [Fixnum] If positive, this is the width of the individual tiles; if negative, the image is divided into -tile_width columns.
514
- # @param tile_height [Fixnum] If positive, this is the height of the individual tiles; if negative, the image is divided into -tile_height rows.
515
- # @param tileable [true, false]
516
- #
517
- # @see file:reference/Tileability.md
518
- def self.load_tiles(window, source, tile_width, tile_height, tileable); end
519
-
520
- # @!endgroup
521
-
522
- # @!group Drawing an image
523
-
524
- ##
525
- # Draws the image with its top left corner at (x, y).
526
- #
527
- # @return [void]
528
- # @param x [Float] the X coordinate.
529
- # @param y [Float] the X coordinate.
530
- # @param z [Float] the Z-order.
531
- # @param factor_x [Float] the horizontal scaling factor.
532
- # @param factor_y [Float] the vertical scaling factor.
533
- # @param color [Gosu::Color, Integer]
534
- # @param mode [:default, :additive] the blending mode to use.
535
- #
536
- # @see #draw_rot
537
- # @see #draw_as_quad
538
- # @see file:reference/Drawing_with_Colors.md Drawing with Colors
539
- # @see file:reference/Z-Ordering.md
540
- def draw(x, y, z, factor_x=1, factor_y=1, color=0xffffffff, mode=:default); end
541
-
542
- ##
543
- # Draws the image rotated, with its rotational center at (x, y).
544
- #
545
- # @return [void]
546
- # @param angle [Float]
547
- # @param center_x [Float] the relative horizontal rotation origin.
548
- # @param center_y [Float] the relative vertical rotation origin.
549
- # @param (see #draw)
550
- #
551
- # @see #draw
552
- # @see file:reference/Drawing_with_Colors.md Drawing with Colors
553
- # @see file:reference/Z-Ordering.md
554
- def draw_rot(x, y, z, angle, center_x=0.5, center_y=0.5, factor_x=1, factor_y=1, color=0xffffffff, mode=:default); end
555
-
556
- ##
557
- # 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.
558
- #
559
- # @return [void]
560
- # @param (see Gosu::Window#draw_quad)
561
- #
562
- # @see #draw
563
- # @see Gosu::Window#draw_quad
564
- # @see file:reference/Drawing_with_Colors.md Drawing with Colors
565
- # @see file:reference/Order_of_Corners.md Order of Corners
566
- # @see file:reference/Z-Ordering.md
567
- def draw_as_quad(x1, y1, c1, x2, y2, c2, x3, y3, c3, x4, y4, c4, z, mode=:default); end
568
-
569
- # @!endgroup
570
-
571
- ##
572
- # Returns an object that holds information about the underlying OpenGL texture and UV coordinates of the image.
573
- #
574
- # @note Some images may be too large to fit on a single texture; this method returns nil in those cases.
575
- #
576
- # @return [Gosu::GLTexInfo?] information about the underlying OpenGL texture.
577
- #
578
- # @see Gosu::GLTexInfo
579
- # @see file:examples/OpenGLIntegration.rb
580
- def gl_tex_info; end
581
-
582
- ##
583
- # Returns the associated texture contents as binary string of packed RGBA values, useful for use with RMagick (Magick::Image.from_blob).
584
- #
585
- # @return [String] a binary string of packed RGBA values.
586
- def to_blob; end
587
-
588
- ##
589
- # 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.
590
- #
591
- # This can be used to e.g. overwrite parts of a landscape.
592
- #
593
- # @return [void]
594
- # @param source [String, Magick::Image] the filename or RMagick image to load from.
595
- # @param x [Fixnum] the X coordinate of the top left corner.
596
- # @param y [Fixnum] the Y coordinate of the top left corner.
597
- def insert(source, x, y); end
598
-
599
- ##
600
- # Saves the image to a file. The file format is determined from the file extension.
601
- #
602
- # Useful for, e.g., pre-rendering text on a development machine where the necessary fonts are known to be available.
603
- #
604
- # @return [void]
605
- # @param filename [String] the path to save the file under.
606
- def save(filename); end
607
- end
608
-
609
- ##
610
- # A sample is a short sound that is completely loaded in memory, can be
611
- # played multiple times at once and offers very flexible playback
612
- # parameters. Use samples for everything that's not music.
613
- #
614
- # @see Gosu::Song
615
- class Sample
616
- ##
617
- # Loads a sample from a file.
618
- #
619
- # @param window [Gosu::Window]
620
- # @param filename [String] the path to load the sample from.
621
- def initialize(window, filename); end
622
-
623
- ##
624
- # Plays the sample without panning.
625
- #
626
- # Playback speed is limited only by the underlying audio library, and both very large and very small values should work just fine.
627
- #
628
- # @return [SampleInstance]
629
- # @param volume [Float] the playback volume, in the range (0..1), where 0 is completely silent and 1 is full volume.
630
- # @param speed [Float] the playback speed.
631
- # @param looping [true, false] whether the sample should play in a loop.
632
- #
633
- # @see #play_pan
634
- def play(volume=1, speed=1, looping=false); end
635
-
636
- ##
637
- # Plays the sample with panning.
638
- #
639
- # @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.
640
- #
641
- # @return [SampleInstance]
642
- # @param pan [Float] the amount of panning. 0 is centered.
643
- # @param (see #play)
644
- #
645
- # @see #play
646
- def play_pan(pan=0, volume=1, speed=1, looping=false); end
647
- end
648
-
649
- ##
650
- # An instance of a {Gosu::Sample} playing. Can be used to stop sounds dynamically, or to check if they are finished.
651
- #
652
- # 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.
653
- class SampleInstance
654
- attr_writer :volume
655
- attr_writer :speed
656
- attr_writer :pan
657
-
658
- ##
659
- # Stops playback of this sample instance. After calling this method, the sample instance is useless and can be discarded.
660
- #
661
- # Calling `stop` after the sample has finished is harmless and has no effect.
662
- #
663
- # @return [void]
664
- def stop; end
665
-
666
- ##
667
- # Pauses the sample, to be resumed afterwards.
668
- #
669
- # @note The sample will still occupy a playback channel while paused.
670
- #
671
- # @return [void]
672
- def pause; end
673
-
674
- ##
675
- # Resumes playback of the sample.
676
- #
677
- # @return [void]
678
- def resume; end
679
-
680
- ##
681
- # @return [true, false] whether the sample is paused.
682
- def paused?; end
683
-
684
- ##
685
- # @return [true, false] whether the sample is playing.
686
- def playing?; end
687
- end
688
-
689
- ##
690
- # Songs are less flexible than samples in that only one can be played at a time, with no panning or speed control.
691
- #
692
- # @see Gosu::Sample
693
- class Song
694
- class <<Song
695
- ##
696
- # Returns the song currently being played (even if it's paused), or nil if no song is playing.
697
- #
698
- # @return [Gosu::Song?] the currently playing song.
699
- attr_reader :current_song
700
- end
701
-
702
- ##
703
- # @return [Float] the song's playback volume.
704
- attr_accessor :volume
705
-
706
- ##
707
- # Loads a song from a file.
708
- #
709
- # @param window [Gosu::Window]
710
- # @param filename [String] the path to load the song from.
711
- def initialize(window, filename); end
712
-
713
- ##
714
- # Starts or resumes playback of the song.
715
- #
716
- # If another song is currently playing, it will be stopped and this song will be set as the current song.
717
- #
718
- # If `looping` is false, the current song will be set to `nil` when this song finishes.
719
- #
720
- # @return [void]
721
- # @param looping [true, false] whether the song should play in a loop.
722
- def play(looping=false); end
723
-
724
- ##
725
- # Pauses playback of the song. The current song is unchanged.
726
- #
727
- # @return [void]
728
- def pause; end
729
-
730
- # Returns true if this song is the current song and playback is paused.
731
- #
732
- # @return [true, false] whether the song is paused.
733
- def paused?; end
734
-
735
- ##
736
- # Stops playback if this song is the current song. The current song is set to `nil`.
737
- #
738
- # @return [void]
739
- def stop; end
740
-
741
- ##
742
- # @return [true, false] whether the song is playing.
743
- def playing?; end
744
- end
745
-
746
- ##
747
- # A TextInput is an invisible object that handles input using the operating system's input manager.
748
- #
749
- # 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}.
750
- #
751
- # 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.
752
- #
753
- # @see Gosu::Window#text_input
754
- # @see file:examples/TextInput.rb
755
- class TextInput
756
- ##
757
- # @return [String] the text that the user has typed.
758
- attr_accessor :text
759
-
760
- ##
761
- # @return [Fixnum] the position of the editing caret.
762
- attr_accessor :caret_pos
763
-
764
- ##
765
- # @return [Fixnum] the starting position of the currently selected text.
766
- attr_accessor :selection_start
767
-
768
- ##
769
- # 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.
770
- #
771
- # The return value of this method will be inserted at the current caret position.
772
- #
773
- # The default implementation returns its argument unchanged.
774
- #
775
- # @return [String] the string to be inserted.
776
- # @param text_in [String] the text typed by the user.
777
- #
778
- # @example Forcing input to all uppercase, alphanumeric characters.
779
- # input = TextInput.new
780
- # def input.filter(text_in)
781
- # text_in.upcase.gsub(/[^A-Z0-9]/, '')
782
- # end
783
- def filter text_in
784
- text_in
785
- end
786
- end
787
-
788
- ##
789
- # Main class that serves as the foundation of a standard
790
- # Gosu application. Manages initialization of all of Gosu's core components
791
- # and provides timing functionality.
792
- #
793
- # Note that all coordinates, even the mouse position, are in client
794
- # coordinates relative to the window. This means that the mouse position
795
- # can be negative or larger than the window size.
796
- #
797
- # @note There should really only be one instance of this class at a time. This may or may not change later, but for right now, having two or more windows and loading samples or songs on both of them will result in an exception.
798
- class Window
799
- ##
800
- # @return [String] the window's caption, usually dispalyed in the title bar.
801
- attr_accessor :caption
802
-
803
- ##
804
- # @return [Fixnum] the mouse pointer's window-based X coordinate.
805
- attr_accessor :mouse_x
806
-
807
- ##
808
- # @return [Fixnum] the mouse pointer's window-based Y coordinate.
809
- attr_accessor :mouse_y
810
-
811
- ##
812
- # The currently active {TextInput}. If not nil, all keyboard input will be handled by this object.
813
- #
814
- # @return [TextInput?] the currently active text input.
815
- attr_accessor :text_input
816
-
817
- ##
818
- # 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.
819
- #
820
- # @return [Fixnum] the window's width, in pixels.
821
- attr_reader :width
822
-
823
- ##
824
- # 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.
825
- #
826
- # @return [Fixnum] the window's height, in pixels.
827
- attr_reader :height
828
-
829
- ##
830
- # @return [true, false] whether this is a full-screen window.
831
- attr_reader :fullscreen?
832
-
833
- ##
834
- # @return [Float] the interval between calls to {#update}, in milliseconds.
835
- attr_reader :update_interval
836
-
837
- ##
838
- # Creates a new window with the requested size.
839
- #
840
- # @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.
841
- #
842
- # @param width [Fixnum] the desired window width.
843
- # @param height [Fixnum] the desired window height.
844
- # @param fullscreen [true, false] whether to create a full-screen window.
845
- # @param update_interval [Float] the interval between calls to {#update}, in milliseconsd. For the default value of 16.666666, the game will attempt to run at approximately 60 FPS, which is ideal on standard 60 Hz TFT screens.
846
- def initialize(width, height, fullscreen, update_interval=16.666666); end
847
-
848
- ##
849
- # Enters a modal loop where the Window is visible on screen and receives calls to draw, update etc.
850
- #
851
- # @return [void]
852
- def show; end
853
-
854
- ##
855
- # Tells the window to end the current run loop as soon as possible. Calling this method will not prevent execution of lines after it.
856
- #
857
- # @return [void]
858
- def close; end
859
-
860
- # @!group Callbacks
861
-
862
- ##
863
- # This method is called once every {#update_interval} milliseconds while the window is being shown. Your application's main logic should go here.
864
- #
865
- # @return [void]
866
- def update; end
867
-
868
- ##
869
- # 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.
870
- #
871
- # @return [void]
872
- #
873
- # @see #needs_redraw?
874
- def draw; end
875
-
876
- ##
877
- # 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.
878
- #
879
- # @return [true, false] whether the window needs to be redrawn.
880
- #
881
- # @see #draw
882
- def needs_redraw?; end
883
-
884
- ##
885
- # 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.
886
- #
887
- # @return [true, false] whether the system cursor should be shown.
888
- def needs_cursor?; end
889
-
890
- ##
891
- # This method is called before {#update} if a button was pressed while the window had focus.
892
- #
893
- # @return [void]
894
- # @param id [Fixnum] the button's platform-defined id.
895
- #
896
- # @see #button_up
897
- # @see #button_down?
898
- def button_down(id); end
899
-
900
- ##
901
- # This method is called before {#update} if a button was released while the window had focus.
902
- #
903
- # @return [void]
904
- # @param (see #button_down)
905
- #
906
- # @see #button_down
907
- # @see #button_down?
908
- def button_up(id); end
909
-
910
- # @!endgroup
911
-
912
- ##
913
- # Returns whether the button `id` is currently pressed. Button states are updated once per tick, so repeated calls during the same tick will always yeild the same result.
914
- #
915
- # @return [true, false] whether the button is currently pressed.
916
- # @param (see #button_down)
917
- #
918
- # @see #button_down
919
- # @see #button_up
920
- def button_down?(id); end
921
-
922
- # @!group Drawing primitives
923
-
924
- ##
925
- # Draws a line from one point to another---inconsistently.
926
- #
927
- # @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.
928
- #
929
- # @return [void]
930
- # @param x1 [Float] the X coordinate of the start point.
931
- # @param y1 [Float] the Y coordinate of the start point.
932
- # @param c1 [Gosu::Color] the color of the start point.
933
- # @param x2 [Float] the X coordinate of the end point.
934
- # @param y2 [Float] the Y coordinate of the end point.
935
- # @param c2 [Gosu::Color] the color of the end point.
936
- # @param z [Float] the Z-order.
937
- # @param mode [:default, :additive] the blending mode to use.
938
- #
939
- # @see #draw_triangle
940
- # @see #draw_quad
941
- # @see file:reference/Drawing_with_Colors.md Drawing with Colors
942
- # @see file:reference/Z-Ordering.md
943
- def draw_line(x1, y1, c1, x2, y2, c2, z=0, mode=:default); end
944
-
945
- ##
946
- # Draws a triangle.
947
- #
948
- # @return [void]
949
- # @param x1 [Float] the X coordinate of the first vertex.
950
- # @param y1 [Float] the Y coordinate of the first vertex.
951
- # @param c1 [Gosu::Color] the color of the first vertex.
952
- # @param x2 [Float] the X coordinate of the second vertex.
953
- # @param y2 [Float] the Y coordinate of the second vertex.
954
- # @param c2 [Gosu::Color] the color of the second vertex.
955
- # @param x3 [Float] the X coordinate of the third vertex.
956
- # @param y3 [Float] the Y coordinate of the third vertex.
957
- # @param c3 [Gosu::Color] the color of the third vertex.
958
- # @param z [Float] the Z-order.
959
- # @param mode [:default, :additive] the blending mode to use.
960
- #
961
- # @see #draw_line
962
- # @see #draw_quad
963
- # @see file:reference/Drawing_with_Colors.md Drawing with Colors
964
- # @see file:reference/Z-Ordering.md
965
- def draw_triangle(x1, y1, c1, x2, y2, c2, x3, y3, c3, z=0, mode=:default); end
966
-
967
- ##
968
- # Draws a quad (actually two triangles).
969
- #
970
- # @return [void]
971
- # @param x1 [Float] the X coordinate of the first vertex.
972
- # @param y1 [Float] the Y coordinate of the first vertex.
973
- # @param c1 [Gosu::Color] the color of the first vertex.
974
- # @param x2 [Float] the X coordinate of the second vertex.
975
- # @param y2 [Float] the Y coordinate of the second vertex.
976
- # @param c2 [Gosu::Color] the color of the second vertex.
977
- # @param x3 [Float] the X coordinate of the third vertex.
978
- # @param y3 [Float] the Y coordinate of the third vertex.
979
- # @param c3 [Gosu::Color] the color of the third vertex.
980
- # @param x4 [Float] the X coordinate of the fourth vertex.
981
- # @param y4 [Float] the Y coordinate of the fourth vertex.
982
- # @param c4 [Gosu::Color] the color of the fourth vertex.
983
- # @param z [Float] the Z-order.
984
- # @param mode [:default, :additive] the blending mode to use.
985
- #
986
- # @see #draw_line
987
- # @see #draw_triangle
988
- # @see file:reference/Drawing_with_Colors.md Drawing with Colors
989
- # @see file:reference/Order_of_Corners.md Order of Corners
990
- # @see file:reference/Z-Ordering.md
991
- def draw_quad(x1, y1, c1, x2, y2, c2, x3, y3, c3, x4, y4, c4, z=0, mode=:default); end
992
-
993
- # @!endgroup
994
- # @!group Manipulating the drawing context
995
-
996
- ##
997
- # 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.
998
- #
999
- # @return [void]
1000
- def flush; end
1001
-
1002
- ##
1003
- # Runs the block in a clean OpenGL environment.
1004
- #
1005
- # 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.
1006
- #
1007
- # @note Gosu does not provide access to the underlying OpenGL APIs. A gem like ruby-opengl is required to use custom OpenGL drawing code.
1008
- #
1009
- # @note Gosu rendering functions MUST NOT be used within the block, and {#gl} MUST be used only within the call tree of {#draw}.
1010
- #
1011
- # @return [void]
1012
- # @param z [Float] the Z-order.
1013
- # @yield OpenGL code.
1014
- #
1015
- # @see #draw
1016
- # @see file:reference/Z-Ordering
1017
- # @see file:examples/OpenGLIntegration.rb
1018
- def gl(z=nil); end
1019
-
1020
- ##
1021
- # Masks the drawing area inside the block.
1022
- #
1023
- # @return [void]
1024
- # @param x [Float] the X coordinate of the top left corner,.
1025
- # @param y [Float] the Y coordinate of the top left corner.
1026
- # @param w [Float] the width of the clipping area.
1027
- # @param h [Float] the height of the clipping area.
1028
- # @yield rendering code.
1029
- #
1030
- # @see #draw
1031
- def clip_to(x, y, w, h); end
1032
-
1033
- ##
1034
- # Records all drawing operatons 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.
1035
- #
1036
- # @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.
1037
- #
1038
- # @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.
1039
- #
1040
- # @return [Gosu::Image] the recorded drawing operations.
1041
- # @param width [Float] the width of the recorded image.
1042
- # @param height [Float] the height of the recorded image.
1043
- # @yield rendering code.
1044
- #
1045
- # @see #draw
1046
- # @see Gosu::Image
1047
- def record(width, height); end
1048
-
1049
- ##
1050
- # Rotates all drawing operatons inside the block.
1051
- #
1052
- # @return [void]
1053
- # @param angle [Float] the rotation angle.
1054
- # @param around_x [Float] the X coorinate of the rotation origin.
1055
- # @param around_y [Float] the Y coordinate of the rotation origin.
1056
- # @yield rendering code.
1057
- #
1058
- # @see #draw
1059
- # @see #scale
1060
- # @see #translate
1061
- # @see #transform
1062
- def rotate(angle, around_x=0, around_y=0); end
1063
-
1064
- ##
1065
- # Scales all drawing operations inside the block.
1066
- #
1067
- # @overload scale(factor_x, factor_y = factor_x) { ... }
1068
- # @overload scale(factor_x, factor_y, around_x, around_y) { ... }
1069
- #
1070
- # @return [void]
1071
- # @param factor_x [Float] the horizontal scaling factor.
1072
- # @param factor_y [Float] the vertical scaling factor.
1073
- # @param around_x [Float] the X coordinate of the scaling origin.
1074
- # @param around_y [Float] the Y coordinate of the scaling origin.
1075
- # @yield rendering code.
1076
- #
1077
- # @see #draw
1078
- # @see #rotate
1079
- # @see #translate
1080
- # @see #transform
1081
- def scale(factor_x, factor_y, around_x, around_y); end
1082
-
1083
- ##
1084
- # Offsets all drawing operations inside the block.
1085
- #
1086
- # @return [void]
1087
- # @param x [Float] the X offset.
1088
- # @param y [Float] the Y offset.
1089
- # @yield rendering code.
1090
- #
1091
- # @see #draw
1092
- # @see #rotate
1093
- # @see #scale
1094
- # @see #transform
1095
- def translate(x, y); end
1096
-
1097
- ##
1098
- # Applies a free-form matrix transformation to everything drawn in the block.
1099
- #
1100
- # @return [void]
1101
- # @param m0 [Float]
1102
- # @param m1 [Float]
1103
- # @param m2 [Float]
1104
- # @param m3 [Float]
1105
- # @param m4 [Float]
1106
- # @param m5 [Float]
1107
- # @param m6 [Float]
1108
- # @param m7 [Float]
1109
- # @param m8 [Float]
1110
- # @param m9 [Float]
1111
- # @param m10 [Float]
1112
- # @param m11 [Float]
1113
- # @param m12 [Float]
1114
- # @param m13 [Float]
1115
- # @param m14 [Float]
1116
- # @param m15 [Float]
1117
- # @yield rendering code.
1118
- #
1119
- # @see #draw
1120
- # @see #rotate
1121
- # @see #scale
1122
- # @see #translate
1123
- def transform(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15); end
1124
-
1125
- # @!endgroup
1126
-
1127
- ##
1128
- # Returns the character a button usually produces, if any.
1129
- #
1130
- # @note For real text input, look at {TextInput} instead.
1131
- #
1132
- # @return [String?] the character the button usually produces.
1133
- # @param id [Fixnum] the button's platform-defined id.
1134
- #
1135
- # @see char_to_button_id
1136
- # @see #text_input
1137
- # @see TextInput
1138
- def self.button_id_to_char(id); end
1139
-
1140
- ##
1141
- # Returns the button that usually produces a character, if any.
1142
- #
1143
- # @return [Fixnum?] the button that usually produces the character.
1144
- # @param char [String] the character to query.
1145
- #
1146
- # @see button_id_to_char
1147
- # @see #text_input
1148
- # @see TextInput
1149
- def self.char_to_button_id(char); end
1150
-
1151
- ##
1152
- # @deprecated Use {#mouse_x=} and {#mouse_y=} instead.
1153
- def set_mouse_position(x, y); end
1154
- end
1155
-
1156
- ##
1157
- # Holds information about the underlying OpenGL texture and UV coordinates of an image.
1158
- #
1159
- # Can be retrieved from some images to use them in OpenGL operations.
1160
- #
1161
- # @see Gosu::Image#gl_tex_info
1162
- # @see file:examples/OpenGLIntegration.rb
1163
- class GLTexInfo
1164
- ##
1165
- # @return [Fixnum] OpenGL texture id
1166
- attr_reader :tex_name
1167
-
1168
- ##
1169
- # @return [Float] the U coordinate of the left edge of the image.
1170
- attr_reader :left
1171
-
1172
- ##
1173
- # @return [Float] the U coordinate of the right edge of the image.
1174
- attr_reader :right
1175
-
1176
- ##
1177
- # @return [Float] the V coordinate of the top edge of the image.
1178
- attr_reader :top
1179
-
1180
- ##
1181
- # @return [Float] the V coordinate of the bottom edge of the image.
1182
- attr_reader :bottom
1183
- end
1184
-
1185
- class << self
1186
- ##
1187
- # @return [Float] a random number in the range (min...max).
1188
- # @param min [Float] the minimum value, inclusive.
1189
- # @param max [Float] the maximum value, exclusive.
1190
- def random(min, max); end
1191
-
1192
- ##
1193
- # @return [Float] the X component of a vector of angle theta and magnitude r, or the vertical distance covered by moving r pixels in the direction given by theta.
1194
- # @param theta [Float]
1195
- # @param r [Float]
1196
- def offset_x(theta, r); end
1197
-
1198
- ##
1199
- # @return [Float] the Y component of a vector of angle theta and magnitude r, or the vertical distance covered by moving r pixels in the direction given by theta.
1200
- # @param theta [Float]
1201
- # @param r [Float]
1202
- def offset_y(theta, r); end
1203
-
1204
- ##
1205
- # @return [Float] the angular distance from (x1, y1) to (x1, y2) in degrees, where 0.0 is up. Returns 0 if both points are equal.
1206
- # @param x1 [Float]
1207
- # @param y1 [Float]
1208
- # @param x2 [Float]
1209
- # @param y2 [Float]
1210
- def angle(x1, y1, x2, y2); end
1211
-
1212
- ##
1213
- # @return [Float] the shortest angular distance from angle1 to angle2. This can be negative if counter-clockwise rotation would yield a shorter distance.
1214
- # @param angle1 [Float]
1215
- # @param angle2 [Float]
1216
- def angle_diff(angle1, angle2); end
1217
-
1218
- ##
1219
- # @return [Float] the distance from (x1, y1) to (x2, y2).
1220
- # @param x1 [Float]
1221
- # @param y1 [Float]
1222
- # @param x2 [Float]
1223
- # @param y2 [Float]
1224
- def distance(x1, y1, x2, y2); end
1225
-
1226
- ##
1227
- # @note For long-running games, this counter will eventually wrap around to 0 again.
1228
- #
1229
- # @return [Fixnum] the number of milliseconds elapsed.
1230
- def milliseconds(); end
1231
-
1232
- ##
1233
- # @return [Fixnum] the current framerate, in frames per second.
1234
- def fps(); end
1235
-
1236
- # @return [String] the name of a neutral font that is available on the current platform.
1237
- #
1238
- # @see Gosu::Font
1239
- # @see Gosu::Image#from_text
1240
- def default_font_name(); end
1241
-
1242
- ##
1243
- # @return [Fixnum] the width, in pixels, of the user's primary screen.
1244
- def screen_width(); end
1245
-
1246
- # @return [Fixnum] the height, in pixels, of the user's primary screen.
1247
- def screen_height(); end
1248
-
1249
- ##
1250
- # Returns the language code for the user's preferred language. Expect return values such as 'en_US', 'de_DE.UTF-8', 'ja', 'zh-Hans', etc. You can rely only on the first two letters being a common language abbreviation.
1251
- #
1252
- # @return [String] the user's preferred language.
1253
- def language(); end
1254
- end
1255
- end
1256
-
1257
- ##
1258
- # Small additions to Numeric to make it easier to integrate Gosu with
1259
- # libraries that use radians, like Chipmunk.
1260
- class ::Numeric
1261
- ##
1262
- # Converts radians to a Gosu-compatible angle using the formula <tt>self * 180.0 / Math::PI + 90</tt>.
1263
- #
1264
- # @return [Float] degrees.
1265
- def radians_to_gosu(); end
1266
-
1267
- ##
1268
- # Converts a Gosu-compatible angle to radians using the formula <tt>(self - 90) * Math::PI / 180.0</tt>.
1269
- #
1270
- # @return [Float] radians.
1271
- def gosu_to_radians(); end
1272
-
1273
- ##
1274
- # Converts degrees to radians.
1275
- #
1276
- # @return [Float] radians.
1277
- def degrees_to_radians(); end
1278
-
1279
- ##
1280
- # Converts radians to degrees.
1281
- #
1282
- # @return [Float] degrees.
1283
- def radians_to_degrees(); end
1284
- end