gosu 0.7.39-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. data/COPYING +34 -0
  2. data/Gosu/Async.hpp +50 -0
  3. data/Gosu/Audio.hpp +163 -0
  4. data/Gosu/AutoLink.hpp +16 -0
  5. data/Gosu/Bitmap.hpp +96 -0
  6. data/Gosu/ButtonsMac.hpp +140 -0
  7. data/Gosu/ButtonsWin.hpp +140 -0
  8. data/Gosu/ButtonsX.hpp +141 -0
  9. data/Gosu/Color.hpp +204 -0
  10. data/Gosu/Directories.hpp +36 -0
  11. data/Gosu/Font.hpp +83 -0
  12. data/Gosu/Fwd.hpp +31 -0
  13. data/Gosu/Gosu.hpp +34 -0
  14. data/Gosu/Graphics.hpp +120 -0
  15. data/Gosu/GraphicsBase.hpp +66 -0
  16. data/Gosu/IO.hpp +259 -0
  17. data/Gosu/Image.hpp +138 -0
  18. data/Gosu/ImageData.hpp +58 -0
  19. data/Gosu/Input.hpp +161 -0
  20. data/Gosu/Inspection.hpp +14 -0
  21. data/Gosu/Math.hpp +135 -0
  22. data/Gosu/Platform.hpp +73 -0
  23. data/Gosu/Sockets.hpp +137 -0
  24. data/Gosu/TR1.hpp +44 -0
  25. data/Gosu/Text.hpp +71 -0
  26. data/Gosu/TextInput.hpp +70 -0
  27. data/Gosu/Timing.hpp +16 -0
  28. data/Gosu/Utility.hpp +28 -0
  29. data/Gosu/Version.hpp +526 -0
  30. data/Gosu/WinUtility.hpp +75 -0
  31. data/Gosu/Window.hpp +124 -0
  32. data/README.txt +25 -0
  33. data/examples/ChipmunkIntegration.rb +275 -0
  34. data/examples/CptnRuby.rb +223 -0
  35. data/examples/MoreChipmunkAndRMagick.rb +155 -0
  36. data/examples/OpenGLIntegration.rb +226 -0
  37. data/examples/RMagickIntegration.rb +417 -0
  38. data/examples/TextInput.rb +154 -0
  39. data/examples/Tutorial.rb +131 -0
  40. data/examples/media/Beep.wav +0 -0
  41. data/examples/media/CptnRuby Gem.png +0 -0
  42. data/examples/media/CptnRuby Map.txt +25 -0
  43. data/examples/media/CptnRuby Tileset.png +0 -0
  44. data/examples/media/CptnRuby.png +0 -0
  45. data/examples/media/Cursor.png +0 -0
  46. data/examples/media/Earth.png +0 -0
  47. data/examples/media/Explosion.wav +0 -0
  48. data/examples/media/Landscape.svg +10 -0
  49. data/examples/media/LargeStar.png +0 -0
  50. data/examples/media/Smoke.png +0 -0
  51. data/examples/media/Soldier.png +0 -0
  52. data/examples/media/Space.png +0 -0
  53. data/examples/media/Star.png +0 -0
  54. data/examples/media/Starfighter.bmp +0 -0
  55. data/lib/FreeImage.dll +0 -0
  56. data/lib/OpenAL32.dll +0 -0
  57. data/lib/gosu.for_1_8.so +0 -0
  58. data/lib/gosu.for_1_9.so +0 -0
  59. data/lib/gosu.rb +17 -0
  60. data/lib/gosu/patches.rb +75 -0
  61. data/lib/gosu/preview.rb +121 -0
  62. data/lib/gosu/run.rb +11 -0
  63. data/lib/gosu/swig_patches.rb +48 -0
  64. data/lib/gosu/zen.rb +28 -0
  65. data/lib/libsndfile.dll +0 -0
  66. metadata +138 -0
