gosu 0.8.7.2 → 0.9.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/COPYING +29 -0
  3. data/Gosu/Audio.hpp +1 -0
  4. data/Gosu/Font.hpp +8 -4
  5. data/Gosu/Graphics.hpp +28 -18
  6. data/Gosu/GraphicsBase.hpp +17 -13
  7. data/Gosu/Image.hpp +54 -45
  8. data/Gosu/Input.hpp +5 -5
  9. data/Gosu/Version.hpp +3 -3
  10. data/Gosu/Window.hpp +1 -8
  11. data/README.txt +25 -0
  12. data/ext/gosu/gosu_wrap.cxx +1495 -1275
  13. data/ext/gosu/gosu_wrap.h +2 -2
  14. data/lib/gosu/patches.rb +71 -35
  15. data/lib/gosu/preview.rb +9 -142
  16. data/lib/gosu/swig_patches.rb +20 -10
  17. data/rdoc/gosu.rb +1185 -0
  18. data/src/Bitmap/BitmapUtils.cpp +9 -9
  19. data/src/Graphics/Common.hpp +3 -1
  20. data/src/Graphics/Graphics.cpp +100 -38
  21. data/src/Graphics/Image.cpp +57 -15
  22. data/src/Graphics/LargeImageData.cpp +9 -10
  23. data/src/Graphics/LargeImageData.hpp +1 -1
  24. data/src/Graphics/TexChunk.cpp +5 -6
  25. data/src/Graphics/TexChunk.hpp +1 -4
  26. data/src/Graphics/Texture.cpp +10 -3
  27. data/src/Graphics/Texture.hpp +1 -2
  28. data/src/Iconv.hpp +2 -2
  29. data/src/Input/Input.cpp +25 -9
  30. data/src/Input/InputTouch.mm +5 -3
  31. data/src/Text/Font.cpp +13 -8
  32. data/src/Window.cpp +66 -37
  33. data/src/WindowTouch.mm +3 -3
  34. metadata +79 -92
  35. data/examples/ChipmunkIntegration.rb +0 -275
  36. data/examples/CptnRuby.rb +0 -223
  37. data/examples/GosuZen.rb +0 -68
  38. data/examples/MoreChipmunkAndRMagick.rb +0 -155
  39. data/examples/OpenGLIntegration.rb +0 -226
  40. data/examples/RMagickIntegration.rb +0 -417
  41. data/examples/TextInput.rb +0 -154
  42. data/examples/Tutorial.rb +0 -131
  43. data/examples/media/Beep.wav +0 -0
  44. data/examples/media/CptnRuby Gem.png +0 -0
  45. data/examples/media/CptnRuby Map.txt +0 -25
  46. data/examples/media/CptnRuby Tileset.png +0 -0
  47. data/examples/media/CptnRuby.png +0 -0
  48. data/examples/media/Cursor.png +0 -0
  49. data/examples/media/Earth.png +0 -0
  50. data/examples/media/Explosion.wav +0 -0
  51. data/examples/media/Landscape.svg +0 -10
  52. data/examples/media/LargeStar.png +0 -0
  53. data/examples/media/Smoke.png +0 -0
  54. data/examples/media/Soldier.png +0 -0
  55. data/examples/media/Space.png +0 -0
  56. data/examples/media/Star.png +0 -0
  57. data/examples/media/Starfighter.bmp +0 -0
@@ -1,6 +1,6 @@
1
1
  /* ----------------------------------------------------------------------------
2
2
  * This file was automatically generated by SWIG (http://www.swig.org).
3
- * Version 3.0.2
3
+ * Version 3.0.5
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
@@ -28,7 +28,7 @@ public:
28
28
  class SwigDirector_Window : public Gosu::Window, public Swig::Director {
29
29
 
30
30
  public:
31
- SwigDirector_Window(VALUE self, unsigned int width, unsigned int height, bool fullscreen, double updateInterval = 16.666666);
31
+ SwigDirector_Window(VALUE self, unsigned int width, unsigned int height, bool fullscreen = false, double updateInterval = 16.666666);
32
32
  virtual ~SwigDirector_Window();
33
33
  virtual void update();
34
34
  virtual void draw();
@@ -1,76 +1,112 @@
1
- # Extend Numeric with simple angle conversion methods.
1
+ # Extend Numeric with simple angle conversion methods,
2
+ # for easier integration with Chipmunk.
2
3
  class ::Numeric
3
4
  def degrees_to_radians
4
5
  self * Math::PI / 180.0
5
6
  end
7
+
6
8
  def radians_to_degrees
7
9
  self * 180.0 / Math::PI
8
10
  end
11
+
9
12
  def gosu_to_radians
10
13
  (self - 90) * Math::PI / 180.0
11
14
  end
15
+
12
16
  def radians_to_gosu
13
17
  self * 180.0 / Math::PI + 90
14
18
  end
15
19
  end
16
-
17
- # Backwards compatibility: import constants into Gosu::Button.
20
+
21
+ # Backwards compatibility:
22
+ # Import constants into Gosu::Button.
18
23
  module Gosu::Button
19
24
  Gosu.constants.each { |c| const_set(c, Gosu.const_get(c)) }
20
25
  end
21
26
 
22
- # Backwards compatibility: Window arguments to Sample and Song
27
+ # Backwards compatibility:
28
+ # The old version of from_text has been deprecated in Gosu 0.9.
29
+ class Gosu::Image
30
+ class << self
31
+ alias from_text_without_window from_text
32
+ end
33
+
34
+ def self.from_text(*args)
35
+ if args.size == 4
36
+ from_text_without_window(args[1], args[3], :font => args[2])
37
+ elsif args.size == 7
38
+ from_text_without_window(args[1], args[3], :font => args[2],
39
+ :spacing => args[4], :width => args[5], :align => args[6])
40
+ else
41
+ from_text_without_window(*args)
42
+ end
43
+ end
44
+ end
45
+
46
+ # Backwards compatibility:
47
+ # Passing a Window Sample#initialize has been deprecated in Gosu 0.7.17.
23
48
  class Gosu::Sample
24
- alias initialize_ initialize
49
+ alias initialize_without_window initialize
25
50
 
26
51
  def initialize(*args)
27
52
  args.shift if args.first.is_a? Gosu::Window
28
- initialize_(*args)
53
+ initialize_without_window(*args)
29
54
  end
30
55
  end
56
+
57
+ # Backwards compatibility:
58
+ # Passing a Window to Song#initialize has been deprecated in Gosu 0.7.17.
31
59
  class Gosu::Song
32
- alias initialize_ initialize
60
+ alias initialize_without_window initialize
33
61
 
34
62
  def initialize(*args)
35
63
  args.shift if args.first.is_a? Gosu::Window
36
- initialize_(*args)
64
+ initialize_without_window(*args)
37
65
  end
38
66
  end
39
67
 
40
- # Color constants (SWIG messes up constants somehow)
41
- class Gosu::Color
42
- class Constant < Gosu::Color
43
- private
44
- def alpha=; end
45
- def red=; end
46
- def green=; end
47
- def blue=; end
48
- def hue=; end
49
- def saturation=; end
50
- def value=; end
68
+ # Color constants.
69
+ # This is cleaner than having SWIG define them.
70
+ module Gosu
71
+ class ImmutableColor < Color
72
+ private :alpha=, :red=, :green=, :blue=, :hue=, :saturation=, :value=
51
73
  end
52
74
 
53
- NONE = Gosu::Color::Constant.argb(0x00000000)
54
- BLACK = Gosu::Color::Constant.argb(0xff000000)
55
- GRAY = Gosu::Color::Constant.argb(0xff808080)
56
- WHITE = Gosu::Color::Constant.argb(0xffffffff)
57
- AQUA = Gosu::Color::Constant.argb(0xff00ffff)
58
- RED = Gosu::Color::Constant.argb(0xffff0000)
59
- GREEN = Gosu::Color::Constant.argb(0xff00ff00)
60
- BLUE = Gosu::Color::Constant.argb(0xff0000ff)
61
- YELLOW = Gosu::Color::Constant.argb(0xffffff00)
62
- FUCHSIA = Gosu::Color::Constant.argb(0xffff00ff)
63
- CYAN = Gosu::Color::Constant.argb(0xff00ffff)
75
+ class Color
76
+ NONE = Gosu::ImmutableColor.new(0x00_000000)
77
+ BLACK = Gosu::ImmutableColor.new(0xff_000000)
78
+ GRAY = Gosu::ImmutableColor.new(0xff_808080)
79
+ WHITE = Gosu::ImmutableColor.new(0xff_ffffff)
80
+ AQUA = Gosu::ImmutableColor.new(0xff_00ffff)
81
+ RED = Gosu::ImmutableColor.new(0xff_ff0000)
82
+ GREEN = Gosu::ImmutableColor.new(0xff_00ff00)
83
+ BLUE = Gosu::ImmutableColor.new(0xff_0000ff)
84
+ YELLOW = Gosu::ImmutableColor.new(0xff_ffff00)
85
+ FUCHSIA = Gosu::ImmutableColor.new(0xff_ff00ff)
86
+ CYAN = Gosu::ImmutableColor.new(0xff_00ffff)
87
+ end
64
88
  end
65
89
 
66
- # Instance methods for button_id_to_char and char_to_button_id
67
90
  class Gosu::Window
68
- def button_id_to_char(id)
69
- self.class.button_id_to_char(id)
91
+ # Backwards compatibility:
92
+ # Class methods that have been turned into module methods.
93
+ def self.button_id_to_char(id)
94
+ Gosu.button_id_to_char(id)
95
+ end
96
+
97
+ def self.char_to_button_id(ch)
98
+ Gosu.char_to_button_id(ch)
70
99
  end
71
100
 
72
- def char_to_button_id(ch)
73
- self.class.char_to_button_id(ch)
101
+ # Backwards compatibility:
102
+ # Instance methods taht have been turned into module methods.
103
+ %w(draw_line draw_triangle draw_quad
104
+ flush gl clip_to record
105
+ transform translate rotate scale
106
+ button_id_to_char char_to_button_id button_down?).each do |method|
107
+ define_method method.to_sym do |*args|
108
+ Gosu.send method, *args
109
+ end
74
110
  end
75
111
  end
76
112
 
@@ -1,143 +1,10 @@
1
- require 'gosu'
2
-
3
- # Wrapper around Gosu 0.4-0.8 that provides the work-in-progress 0.9 interface
1
+ warn "gosu/preview.rb has been removed in Gosu 0.9.0, and Gosu itself \n" +
2
+ "provides a similar interface to what preview.rb used to offer.\n" +
3
+ "Notable differences:\n" +
4
+ "• no global $window variable\n" +
5
+ "• no global Gosu.mouse_x and Gosu.mouse_y functions\n" +
6
+ "• Image#initialize et.al. use an options hash now\n" +
7
+ "If you cannot update your code base right now, you should require \n" +
8
+ "Gosu 0.8.x in your Gemfile: gem 'gosu', '~> 0.8.0'";
4
9
 
5
- module Gosu
6
- class Font
7
- alias :initialize_old :initialize
8
-
9
- def initialize *args
10
- if args.first.is_a? Gosu::Window then
11
- initialize_old *args
12
- else
13
- height = args[0]
14
- options = args[1] || {}
15
- name = options[:name] || Gosu::default_font_name
16
- initialize_old $window, name, height
17
- end
18
- end
19
- end
20
-
21
- class Window
22
- alias :initialize_old :initialize
23
-
24
- def initialize width, height, *args
25
- if args.empty? or args.first.is_a? Hash then
26
- options = args.first || {}
27
- fullscreen = !!options[:fullscreen]
28
- update_interval = options[:update_interval] || 16.66
29
- else
30
- fullscreen, update_interval = *args
31
- end
32
- $window = initialize_old width, height, fullscreen, update_interval
33
- end
34
- end
35
-
36
- class Image
37
- alias :initialize_old :initialize
38
-
39
- def initialize *args
40
- if args.first.is_a? Gosu::Window then
41
- initialize_old *args
42
- else
43
- source = args[0]
44
- tileable = !args[1] || args[1][:tileable]
45
- rect = args[1] && args[1][:rect]
46
- if rect then
47
- initialize_old $window, source, !!tileable, *rect
48
- else
49
- initialize_old $window, source, !!tileable
50
- end
51
- end
52
- end
53
-
54
- class <<self
55
- alias load_tiles_old load_tiles
56
- end
57
-
58
- def self.load_tiles *args
59
- if args.first.is_a? Gosu::Window then
60
- load_tiles_old *args
61
- else
62
- source = args[0]
63
- x, y = args[1..2]
64
- tileable = !args[3] || args[3][:tileable]
65
- load_tiles_old $window, source, x, y, !!tileable
66
- end
67
- end
68
-
69
- def self.from_text *args
70
- if args.first.is_a? Gosu::Window then
71
- args.size == 4 ? from_text4(*args) : from_text7(*args)
72
- else
73
- text = args[0]
74
- height = args[1]
75
- options = args[2] || {}
76
- font = options[:font] || Gosu::default_font_name
77
- if width = options[:width] then
78
- spacing = options[:spacing] || 0
79
- align = options[:align] || :left
80
- Gosu::Image.from_text7 $window, text, font, height, spacing, width, align
81
- else
82
- Gosu::Image.from_text4 $window, text, font, height
83
- end
84
- end
85
- end
86
- end
87
-
88
- def self.button_down? id
89
- $window.button_down? id
90
- end
91
-
92
- def self.mouse_x
93
- $window.mouse_x
94
- end
95
-
96
- def self.mouse_y
97
- $window.mouse_y
98
- end
99
-
100
- def self.draw_line *args
101
- $window.draw_line *args
102
- end
103
-
104
- def self.draw_triangle *args
105
- $window.draw_triangle *args
106
- end
107
-
108
- def self.draw_quad *args
109
- $window.draw_quad *args
110
- end
111
-
112
- def self.draw_rect x, y, width, height, color = 0xffffffff, z = 0, mode = :default
113
- $window.draw_quad x, y, color, x + width, y, color, x, y + height, color, x + width, y + height, color, z, mode
114
- end
115
-
116
- def self.clip_to *args, &draw
117
- $window.clip_to *args, &draw
118
- end
119
-
120
- def self.translate *args, &draw
121
- $window.translate *args, &draw
122
- end
123
-
124
- def self.scale *args, &draw
125
- $window.scale *args, &draw
126
- end
127
-
128
- def self.rotate *args, &draw
129
- $window.rotate *args, &draw
130
- end
131
-
132
- def self.transform *args, &draw
133
- $window.transform *args, &draw
134
- end
135
-
136
- def self.record width, height, &draw
137
- $window.record width, height, &draw
138
- end
139
-
140
- def self.gl *args, &draw
141
- $window.gl *args, &draw
142
- end
143
- end
10
+ require 'gosu'
@@ -6,6 +6,19 @@
6
6
  # compatible, but I just call protected_update etc. in the Ruby wrapper so I can add this
7
7
  # custom debugging help:
8
8
  class Gosu::Window
9
+ alias initialize_without_hash initialize
10
+
11
+ def initialize width, height, *args
12
+ if args.empty? or args.first.is_a? Hash then
13
+ options = args.first || {}
14
+ fullscreen = options[:fullscreen]
15
+ update_interval = options[:update_interval]
16
+ else
17
+ fullscreen, update_interval = *args
18
+ end
19
+ initialize_without_hash width, height, !!fullscreen, update_interval || 16.666666
20
+ end
21
+
9
22
  %w(update draw needs_redraw? needs_cursor?
10
23
  lose_focus button_down button_up).each do |callback|
11
24
  define_method "protected_#{callback}" do |*args|
@@ -27,12 +40,6 @@ class Gosu::Window
27
40
  $gosu_gl_blocks = nil
28
41
  end
29
42
 
30
- def gl(*args, &block)
31
- $gosu_gl_blocks ||= []
32
- $gosu_gl_blocks << block
33
- unsafe_gl(*args, &block)
34
- end
35
-
36
43
  alias show_internal show
37
44
  def show
38
45
  show_internal
@@ -47,10 +54,13 @@ class Gosu::Window
47
54
  end
48
55
  end
49
56
 
50
- # SWIG doesn't understand the C++ overloading, so we need this simple check in Ruby.
51
- class Gosu::Image
52
- def self.from_text(*args)
53
- args.size == 4 ? from_text4(*args) : from_text7(*args)
57
+ module Gosu
58
+ # Keep a reference to these blocks that is only cleared after Window#draw.
59
+ # Otherwise, the GC might free these blocks while Gosu is still rendering.
60
+ def self.gl(*args, &block)
61
+ $gosu_gl_blocks ||= []
62
+ $gosu_gl_blocks << block
63
+ unsafe_gl(*args, &block)
54
64
  end
55
65
  end
56
66
 
@@ -0,0 +1,1185 @@
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", "0.1.2.3" or "0.1.2pre4".
15
+ GOSU_VERSION = :a_string
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 Kb1 Kb2 Kb3 Kb4 Kb5 Kb6 Kb7 Kb8 Kb9 = :implementation_defined
23
+ KbA KbB KbC KbD KbE KbF KbG KbH KbI KbJ KbK KbL KbM KbN KbO KbP KbQ KbR KbS KbT KbU KbV KbW KbX KbY KbZ = :implementation_defined
24
+ KbBackspace = :implementation_defined
25
+ KbDelete = :implementation_defined
26
+ KbDown = :implementation_defined
27
+ KbEnd = :implementation_defined
28
+
29
+ ##
30
+ # This is the key on the numpad.
31
+ KbEnter = :implementation_defined
32
+
33
+ KbEscape = :implementation_defined
34
+ KbF1 KbF2 KbF3 KbF4 KbF5 KbF6 KbF7 KbF8 KbF9 KbF10 KbF11 KbF12 = :implementation_defined
35
+ KbHome = :implementation_defined
36
+ KbInsert = :implementation_defined
37
+ KbLeft = :implementation_defined
38
+ KbLeftAlt = :implementation_defined
39
+ KbLeftControl = :implementation_defined
40
+ KbLeftShift = :implementation_defined
41
+ KbNumpad0 KbNumpad1 KbNumpad2 KbNumpad3 KbNumpad4 KbNumpad5 KbNumpad6 KbNumpad7 KbNumpad8 KbNumpad9 = :implementation_defined
42
+ KbNumpadAdd = :implementation_defined
43
+ KbNumpadDivide = :implementation_defined
44
+ KbNumpadMultiply = :implementation_defined
45
+ KbNumpadSubtract = :implementation_defined
46
+ KbPageDown = :implementation_defined
47
+ KbPageUp = :implementation_defined
48
+
49
+ ##
50
+ # This is the key above the right shift key.
51
+ KbReturn = :implementation_defined
52
+
53
+ KbRight = :implementation_defined
54
+ KbRightAlt = :implementation_defined
55
+ KbRightControl = :implementation_defined
56
+ KbRightShift = :implementation_defined
57
+ KbSpace = :implementation_defined
58
+ KbTab = :implementation_defined
59
+ KbUp = :implementation_defined
60
+ KbBacktick = :implementation_defined
61
+ KbMinus = :implementation_defined
62
+ KbEqual = :implementation_defined
63
+ KbBracketLeft = :implementation_defined
64
+ KbBracketRight = :implementation_defined
65
+ KbBackslash = :implementation_defined
66
+ KbSemicolon = :implementation_defined
67
+ KbApostrophe = :implementation_defined
68
+ KbComma = :implementation_defined
69
+ KbPeriod = :implementation_defined
70
+ KbSlash = :implementation_defined
71
+
72
+ MsLeft = :implementation_defined
73
+ MsMiddle = :implementation_defined
74
+ MsRight = :implementation_defined
75
+ MsWheelDown = :implementation_defined
76
+ MsWheelUp = :implementation_defined
77
+ MsOther0 MsOther1 MsOther2 MsOther3 MsOther4 MsOther5 MsOther6 MsOther7 = :implementation_defined
78
+
79
+ GpButton0 GpButton1 GpButton2 GpButton3 GpButton4 GpButton5 GpButton6 GpButton7 GpButton8 GpButton9 GpButton10 GpButton11 GpButton12 GpButton13 GpButton14 GpButton15 = :implementation_defined
80
+ GpDown = :implementation_defined
81
+ GpLeft = :implementation_defined
82
+ GpRight = :implementation_defined
83
+ GpUp = :implementation_defined
84
+
85
+ Gp0Button0 Gp0Button1 Gp0Button2 Gp0Button3 Gp0Button4 Gp0Button5 Gp0Button6 Gp0Button7 Gp0Button8 Gp0Button9 Gp0Button10 Gp0Button11 Gp0Button12 Gp0Button13 Gp0Button14 Gp0Button15 = :implementation_defined
86
+ Gp0Down = :implementation_defined
87
+ Gp0Left = :implementation_defined
88
+ Gp0Right = :implementation_defined
89
+ Gp0Up = :implementation_defined
90
+
91
+ Gp1Button0 Gp1Button1 Gp1Button2 Gp1Button3 Gp1Button4 Gp1Button5 Gp1Button6 Gp1Button7 Gp1Button8 Gp1Button9 Gp1Button10 Gp1Button11 Gp1Button12 Gp1Button13 Gp1Button14 Gp1Button15 = :implementation_defined
92
+ Gp1Down = :implementation_defined
93
+ Gp1Left = :implementation_defined
94
+ Gp1Right = :implementation_defined
95
+ Gp1Up = :implementation_defined
96
+
97
+ Gp2Button0 Gp2Button1 Gp2Button2 Gp2Button3 Gp2Button4 Gp2Button5 Gp2Button6 Gp2Button7 Gp2Button8 Gp2Button9 Gp2Button10 Gp2Button11 Gp2Button12 Gp2Button13 Gp2Button14 Gp2Button15 = :implementation_defined
98
+ Gp2Down = :implementation_defined
99
+ Gp2Left = :implementation_defined
100
+ Gp2Right = :implementation_defined
101
+ Gp2Up = :implementation_defined
102
+
103
+ Gp3Button0 Gp3Button1 Gp3Button2 Gp3Button3 Gp3Button4 Gp3Button5 Gp3Button6 Gp3Button7 Gp3Button8 Gp3Button9 Gp3Button10 Gp3Button11 Gp3Button12 Gp3Button13 Gp3Button14 Gp3Button15 = :implementation_defined
104
+ Gp3Down = :implementation_defined
105
+ Gp3Left = :implementation_defined
106
+ Gp3Right = :implementation_defined
107
+ Gp3Up = :implementation_defined
108
+
109
+ ##
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
+ class Color
112
+ ##
113
+ # @return [Fixnum] the color's alpha channel.
114
+ attr_accessor :alpha
115
+
116
+ ##
117
+ # @return [Fixnum] the color's red channel.
118
+ attr_accessor :red
119
+
120
+ ##
121
+ # @return [Fixnum] the color's green channel.
122
+ attr_accessor :green
123
+
124
+ ##
125
+ # @return [Fixnum] the color's blue channel.
126
+ attr_accessor :blue
127
+
128
+ ##
129
+ # @return [Fixnum] the color's hue in the range (0...360).
130
+ attr_accessor :hue
131
+
132
+ ##
133
+ # @return [Float] the color's saturation in the range (0..1).
134
+ attr_accessor :saturation
135
+
136
+ ##
137
+ # @return [Float] the color's value in the range (0..1).
138
+ attr_accessor :value
139
+
140
+ # @!group Creating colors.
141
+
142
+ ##
143
+ # @overload initialize(argb)
144
+ # @param argb [Fixnum] an integer of the form 0xAARRGGBB.
145
+ #
146
+ # @overload initialize(a, r, g, b)
147
+ # @param a [Fixnum] the color's alpha channel in the range (0..255).
148
+ # @param r [Fixnum] the color's red channel in the range (0..255).
149
+ # @param g [Fixnum] the color's green channel in the range (0..255).
150
+ # @param b [Fixnum] the color's blue channel in the range (0..255).
151
+ #
152
+ # @see from_hsv
153
+ # @see from_ahsv
154
+ # @see rgba
155
+ # @see argb
156
+ def initialize(*args); end
157
+
158
+ ##
159
+ # @return (see #initialize)
160
+ #
161
+ # @overload rgba(rgba)
162
+ # @param argb [Fixnum] an integer of the form 0xRRGGBBAA.
163
+ #
164
+ # @overload rgba(r, g, b, a)
165
+ # @param r [Fixnum] the color's red channel in the range (0..255).
166
+ # @param g [Fixnum] the color's green channel in the range (0..255).
167
+ # @param b [Fixnum] the color's blue channel in the range (0..255).
168
+ # @param a [Fixnum] the color's alpha channel in the range (0..255).
169
+ #
170
+ # @see #initialize
171
+ # @see argb
172
+ def self.rgba(*args); end
173
+
174
+ # This method is equivalent to calling `Color.new`, but the name makes the parameter order explicit.
175
+ #
176
+ # @return (see #initialize)
177
+ # @overload argb(argb)
178
+ # @overload argb(a, r, g, b)
179
+ #
180
+ # @see #initialize
181
+ # @see rgba
182
+ def self.argb(*args); end
183
+
184
+ # Converts an HSV triplet to an opaque color.
185
+ #
186
+ # @return [Color] a color corresponding to the HSV triplet.
187
+ # @param h [Fixnum] the color's hue in the range (0..360).
188
+ # @param s [Float] the color's saturation in the range (0..1).
189
+ # @param v [Float] the color's value in the range (0..1).
190
+ #
191
+ # @see from_ahsv
192
+ def self.from_hsv(h, s, v); end
193
+
194
+ # Converts an HSV triplet to a color with the alpha channel set to a given value.
195
+ #
196
+ # @return (see from_hsv)
197
+ # @param a [Fixnum] the color's opacity in the range (0..255).
198
+ # @param (see from_hsv)
199
+ #
200
+ # @see from_hsv
201
+ def self.from_ahsv(a, h, s, v); end
202
+
203
+ # @!endgroup
204
+
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
+ #
207
+ # @return [Fixnum] a 32-bit OpenGL color.
208
+ def gl; end
209
+
210
+ ##
211
+ # @return [Color] a copy of the color.
212
+ def dup; end
213
+
214
+ NONE = Gosu::Color.argb(0x00_000000)
215
+ BLACK = Gosu::Color.argb(0xff_000000)
216
+ GRAY = Gosu::Color.argb(0xff_808080)
217
+ WHITE = Gosu::Color.argb(0xff_ffffff)
218
+ AQUA = Gosu::Color.argb(0xff_00ffff)
219
+ RED = Gosu::Color.argb(0xff_ff0000)
220
+ GREEN = Gosu::Color.argb(0xff_00ff00)
221
+ BLUE = Gosu::Color.argb(0xff_0000ff)
222
+ YELLOW = Gosu::Color.argb(0xff_ffff00)
223
+ FUCHSIA = Gosu::Color.argb(0xff_ff00ff)
224
+ CYAN = Gosu::Color.argb(0xff_00ffff)
225
+ end
226
+
227
+ ##
228
+ # A Font can be used to draw text on a Window object very flexibly.
229
+ # Fonts are ideal for small texts that change regularly.
230
+ # For large, static texts you should use {Gosu::Image#from_text}.
231
+ class Font
232
+ ##
233
+ # The font's name. This may be the name of a system font or a filename.
234
+ #
235
+ # @return [String] the font's name.
236
+ attr_reader :name
237
+
238
+ ##
239
+ # @return [Fixnum] the font's height in pixels.
240
+ attr_reader :height
241
+
242
+ ##
243
+ # Load a font from the system fonts or a file.
244
+ #
245
+ # (Passing a Window reference is not necessary anymore, please use the first overload from now on.)
246
+ #
247
+ # @param height [Fixnum] the height of the font, in pixels.
248
+ # @param [Hash] options
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
+ #
251
+ # @overload initialize(height, options = {})
252
+ # @overload initialize(window, font_name, height)
253
+ def initialize(height, options = {}); end
254
+
255
+ ##
256
+ # Overrides the image for a character.
257
+ #
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
+ #
260
+ # @return [void]
261
+ # @param character [String] the character to replace.
262
+ # @param image [Image] the image to use for the character.
263
+ def []=(character, image); end
264
+
265
+ # @!group Drawing text
266
+
267
+ ##
268
+ # Draws a single line of text with its top left corner at (x, y).
269
+ #
270
+ # @return [void]
271
+ # @param text [String]
272
+ # @param x [Number] the X coordinate
273
+ # @param y [Number] the Y coordinate
274
+ # @param z [Number] the Z-order.
275
+ # @param scale_x [Float] the horizontal scaling factor.
276
+ # @param scale_y [Float] the vertical scaling factor.
277
+ # @param color [Color, Fixnum]
278
+ # @param mode [:default, :additive] the blending mode to use.
279
+ #
280
+ # @see #draw_rel
281
+ # @see Gosu::Image.from_text
282
+ # @see https://github.com/jlnr/gosu/wiki/Basic-Concepts#drawing-with-colours Drawing with colors, explained in the Gosu Wiki
283
+ # @see https://github.com/jlnr/gosu/wiki/Basic-Concepts#z-ordering Z-ordering explained in the Gosu Wiki
284
+ def draw(text, x, y, z, scale_x=1, scale_y=1, color=0xff_ffffff, mode=:default); end
285
+
286
+ ##
287
+ # Draws a single line of text relative to (x, y).
288
+ #
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
+ #
291
+ # All real numbers are valid alignment values and will be interpolated (or extrapolated) accordingly.
292
+ #
293
+ # @return [void]
294
+ # @param rel_x [Float] the horizontal alignment.
295
+ # @param rel_y [Float] the vertical alignment.
296
+ # @param (see #draw)
297
+ #
298
+ # @see #draw
299
+ # @see https://github.com/jlnr/gosu/wiki/Basic-Concepts#drawing-with-colours Drawing with colors, explained in the Gosu Wiki
300
+ # @see https://github.com/jlnr/gosu/wiki/Basic-Concepts#z-ordering Z-ordering explained in the Gosu Wiki
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
+
303
+ ##
304
+ # @deprecated Use {#draw} in conjunction with {Gosu.rotate} instead.
305
+ #
306
+ # @see #draw
307
+ # @see Gosu::Window#rotate
308
+ def draw_rot(text, x, y, z, angle, scale_x=1, scale_y=1, color=0xff_ffffff, mode=:default); end
309
+
310
+ # @!endgroup
311
+
312
+ ##
313
+ # Returns the width of a single line of text, in pixels, if it were drawn.
314
+ #
315
+ # @return [Fixnum] the width of the text, in pixels.
316
+ # @param text [String]
317
+ def text_width(text, scale_x=1); end
318
+ end
319
+
320
+ ##
321
+ # Provides functionality for drawing rectangular images.
322
+ class Image
323
+ ##
324
+ # @return [Fixnum] the image's width, in pixels.
325
+ attr_reader :width
326
+
327
+ ##
328
+ # @return [Fixnum] the image's height, in pixels.
329
+ attr_reader :height
330
+
331
+ # @!group Creating and loading images
332
+
333
+ ##
334
+ # Loads an image from a file or an RMagick image.
335
+ #
336
+ # (Passing a Window reference is not necessary anymore, please use the first overload from now on.)
337
+ #
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
+ #
340
+ # @param [String, Magick::Image] source the filename or RMagick image to load from.
341
+ # @param [Hash] options
342
+ # @option options [true, false] :tileable (false) if true, the Image will not have soft edges when scaled
343
+ # @option options [Array] :rect ([0, 0, image_width, image_height]) the source rectangle in the image
344
+ #
345
+ # @overload initialize(source, options = {})
346
+ # @overload initialize(window, source, tileable = false)
347
+ # @overload initialize(window, source, tileable, left, top, width, height)
348
+ #
349
+ # @see load_tiles
350
+ # @see from_text
351
+ # @see https://github.com/jlnr/gosu/wiki/Basic-Concepts#tileability Tileability explained in the Gosu Wiki
352
+ def initialize(source, options = {}); end
353
+
354
+ ##
355
+ # Creates a reusable image from one or more lines of text.
356
+ #
357
+ # (Passing a Window reference is not necessary anymore, please use the first overload from now on.)
358
+ #
359
+ # @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
+ # @overload from_text(text, line_height, options = {})
362
+ # @overload from_text(window, text, font_name, line_height)
363
+ # @overload from_text(window, text, font_name, line_height, line_spacing, width, align)
364
+ #
365
+ # @return [Gosu::Image]
366
+ # @param [String] text
367
+ # @param [Fixnum] line_height the line height, in pixels.
368
+ # @param [Hash] options
369
+ # @option options [String] :font (Gosu::default_font_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.
370
+ # @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
+ # @option options [Fixnum] :spacing (0) the spacing between lines, in pixels.
372
+ # @option options [:left, :right, :center, :justify] :align (:left) the text alignment.
373
+ #
374
+ # @see Gosu::Font
375
+ # @see https://github.com/jlnr/gosu/wiki/Basic-Concepts#drawing-with-colours Drawing with colors, explained in the Gosu Wiki
376
+ def self.from_text(text, line_height, options = {}); end
377
+
378
+ ##
379
+ # Loads an image from a file or an RMagick image, then divides the image into an array of equal-sized tiles.
380
+ #
381
+ # @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
+ # @return [Array<Gosu::Image>]
384
+ # @param source [String, Magick::Image]
385
+ # @param tile_width [Fixnum] If positive, this is the width of the individual tiles; if negative, the image is divided into -tile_width columns.
386
+ # @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
+ # @param [Hash] options
388
+ # @option options [true, false] :tileable (false) if true, the Image will not have soft edges when scaled
389
+ #
390
+ # @overload initialize(source, tile_width, tile_height, options = {})
391
+ # @overload initialize(window, source, tile_width, tile_height, tileable = false)
392
+ #
393
+ # (Passing a Window reference is not necessary anymore, please use the first overload from now on.)
394
+ #
395
+ # @see https://github.com/jlnr/gosu/wiki/Basic-Concepts#tileability Tileability explained in the Gosu Wiki
396
+ def self.load_tiles(source, tile_width, tile_height, options = {}); end
397
+
398
+ # @!endgroup
399
+
400
+ # @!group Drawing an image
401
+
402
+ ##
403
+ # Draws the image with its top left corner at (x, y).
404
+ #
405
+ # @return [void]
406
+ # @param x [Float] the X coordinate.
407
+ # @param y [Float] the X coordinate.
408
+ # @param z [Float] the Z-order.
409
+ # @param scale_x [Float] the horizontal scaling factor.
410
+ # @param scale_y [Float] the vertical scaling factor.
411
+ # @param color [Gosu::Color, Integer]
412
+ # @param mode [:default, :additive] the blending mode to use.
413
+ #
414
+ # @see #draw_rot
415
+ # @see #draw_as_quad
416
+ # @see https://github.com/jlnr/gosu/wiki/Basic-Concepts#drawing-with-colours Drawing with colors, explained in the Gosu Wiki
417
+ # @see https://github.com/jlnr/gosu/wiki/Basic-Concepts#z-ordering Z-ordering explained in the Gosu Wiki
418
+ def draw(x, y, z, scale_x=1, scale_y=1, color=0xff_ffffff, mode=:default); end
419
+
420
+ ##
421
+ # Draws the image rotated, with its rotational center at (x, y).
422
+ #
423
+ # @return [void]
424
+ # @param angle [Float]
425
+ # @param center_x [Float] the relative horizontal rotation origin.
426
+ # @param center_y [Float] the relative vertical rotation origin.
427
+ # @param (see #draw)
428
+ #
429
+ # @see #draw
430
+ # @see https://github.com/jlnr/gosu/wiki/Basic-Concepts#drawing-with-colours Drawing with colors, explained in the Gosu Wiki
431
+ # @see https://github.com/jlnr/gosu/wiki/Basic-Concepts#z-ordering Z-ordering explained in the Gosu Wiki
432
+ 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
+
434
+ ##
435
+ # 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
+ #
437
+ # @return [void]
438
+ # @param (see Gosu::Window#draw_quad)
439
+ #
440
+ # @see #draw
441
+ # @see Gosu::Window#draw_quad
442
+ # @see https://github.com/jlnr/gosu/wiki/Basic-Concepts#drawing-with-colours Drawing with colors, explained in the Gosu Wiki
443
+ # @see https://github.com/jlnr/gosu/wiki/Basic-Concepts#order-of-corners The order of corners explained in the Gosu Wiki
444
+ # @see https://github.com/jlnr/gosu/wiki/Basic-Concepts#z-ordering Z-ordering explained in the Gosu Wiki
445
+ def draw_as_quad(x1, y1, c1, x2, y2, c2, x3, y3, c3, x4, y4, c4, z, mode=:default); end
446
+
447
+ # @!endgroup
448
+
449
+ ##
450
+ # Returns an object that holds information about the underlying OpenGL texture and UV coordinates of the image.
451
+ #
452
+ # @note Some images may be too large to fit on a single texture; this method returns nil in those cases.
453
+ #
454
+ # @return [Gosu::GLTexInfo?] information about the underlying OpenGL texture.
455
+ #
456
+ # @see Gosu::GLTexInfo
457
+ # @see file:examples/OpenGLIntegration.rb
458
+ def gl_tex_info; end
459
+
460
+ ##
461
+ # Returns the associated texture contents as binary string of packed RGBA values, useful for use with RMagick (Magick::Image.from_blob).
462
+ #
463
+ # @return [String] a binary string of packed RGBA values.
464
+ def to_blob; end
465
+
466
+ ##
467
+ # 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
+ #
469
+ # This can be used to e.g. overwrite parts of a landscape.
470
+ #
471
+ # @return [void]
472
+ # @param source [String, Magick::Image] the filename or RMagick image to load from.
473
+ # @param x [Fixnum] the X coordinate of the top left corner.
474
+ # @param y [Fixnum] the Y coordinate of the top left corner.
475
+ def insert(source, x, y); end
476
+
477
+ ##
478
+ # Saves the image to a file. The file format is determined from the file extension.
479
+ #
480
+ # Useful for, e.g., pre-rendering text on a development machine where the necessary fonts are known to be available.
481
+ #
482
+ # @return [void]
483
+ # @param filename [String] the path to save the file under.
484
+ def save(filename); end
485
+ end
486
+
487
+ ##
488
+ # A sample is a short sound that is completely loaded in memory, can be
489
+ # played multiple times at once and offers very flexible playback
490
+ # parameters. Use samples for everything that's not music.
491
+ #
492
+ # @see Gosu::Song
493
+ class Sample
494
+ ##
495
+ # Loads a sample from a file.
496
+ #
497
+ # (Passing a Window reference is not necessary anymore, please use the first overload from now on.)
498
+ #
499
+ # @overload initialize(filename)
500
+ # @overload initialize(window, filename)
501
+ #
502
+ # @param filename [String] the path to load the sample from.
503
+ def initialize(filename); end
504
+
505
+ ##
506
+ # Plays the sample without panning.
507
+ #
508
+ # Playback speed is limited only by the underlying audio library, and both very large and very small values should work just fine.
509
+ #
510
+ # @return [SampleInstance]
511
+ # @param volume [Float] the playback volume, in the range (0..1), where 0 is completely silent and 1 is full volume.
512
+ # @param speed [Float] the playback speed.
513
+ # @param looping [true, false] whether the sample should play in a loop.
514
+ #
515
+ # @see #play_pan
516
+ def play(volume=1, speed=1, looping=false); end
517
+
518
+ ##
519
+ # Plays the sample with panning.
520
+ #
521
+ # @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
+ #
523
+ # @return [SampleInstance]
524
+ # @param pan [Float] the amount of panning. 0 is centered.
525
+ # @param (see #play)
526
+ #
527
+ # @see #play
528
+ def play_pan(pan=0, volume=1, speed=1, looping=false); end
529
+ end
530
+
531
+ ##
532
+ # An instance of a {Gosu::Sample} playing. Can be used to stop sounds dynamically, or to check if they are finished.
533
+ #
534
+ # 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
+ class SampleInstance
536
+ attr_writer :volume
537
+ attr_writer :speed
538
+ attr_writer :pan
539
+
540
+ ##
541
+ # Stops playback of this sample instance. After calling this method, the sample instance is useless and can be discarded.
542
+ #
543
+ # Calling `stop` after the sample has finished is harmless and has no effect.
544
+ #
545
+ # @return [void]
546
+ def stop; end
547
+
548
+ ##
549
+ # Pauses the sample, to be resumed afterwards.
550
+ #
551
+ # @note The sample will still occupy a playback channel while paused.
552
+ #
553
+ # @return [void]
554
+ def pause; end
555
+
556
+ ##
557
+ # Resumes playback of the sample.
558
+ #
559
+ # @return [void]
560
+ def resume; end
561
+
562
+ ##
563
+ # @return [true, false] whether the sample is paused.
564
+ def paused?; end
565
+
566
+ ##
567
+ # @return [true, false] whether the sample is playing.
568
+ def playing?; end
569
+ end
570
+
571
+ ##
572
+ # Songs are less flexible than samples in that only one can be played at a time, with no panning or speed control.
573
+ #
574
+ # @see Gosu::Sample
575
+ class Song
576
+ class <<Song
577
+ ##
578
+ # Returns the song currently being played (even if it's paused), or nil if no song is playing.
579
+ #
580
+ # @return [Gosu::Song?] the currently playing song.
581
+ attr_reader :current_song
582
+ end
583
+
584
+ ##
585
+ # @return [Float] the song's playback volume.
586
+ attr_accessor :volume
587
+
588
+ ##
589
+ # Loads a song from a file.
590
+ #
591
+ # (Passing a Window reference is not necessary anymore, please use the first overload instead.)
592
+ #
593
+ # @overload initialize(filename)
594
+ # @overload initialize(window, filename)
595
+ #
596
+ # @param filename [String] the path to load the song from.
597
+ def initialize(window, filename); end
598
+
599
+ ##
600
+ # Starts or resumes playback of the song.
601
+ #
602
+ # If another song is currently playing, it will be stopped and this song will be set as the current song.
603
+ #
604
+ # If `looping` is false, the current song will be set to `nil` when this song finishes.
605
+ #
606
+ # @return [void]
607
+ # @param looping [true, false] whether the song should play in a loop.
608
+ def play(looping=false); end
609
+
610
+ ##
611
+ # Pauses playback of the song. The current song is unchanged.
612
+ #
613
+ # @return [void]
614
+ def pause; end
615
+
616
+ # Returns true if this song is the current song and playback is paused.
617
+ #
618
+ # @return [true, false] whether the song is paused.
619
+ def paused?; end
620
+
621
+ ##
622
+ # Stops playback if this song is the current song. The current song is set to `nil`.
623
+ #
624
+ # @return [void]
625
+ def stop; end
626
+
627
+ ##
628
+ # @return [true, false] whether the song is playing.
629
+ def playing?; end
630
+ end
631
+
632
+ ##
633
+ # A TextInput is an invisible object that handles input using the operating system's input manager.
634
+ #
635
+ # 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
+ #
637
+ # 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
+ #
639
+ # @see Gosu::Window#text_input
640
+ # @see file:examples/TextInput.rb
641
+ class TextInput
642
+ ##
643
+ # @return [String] the text that the user has typed.
644
+ attr_accessor :text
645
+
646
+ ##
647
+ # @return [Fixnum] the position of the editing caret.
648
+ attr_accessor :caret_pos
649
+
650
+ ##
651
+ # @return [Fixnum] the starting position of the currently selected text.
652
+ attr_accessor :selection_start
653
+
654
+ ##
655
+ # 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
+ #
657
+ # The return value of this method will be inserted at the current caret position.
658
+ #
659
+ # The default implementation returns its argument unchanged.
660
+ #
661
+ # @return [String] the string to be inserted.
662
+ # @param text_in [String] the text typed by the user.
663
+ #
664
+ # @example Forcing input to all uppercase, alphanumeric characters.
665
+ # input = TextInput.new
666
+ # def input.filter(text_in)
667
+ # text_in.upcase.gsub(/[^A-Z0-9]/, '')
668
+ # end
669
+ def filter text_in
670
+ text_in
671
+ end
672
+ end
673
+
674
+ ##
675
+ # Main class that serves as the foundation of a standard
676
+ # Gosu application. Manages initialization of all of Gosu's core components
677
+ # and provides timing functionality.
678
+ #
679
+ # Note that all coordinates, even the mouse position, are in client
680
+ # coordinates relative to the window. This means that the mouse position
681
+ # can be negative or larger than the window size.
682
+ #
683
+ # @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.
684
+ class Window
685
+ ##
686
+ # @return [String] the window's caption, usually dispalyed in the title bar.
687
+ attr_accessor :caption
688
+
689
+ ##
690
+ # @return [Fixnum] the mouse pointer's window-based X coordinate.
691
+ attr_accessor :mouse_x
692
+
693
+ ##
694
+ # @return [Fixnum] the mouse pointer's window-based Y coordinate.
695
+ attr_accessor :mouse_y
696
+
697
+ ##
698
+ # The currently active {TextInput}. If not nil, all keyboard input will be handled by this object.
699
+ #
700
+ # @return [TextInput?] the currently active text input.
701
+ attr_accessor :text_input
702
+
703
+ ##
704
+ # 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.
705
+ #
706
+ # @return [Fixnum] the window's width, in pixels.
707
+ attr_reader :width
708
+
709
+ ##
710
+ # 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.
711
+ #
712
+ # @return [Fixnum] the window's height, in pixels.
713
+ attr_reader :height
714
+
715
+ ##
716
+ # @return [true, false] whether this is a full-screen window.
717
+ attr_reader :fullscreen?
718
+
719
+ ##
720
+ # @return [Float] the interval between calls to {#update}, in milliseconds.
721
+ attr_reader :update_interval
722
+
723
+ ##
724
+ # Creates a new window with the requested size.
725
+ #
726
+ # @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.
727
+ #
728
+ # @overload initialize(width, height, options = {})
729
+ # @overload initialize(width, height, fullscreen, update_interval = 16.666666)
730
+ #
731
+ # @param width [Fixnum] the desired window width.
732
+ # @param height [Fixnum] the desired window height.
733
+ # @param [Hash] options
734
+ # @option options [true, false] :fullscreen (false) whether to present the window in fullscreen mode.
735
+ # @option options [Float] :update_interval (16.666666) the interval between frames, in milliseconds.
736
+ def initialize(width, height, options); end
737
+
738
+ ##
739
+ # Enters a modal loop where the Window is visible on screen and receives calls to draw, update etc.
740
+ #
741
+ # @return [void]
742
+ def show; end
743
+
744
+ ##
745
+ # Tells the window to end the current run loop as soon as possible. Calling this method will not prevent execution of lines after it.
746
+ #
747
+ # @return [void]
748
+ def close; end
749
+
750
+ # @!group Callbacks
751
+
752
+ ##
753
+ # This method is called once every {#update_interval} milliseconds while the window is being shown. Your application's main logic should go here.
754
+ #
755
+ # @return [void]
756
+ def update; end
757
+
758
+ ##
759
+ # 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.
760
+ #
761
+ # @return [void]
762
+ #
763
+ # @see #needs_redraw?
764
+ def draw; end
765
+
766
+ ##
767
+ # 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.
768
+ #
769
+ # @return [true, false] whether the window needs to be redrawn.
770
+ #
771
+ # @see #draw
772
+ def needs_redraw?; end
773
+
774
+ ##
775
+ # 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.
776
+ #
777
+ # @return [true, false] whether the system cursor should be shown.
778
+ def needs_cursor?; end
779
+
780
+ ##
781
+ # This method is called before {#update} if a button was pressed while the window had focus.
782
+ #
783
+ # @return [void]
784
+ # @param id [Fixnum] the button's platform-defined id.
785
+ #
786
+ # @see #button_up
787
+ # @see Gosu.button_down?
788
+ def button_down(id); end
789
+
790
+ ##
791
+ # This method is called before {#update} if a button was released while the window had focus.
792
+ #
793
+ # @return [void]
794
+ # @param (see #button_down)
795
+ #
796
+ # @see #button_down
797
+ # @see Gosu.button_down?
798
+ def button_up(id); end
799
+
800
+ # @!endgroup
801
+
802
+ ##
803
+ # @deprecated Use {#mouse_x=} and {#mouse_y=} instead.
804
+ def set_mouse_position(x, y); end
805
+ end
806
+
807
+ ##
808
+ # Holds information about the underlying OpenGL texture and UV coordinates of an image.
809
+ #
810
+ # Can be retrieved from some images to use them in OpenGL operations.
811
+ #
812
+ # @see Gosu::Image#gl_tex_info
813
+ # @see file:examples/OpenGLIntegration.rb
814
+ class GLTexInfo
815
+ ##
816
+ # @return [Fixnum] OpenGL texture id
817
+ attr_reader :tex_name
818
+
819
+ ##
820
+ # @return [Float] the U coordinate of the left edge of the image.
821
+ attr_reader :left
822
+
823
+ ##
824
+ # @return [Float] the U coordinate of the right edge of the image.
825
+ attr_reader :right
826
+
827
+ ##
828
+ # @return [Float] the V coordinate of the top edge of the image.
829
+ attr_reader :top
830
+
831
+ ##
832
+ # @return [Float] the V coordinate of the bottom edge of the image.
833
+ attr_reader :bottom
834
+ end
835
+
836
+ class << self
837
+ ##
838
+ # 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.
839
+ #
840
+ # @return [true, false] whether the button is currently pressed.
841
+ # @param (see #button_down)
842
+ #
843
+ # @see Window#button_down
844
+ # @see Window#button_up
845
+ def button_down?(id); end
846
+
847
+ # @!group Drawing primitives
848
+
849
+ ##
850
+ # Draws a line from one point to another---inconsistently.
851
+ #
852
+ # @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.
853
+ #
854
+ # @return [void]
855
+ # @param x1 [Float] the X coordinate of the start point.
856
+ # @param y1 [Float] the Y coordinate of the start point.
857
+ # @param c1 [Gosu::Color] the color of the start point.
858
+ # @param x2 [Float] the X coordinate of the end point.
859
+ # @param y2 [Float] the Y coordinate of the end point.
860
+ # @param c2 [Gosu::Color] the color of the end point.
861
+ # @param z [Float] the Z-order.
862
+ # @param mode [:default, :additive] the blending mode to use.
863
+ #
864
+ # @see draw_triangle
865
+ # @see draw_quad
866
+ # @see https://github.com/jlnr/gosu/wiki/Basic-Concepts#drawing-with-colours Drawing with colors, explained in the Gosu Wiki
867
+ # @see https://github.com/jlnr/gosu/wiki/Basic-Concepts#z-ordering Z-ordering explained in the Gosu Wiki
868
+ def draw_line(x1, y1, c1, x2, y2, c2, z=0, mode=:default); end
869
+
870
+ ##
871
+ # Draws a triangle.
872
+ #
873
+ # @return [void]
874
+ # @param x1 [Float] the X coordinate of the first vertex.
875
+ # @param y1 [Float] the Y coordinate of the first vertex.
876
+ # @param c1 [Gosu::Color] the color of the first vertex.
877
+ # @param x2 [Float] the X coordinate of the second vertex.
878
+ # @param y2 [Float] the Y coordinate of the second vertex.
879
+ # @param c2 [Gosu::Color] the color of the second vertex.
880
+ # @param x3 [Float] the X coordinate of the third vertex.
881
+ # @param y3 [Float] the Y coordinate of the third vertex.
882
+ # @param c3 [Gosu::Color] the color of the third vertex.
883
+ # @param z [Float] the Z-order.
884
+ # @param mode [:default, :additive] the blending mode to use.
885
+ #
886
+ # @see draw_line
887
+ # @see draw_quad
888
+ # @see https://github.com/jlnr/gosu/wiki/Basic-Concepts#drawing-with-colours Drawing with colors, explained in the Gosu Wiki
889
+ # @see https://github.com/jlnr/gosu/wiki/Basic-Concepts#z-ordering Z-ordering explained in the Gosu Wiki
890
+ def draw_triangle(x1, y1, c1, x2, y2, c2, x3, y3, c3, z=0, mode=:default); end
891
+
892
+ ##
893
+ # Draws a quad (actually two triangles).
894
+ #
895
+ # @return [void]
896
+ # @param x1 [Float] the X coordinate of the first vertex.
897
+ # @param y1 [Float] the Y coordinate of the first vertex.
898
+ # @param c1 [Gosu::Color] the color of the first vertex.
899
+ # @param x2 [Float] the X coordinate of the second vertex.
900
+ # @param y2 [Float] the Y coordinate of the second vertex.
901
+ # @param c2 [Gosu::Color] the color of the second vertex.
902
+ # @param x3 [Float] the X coordinate of the third vertex.
903
+ # @param y3 [Float] the Y coordinate of the third vertex.
904
+ # @param c3 [Gosu::Color] the color of the third vertex.
905
+ # @param x4 [Float] the X coordinate of the fourth vertex.
906
+ # @param y4 [Float] the Y coordinate of the fourth vertex.
907
+ # @param c4 [Gosu::Color] the color of the fourth vertex.
908
+ # @param z [Float] the Z-order.
909
+ # @param mode [:default, :additive] the blending mode to use.
910
+ #
911
+ # @see draw_line
912
+ # @see draw_triangle
913
+ # @see https://github.com/jlnr/gosu/wiki/Basic-Concepts#drawing-with-colours Drawing with colors, explained in the Gosu Wiki
914
+ # @see https://github.com/jlnr/gosu/wiki/Basic-Concepts#order-of-corners The order of corners explained in the Gosu Wiki
915
+ # @see https://github.com/jlnr/gosu/wiki/Basic-Concepts#z-ordering Z-ordering explained in the Gosu Wiki
916
+ def draw_quad(x1, y1, c1, x2, y2, c2, x3, y3, c3, x4, y4, c4, z=0, mode=:default); end
917
+
918
+ # @!endgroup
919
+ # @!group Manipulating the current drawing context
920
+
921
+ ##
922
+ # 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.
923
+ #
924
+ # @return [void]
925
+ def flush; end
926
+
927
+ ##
928
+ # Runs the block in a clean OpenGL environment.
929
+ #
930
+ # 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.
931
+ #
932
+ # @note Gosu does not provide access to the underlying OpenGL APIs. A gem like ruby-opengl is required to use custom OpenGL drawing code.
933
+ #
934
+ # @note Gosu rendering functions MUST NOT be used within the block, and {gl} MUST be used only within the call tree of {Window#draw}.
935
+ #
936
+ # @return [void]
937
+ # @param z [Float] the Z-order.
938
+ # @yield OpenGL code.
939
+ #
940
+ # @see Window#draw
941
+ # @see file:reference/Z-Ordering
942
+ # @see file:examples/OpenGLIntegration.rb
943
+ def gl(z=nil); end
944
+
945
+ ##
946
+ # Masks the drawing area inside the block.
947
+ #
948
+ # @return [void]
949
+ # @param x [Float] the X coordinate of the top left corner,.
950
+ # @param y [Float] the Y coordinate of the top left corner.
951
+ # @param w [Float] the width of the clipping area.
952
+ # @param h [Float] the height of the clipping area.
953
+ # @yield rendering code.
954
+ #
955
+ # @see Window#draw
956
+ def clip_to(x, y, w, h); end
957
+
958
+ ##
959
+ # 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.
960
+ #
961
+ # @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.
962
+ #
963
+ # @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.
964
+ #
965
+ # @return [Gosu::Image] the recorded drawing operations.
966
+ # @param width [Float] the width of the recorded image.
967
+ # @param height [Float] the height of the recorded image.
968
+ # @yield rendering code.
969
+ #
970
+ # @see Window#draw
971
+ # @see Gosu::Image
972
+ def record(width, height); end
973
+
974
+ ##
975
+ # Rotates all drawing operatons inside the block.
976
+ #
977
+ # @return [void]
978
+ # @param angle [Float] the rotation angle.
979
+ # @param around_x [Float] the X coorinate of the rotation origin.
980
+ # @param around_y [Float] the Y coordinate of the rotation origin.
981
+ # @yield rendering code.
982
+ #
983
+ # @see Window#draw
984
+ # @see scale
985
+ # @see translate
986
+ # @see transform
987
+ def rotate(angle, around_x=0, around_y=0); end
988
+
989
+ ##
990
+ # Scales all drawing operations inside the block.
991
+ #
992
+ # @overload scale(scale_x, scale_y = scale_x) { ... }
993
+ # @overload scale(scale_x, scale_y, around_x, around_y) { ... }
994
+ #
995
+ # @return [void]
996
+ # @param scale_x [Float] the horizontal scaling factor.
997
+ # @param scale_y [Float] the vertical scaling factor.
998
+ # @param around_x [Float] the X coordinate of the scaling origin.
999
+ # @param around_y [Float] the Y coordinate of the scaling origin.
1000
+ # @yield rendering code.
1001
+ #
1002
+ # @see Window#draw
1003
+ # @see rotate
1004
+ # @see translate
1005
+ # @see transform
1006
+ def scale(scale_x, scale_y, around_x, around_y); end
1007
+
1008
+ ##
1009
+ # Offsets all drawing operations inside the block.
1010
+ #
1011
+ # @return [void]
1012
+ # @param x [Float] the X offset.
1013
+ # @param y [Float] the Y offset.
1014
+ # @yield rendering code.
1015
+ #
1016
+ # @see Window#draw
1017
+ # @see rotate
1018
+ # @see scale
1019
+ # @see transform
1020
+ def translate(x, y); end
1021
+
1022
+ ##
1023
+ # Applies a free-form matrix transformation to everything drawn in the block.
1024
+ #
1025
+ # @return [void]
1026
+ # @param m0 [Float]
1027
+ # @param m1 [Float]
1028
+ # @param m2 [Float]
1029
+ # @param m3 [Float]
1030
+ # @param m4 [Float]
1031
+ # @param m5 [Float]
1032
+ # @param m6 [Float]
1033
+ # @param m7 [Float]
1034
+ # @param m8 [Float]
1035
+ # @param m9 [Float]
1036
+ # @param m10 [Float]
1037
+ # @param m11 [Float]
1038
+ # @param m12 [Float]
1039
+ # @param m13 [Float]
1040
+ # @param m14 [Float]
1041
+ # @param m15 [Float]
1042
+ # @yield rendering code.
1043
+ #
1044
+ # @see Window#draw
1045
+ # @see rotate
1046
+ # @see scale
1047
+ # @see translate
1048
+ def transform(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15); end
1049
+
1050
+ # @!endgroup
1051
+
1052
+ ##
1053
+ # Returns the character a button usually produces, if any.
1054
+ #
1055
+ # @note For real text input, look at {TextInput} instead.
1056
+ #
1057
+ # @return [String?] the character the button usually produces.
1058
+ # @param id [Fixnum] the button's platform-defined id.
1059
+ #
1060
+ # @see char_to_button_id
1061
+ # @see Window#text_input
1062
+ # @see TextInput
1063
+ def self.button_id_to_char(id); end
1064
+
1065
+ ##
1066
+ # Returns the button that usually produces a character, if any.
1067
+ #
1068
+ # @return [Fixnum?] the button that usually produces the character.
1069
+ # @param char [String] the character to query.
1070
+ #
1071
+ # @see button_id_to_char
1072
+ # @see Window#text_input
1073
+ # @see TextInput
1074
+ def self.char_to_button_id(char); end
1075
+
1076
+ ##
1077
+ # @return [Float] a random number in the range (min...max).
1078
+ # @param min [Float] the minimum value, inclusive.
1079
+ # @param max [Float] the maximum value, exclusive.
1080
+ def random(min, max); end
1081
+
1082
+ ##
1083
+ # @return [Float] the X component of a vector of angle theta and magnitude r, or the horizontal distance covered by moving r pixels in the direction given by theta.
1084
+ # @param theta [Float]
1085
+ # @param r [Float]
1086
+ def offset_x(theta, r); end
1087
+
1088
+ ##
1089
+ # @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.
1090
+ # @param theta [Float]
1091
+ # @param r [Float]
1092
+ def offset_y(theta, r); end
1093
+
1094
+ ##
1095
+ # @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.
1096
+ # @param x1 [Float]
1097
+ # @param y1 [Float]
1098
+ # @param x2 [Float]
1099
+ # @param y2 [Float]
1100
+ def angle(x1, y1, x2, y2); end
1101
+
1102
+ ##
1103
+ # @return [Float] the shortest angular distance from angle1 to angle2. This can be negative if counter-clockwise rotation would yield a shorter distance.
1104
+ # @param angle1 [Float]
1105
+ # @param angle2 [Float]
1106
+ def angle_diff(angle1, angle2); end
1107
+
1108
+ ##
1109
+ # @return [Float] the distance from (x1, y1) to (x2, y2).
1110
+ # @param x1 [Float]
1111
+ # @param y1 [Float]
1112
+ # @param x2 [Float]
1113
+ # @param y2 [Float]
1114
+ def distance(x1, y1, x2, y2); end
1115
+
1116
+ ##
1117
+ # @note For long-running games, this counter will eventually wrap around to 0 again.
1118
+ #
1119
+ # @return [Fixnum] the number of milliseconds elapsed.
1120
+ def milliseconds(); end
1121
+
1122
+ ##
1123
+ # @return [Fixnum] the current framerate, in frames per second.
1124
+ def fps(); end
1125
+
1126
+ # @return [String] the name of a neutral font that is available on the current platform.
1127
+ #
1128
+ # @see Gosu::Font
1129
+ # @see Gosu::Image#from_text
1130
+ def default_font_name(); end
1131
+
1132
+ ##
1133
+ # @return [Fixnum] the width (in pixels) of the user's primary screen.
1134
+ def screen_width(); end
1135
+
1136
+ # @return [Fixnum] the height (in pixels) of the user's primary screen.
1137
+ def screen_height(); end
1138
+
1139
+ ##
1140
+ # @return [Fixnum] the maximum width (in 'points') that is available for a non-fullscreen Window.
1141
+ # All windows larger than this size will automatically be shrunk to fit.
1142
+ def available_width(); end
1143
+
1144
+ # @return [Fixnum] the maximum height (in 'points') that is available for a non-fullscreen Window.
1145
+ # All windows larger than this size will automatically be shrunk to fit.
1146
+ def available_height(); end
1147
+
1148
+ ##
1149
+ # Returns the language code for the user's preferred language.
1150
+ # Expect return values such as 'en_US', 'de_DE.UTF-8', 'ja', 'zh-Hans', etc.
1151
+ # You can rely only the first two letters being a language abbreviation.
1152
+ #
1153
+ # @return [String] the user's preferred language.
1154
+ def language(); end
1155
+ end
1156
+ end
1157
+
1158
+ ##
1159
+ # Small additions to Numeric to make it easier to integrate Gosu with
1160
+ # libraries that use radians, like Chipmunk.
1161
+ class ::Numeric
1162
+ ##
1163
+ # Converts radians to a Gosu-compatible angle using the formula <tt>self * 180.0 / Math::PI + 90</tt>.
1164
+ #
1165
+ # @return [Float] degrees.
1166
+ def radians_to_gosu(); end
1167
+
1168
+ ##
1169
+ # Converts a Gosu-compatible angle to radians using the formula <tt>(self - 90) * Math::PI / 180.0</tt>.
1170
+ #
1171
+ # @return [Float] radians.
1172
+ def gosu_to_radians(); end
1173
+
1174
+ ##
1175
+ # Converts degrees to radians.
1176
+ #
1177
+ # @return [Float] radians.
1178
+ def degrees_to_radians(); end
1179
+
1180
+ ##
1181
+ # Converts radians to degrees.
1182
+ #
1183
+ # @return [Float] degrees.
1184
+ def radians_to_degrees(); end
1185
+ end