@@ -0,0 +1,131 @@
1
+ require 'rubygems'
2
+ require 'gosu'
3
+
4
+ module ZOrder
5
+ Background, Stars, Player, UI = *0..3
6
+ end
7
+
8
+ class Player
9
+ attr_reader :score
10
+
11
+ def initialize(window)
12
+ @image = Gosu::Image.new(window, "media/Starfighter.bmp", false)
13
+ @beep = Gosu::Sample.new(window, "media/Beep.wav")
14
+ @x = @y = @vel_x = @vel_y = @angle = 0.0
15
+ @score = 0
16
+ end
17
+
18
+ def warp(x, y)
19
+ @x, @y = x, y
20
+ end
21
+
22
+ def turn_left
23
+ @angle -= 4.5
24
+ end
25
+
26
+ def turn_right
27
+ @angle += 4.5
28
+ end
29
+
30
+ def accelerate
31
+ @vel_x += Gosu::offset_x(@angle, 0.5)
32
+ @vel_y += Gosu::offset_y(@angle, 0.5)
33
+ end
34
+
35
+ def move
36
+ @x += @vel_x
37
+ @y += @vel_y
38
+ @x %= 640
39
+ @y %= 480
40
+
41
+ @vel_x *= 0.95
42
+ @vel_y *= 0.95
43
+ end
44
+
45
+ def draw
46
+ @image.draw_rot(@x, @y, ZOrder::Player, @angle)
47
+ end
48
+
49
+ def collect_stars(stars)
50
+ stars.reject! do |star|
51
+ if Gosu::distance(@x, @y, star.x, star.y) < 35 then
52
+ @score += 10
53
+ @beep.play
54
+ true
55
+ else
56
+ false
57
+ end
58
+ end
59
+ end
60
+ end
61
+
62
+ class Star
63
+ attr_reader :x, :y
64
+
65
+ def initialize(animation)
66
+ @animation = animation
67
+ @color = Gosu::Color.new(0xff000000)
68
+ @color.red = rand(256 - 40) + 40
69
+ @color.green = rand(256 - 40) + 40
70
+ @color.blue = rand(256 - 40) + 40
71
+ @x = rand * 640
72
+ @y = rand * 480
73
+ end
74
+
75
+ def draw
76
+ img = @animation[Gosu::milliseconds / 100 % @animation.size]
77
+ img.draw(@x - img.width / 2.0, @y - img.height / 2.0,
78
+ ZOrder::Stars, 1, 1, @color, :add)
79
+ end
80
+ end
81
+
82
+ class GameWindow < Gosu::Window
83
+ def initialize
84
+ super(640, 480, false)
85
+ self.caption = "Gosu Tutorial Game"
86
+
87
+ @background_image = Gosu::Image.new(self, "media/Space.png", true)
88
+
89
+ @player = Player.new(self)
90
+ @player.warp(320, 240)
91
+
92
+ @star_anim = Gosu::Image::load_tiles(self, "media/Star.png", 25, 25, false)
93
+ @stars = Array.new
94
+
95
+ @font = Gosu::Font.new(self, Gosu::default_font_name, 20)
96
+ end
97
+
98
+ def update
99
+ if button_down? Gosu::KbLeft or button_down? Gosu::GpLeft then
100
+ @player.turn_left
101
+ end
102
+ if button_down? Gosu::KbRight or button_down? Gosu::GpRight then
103
+ @player.turn_right
104
+ end
105
+ if button_down? Gosu::KbUp or button_down? Gosu::GpButton0 then
106
+ @player.accelerate
107
+ end
108
+ @player.move
109
+ @player.collect_stars(@stars)
110
+
111
+ if rand(100) < 4 and @stars.size < 25 then
112
+ @stars.push(Star.new(@star_anim))
113
+ end
114
+ end
115
+
116
+ def draw
117
+ @background_image.draw(0, 0, ZOrder::Background)
118
+ @player.draw
119
+ @stars.each { |star| star.draw }
120
+ @font.draw("Score: #{@player.score}", 10, 10, ZOrder::UI, 1.0, 1.0, 0xffffff00)
121
+ end
122
+
123
+ def button_down(id)
124
+ if id == Gosu::KbEscape then
125
+ close
126
+ end
127
+ end
128
+ end
129
+
130
+ window = GameWindow.new
131
+ window.show
Binary file
Binary file
@@ -0,0 +1,25 @@
1
+ #....................................................#
2
+ #....................................................#
3
+ #.............xx......x.x............................#
4
+ #............x..x....................................#
5
+ #x....x...x..x.......#####..xxx....................x.#
6
+ #.x.........................xxx.........##.........x.#
7
+ #...............""..........###...##..........##.....#
8
+ #..##..###..##..##...................................#
9
+ #........................................xx........###
10
+ #.............................###....................#
11
+ ##....##.............................................#
12
+ #....................##....##......##....##....##....#
13
+ #.................................................x..#
14
+ #...x....##....##.......x...x.....................x..#
15
+ #.....x...............x...x...x...................x..#
16
+ #......x...##.....##.................................#
17
+ #.......x.........................................#..#
18
+ #...........##........#...#...#..#.......x...........#
19
+ #...#................................................#
20
+ #....."""".................x.......#..#####...###....#
21
+ #x....#......................##......................#
22
+ #"""""#.....#.....x..................#...............#
23
+ ##xxxx......#........................................#
24
+ ##xxxx...#####............."...""""".................#
25
+ ######"""#############################################
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" clip-rule="evenodd" stroke-miterlimit="10" viewBox="0 0 850.39 637.80">
3
+ <desc>SVG generated by Lineform</desc>
4
+ <defs/>
5
+ <g>
6
+ <rect width="940.00" height="734.00" x="-25.50" y="-55.50" fill="#5FB7FF" stroke="#000000" stroke-width="2.20"/>
7
+ <path d="M 223.50 49.00 C 171.16 49.00 118.84 59.51 78.91 80.50 C -0.96 122.48 -0.96 190.52 78.91 232.50 C 134.24 261.59 213.37 270.50 283.34 259.28 C 350.32 290.78 452.18 289.47 516.06 255.19 C 582.65 219.45 582.65 161.55 516.06 125.81 C 482.95 108.04 439.59 99.12 396.19 99.03 C 388.26 92.46 378.99 86.23 368.09 80.50 C 328.16 59.51 275.84 49.00 223.50 49.00 Z M 223.50 49.00 " fill="#FFFFFF" stroke="#BFBFBF" stroke-width="6.00"/>
8
+ <path d="M 735.48 183.00 C 699.52 183.00 663.55 187.05 636.11 195.16 C 607.54 203.59 593.99 214.76 595.17 225.81 C 561.74 227.76 529.60 233.37 503.83 242.72 C 438.71 266.35 438.71 304.65 503.83 328.28 C 568.96 351.91 674.56 351.91 739.69 328.28 C 787.65 310.88 800.17 285.50 777.48 263.91 C 798.41 261.97 818.28 258.74 834.86 253.84 C 889.73 237.64 889.73 211.36 834.86 195.16 C 807.42 187.05 771.44 183.00 735.48 183.00 Z M 735.48 183.00 " fill="#FFFFFF" stroke="#BFBFBF" stroke-width="6.00"/>
9
+ </g>
10
+ </svg>
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
data/lib/FreeImage.dll ADDED
Binary file
data/lib/OpenAL32.dll ADDED
Binary file
Binary file
Binary file
data/lib/gosu.rb ADDED
@@ -0,0 +1,17 @@
1
+ require 'rbconfig'
2
+
3
+ if defined? RUBY_PLATFORM and
4
+ %w(-win32 win32- mswin mingw32).any? { |s| RUBY_PLATFORM.include? s } then
5
+ ENV['PATH'] = "#{File.dirname(__FILE__)};#{ENV['PATH']}"
6
+ end
7
+
8
+ if File.exist? "#{File.dirname(__FILE__)}/gosu.#{RbConfig::CONFIG['DLEXT']}"
9
+ 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
+ end
15
+
16
+ require "gosu/swig_patches"
17
+ require "gosu/patches"
@@ -0,0 +1,75 @@
1
+ # Extend Numeric with simple angle conversion methods.
2
+ class ::Numeric
3
+ def degrees_to_radians
4
+ self * Math::PI / 180.0
5
+ end
6
+ def radians_to_degrees
7
+ self * 180.0 / Math::PI
8
+ end
9
+ def gosu_to_radians
10
+ (self - 90) * Math::PI / 180.0
11
+ end
12
+ def radians_to_gosu
13
+ self * 180.0 / Math::PI + 90
14
+ end
15
+ end
16
+
17
+ # Backwards compatibility: import constants into Gosu::Button.
18
+ module Gosu::Button
19
+ Gosu.constants.each { |c| const_set(c, Gosu.const_get(c)) }
20
+ end
21
+
22
+ # Backwards compatibility: Window arguments to Sample and Song
23
+ class Gosu::Sample
24
+ alias initialize_ initialize
25
+
26
+ def initialize(*args)
27
+ args.shift if args.first.is_a? Gosu::Window
28
+ initialize_(*args)
29
+ end
30
+ end
31
+ class Gosu::Song
32
+ alias initialize_ initialize
33
+
34
+ def initialize(*args)
35
+ args.shift if args.first.is_a? Gosu::Window
36
+ initialize_(*args)
37
+ end
38
+ end
39
+
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
51
+ end
52
+
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)
64
+ end
65
+
66
+ # Instance methods for button_id_to_char and char_to_button_id
67
+ class Gosu::Window
68
+ def button_id_to_char(id)
69
+ self.class.button_id_to_char(id)
70
+ end
71
+
72
+ def char_to_button_id(ch)
73
+ self.class.char_to_button_id(ch)
74
+ end
75
+ end
@@ -0,0 +1,121 @@
1
+ require 'gosu'
2
+
3
+ # Wrapper around Gosu 0.7 that provides the work-in-progress 0.8 interface
4
+
5
+ module Gosu
6
+ class Font
7
+ alias :initialize07 :initialize
8
+
9
+ def initialize *args
10
+ if args.first.is_a? Gosu::Window then
11
+ initialize07 *args
12
+ else
13
+ height = args[0]
14
+ options = args[1] || {}
15
+ name = options[:name] || Gosu::default_font_name
16
+ initialize07 $window, name, height
17
+ end
18
+ end
19
+ end
20
+
21
+ class Window
22
+ alias :initialize07 :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 = initialize07 width, height, fullscreen, update_interval
33
+ end
34
+ end
35
+
36
+ class Image
37
+ alias :initialize07 :initialize
38
+
39
+ def initialize *args
40
+ if args.first.is_a? Gosu::Window then
41
+ initialize07 *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
+ initialize07 $window, source, !!tileable, *rect
48
+ else
49
+ initialize07 $window, source, !!tileable
50
+ end
51
+ end
52
+ end
53
+
54
+ class <<self
55
+ alias load_tiles07 load_tiles
56
+ end
57
+
58
+ def self.load_tiles *args
59
+ if args.first.is_a? Gosu::Window then
60
+ load_tiles07 *args
61
+ else
62
+ source = args[0]
63
+ x, y = args[1..2]
64
+ tileable = !args[3] || args[3][:tileable]
65
+ load_tiles07 $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.draw_quad *args
89
+ $window.draw_quad *args
90
+ end
91
+
92
+ def self.clip_to *args
93
+ $window.clip_to *args do
94
+ yield
95
+ end
96
+ end
97
+
98
+ def self.translate *args
99
+ $window.translate *args do
100
+ yield
101
+ end
102
+ end
103
+
104
+ def self.scale *args
105
+ $window.scale *args do
106
+ yield
107
+ end
108
+ end
109
+
110
+ def self.rotate *args
111
+ $window.rotate *args do
112
+ yield
113
+ end
114
+ end
115
+
116
+ def self.transform *args
117
+ $window.transform *args do
118
+ yield
119
+ end
120
+ end
121
+ end
data/lib/gosu/run.rb ADDED
@@ -0,0 +1,11 @@
1
+ # Replace the load path
2
+ $LOAD_PATH.clear
3
+ $LOAD_PATH << File.dirname(__FILE__)[0..-6]
4
+ $LOAD_PATH << $LOAD_PATH[0] + '/lib'
5
+ # Ruby portions of Gosu
6
+ require 'gosu/patches'
7
+ require 'gosu/swig_patches'
8
+ # Let the application know it is being run from the Mac app wrapper.
9
+ OSX_EXECUTABLE = true
10
+ # Main application
11
+ require 'Main'
@@ -0,0 +1,48 @@
1
+ # SWIG workarounds
2
+ # These are offloaded into a separate file because rb_eval_string() is weird on Ruby 1.8.
3
+
4
+ # Exceptions in Window callbacks often get lost, this is especially annoying in draw/update.
5
+ # It is not clear whether this is a SWIG issue or if some stack frame is not exception
6
+ # compatible, but I just call protected_update etc. in the Ruby wrapper so I can add this
7
+ # custom debugging help:
8
+ class Gosu::Window
9
+ %w(update draw needs_redraw? needs_cursor?
10
+ lose_focus button_down button_up).each do |callback|
11
+ define_method "protected_#{callback}" do |*args|
12
+ begin
13
+ # Turn into a boolean result for needs_cursor? etc while we are at it.
14
+ # If there has been an exception, don't do anything as to not make matters worse.
15
+ defined?(@_exception) ? false : !!send(callback, *args)
16
+ rescue Exception => e
17
+ # Exit the message loop naturally, then re-throw
18
+ @_exception = e
19
+ close
20
+ end
21
+ end
22
+ end
23
+
24
+ alias show_internal show
25
+ def show
26
+ show_internal
27
+ # Try to format the message nicely, without any useless patching that we are
28
+ # doing here.
29
+ if defined? @_exception then
30
+ if @_exception.backtrace.is_a? Array and not @_exception.backtrace.frozen? then
31
+ @_exception.backtrace.reject! { |line| line.include? 'lib/gosu/swig_patches.rb' }
32
+ end
33
+ raise @_exception
34
+ end
35
+ end
36
+ end
37
+
38
+ # SWIG doesn't understand the C++ overloading, so we need this simple check in Ruby.
39
+ class Gosu::Image
40
+ def self.from_text(*args)
41
+ args.size == 4 ? from_text4(*args) : from_text7(*args)
42
+ end
43
+ end
44
+
45
+ # SWIG won't let me rename my method to '[]='.
46
+ class Gosu::Font
47
+ alias []= set_image
48
+ end