rubygame 2.2.0-mswin32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. data/CREDITS +60 -0
  2. data/LICENSE +504 -0
  3. data/NEWS +201 -0
  4. data/README +139 -0
  5. data/ROADMAP +43 -0
  6. data/Rakefile +409 -0
  7. data/doc/extended_readme.rdoc +49 -0
  8. data/doc/getting_started.rdoc +47 -0
  9. data/doc/macosx_install.rdoc +70 -0
  10. data/doc/windows_install.rdoc +127 -0
  11. data/ext/rubygame/MANIFEST +25 -0
  12. data/ext/rubygame/rubygame_core.so +0 -0
  13. data/ext/rubygame/rubygame_event.c +644 -0
  14. data/ext/rubygame/rubygame_event.h +48 -0
  15. data/ext/rubygame/rubygame_event.obj +0 -0
  16. data/ext/rubygame/rubygame_gfx.c +942 -0
  17. data/ext/rubygame/rubygame_gfx.h +101 -0
  18. data/ext/rubygame/rubygame_gfx.obj +0 -0
  19. data/ext/rubygame/rubygame_gfx.so +0 -0
  20. data/ext/rubygame/rubygame_gl.c +154 -0
  21. data/ext/rubygame/rubygame_gl.h +32 -0
  22. data/ext/rubygame/rubygame_gl.obj +0 -0
  23. data/ext/rubygame/rubygame_image.c +108 -0
  24. data/ext/rubygame/rubygame_image.h +41 -0
  25. data/ext/rubygame/rubygame_image.obj +0 -0
  26. data/ext/rubygame/rubygame_image.so +0 -0
  27. data/ext/rubygame/rubygame_joystick.c +247 -0
  28. data/ext/rubygame/rubygame_joystick.h +41 -0
  29. data/ext/rubygame/rubygame_joystick.obj +0 -0
  30. data/ext/rubygame/rubygame_main.c +155 -0
  31. data/ext/rubygame/rubygame_main.h +33 -0
  32. data/ext/rubygame/rubygame_main.obj +0 -0
  33. data/ext/rubygame/rubygame_mixer.c +764 -0
  34. data/ext/rubygame/rubygame_mixer.h +62 -0
  35. data/ext/rubygame/rubygame_mixer.obj +0 -0
  36. data/ext/rubygame/rubygame_mixer.so +0 -0
  37. data/ext/rubygame/rubygame_screen.c +448 -0
  38. data/ext/rubygame/rubygame_screen.h +43 -0
  39. data/ext/rubygame/rubygame_screen.obj +0 -0
  40. data/ext/rubygame/rubygame_shared.c +209 -0
  41. data/ext/rubygame/rubygame_shared.h +60 -0
  42. data/ext/rubygame/rubygame_shared.obj +0 -0
  43. data/ext/rubygame/rubygame_surface.c +1147 -0
  44. data/ext/rubygame/rubygame_surface.h +62 -0
  45. data/ext/rubygame/rubygame_surface.obj +0 -0
  46. data/ext/rubygame/rubygame_time.c +183 -0
  47. data/ext/rubygame/rubygame_time.h +32 -0
  48. data/ext/rubygame/rubygame_time.obj +0 -0
  49. data/ext/rubygame/rubygame_ttf.c +599 -0
  50. data/ext/rubygame/rubygame_ttf.h +69 -0
  51. data/ext/rubygame/rubygame_ttf.obj +0 -0
  52. data/ext/rubygame/rubygame_ttf.so +0 -0
  53. data/lib/rubygame.rb +41 -0
  54. data/lib/rubygame/MANIFEST +12 -0
  55. data/lib/rubygame/clock.rb +128 -0
  56. data/lib/rubygame/color.rb +79 -0
  57. data/lib/rubygame/color/models/base.rb +106 -0
  58. data/lib/rubygame/color/models/hsl.rb +153 -0
  59. data/lib/rubygame/color/models/hsv.rb +149 -0
  60. data/lib/rubygame/color/models/rgb.rb +78 -0
  61. data/lib/rubygame/color/palettes/css.rb +49 -0
  62. data/lib/rubygame/color/palettes/palette.rb +100 -0
  63. data/lib/rubygame/color/palettes/x11.rb +177 -0
  64. data/lib/rubygame/constants.rb +238 -0
  65. data/lib/rubygame/event.rb +313 -0
  66. data/lib/rubygame/ftor.rb +370 -0
  67. data/lib/rubygame/hotspot.rb +265 -0
  68. data/lib/rubygame/keyconstants.rb +237 -0
  69. data/lib/rubygame/mediabag.rb +94 -0
  70. data/lib/rubygame/queue.rb +288 -0
  71. data/lib/rubygame/rect.rb +612 -0
  72. data/lib/rubygame/sfont.rb +223 -0
  73. data/lib/rubygame/sprite.rb +511 -0
  74. data/samples/FreeSans.ttf +0 -0
  75. data/samples/GPL.txt +340 -0
  76. data/samples/README +40 -0
  77. data/samples/chimp.bmp +0 -0
  78. data/samples/chimp.rb +313 -0
  79. data/samples/demo_gl.rb +151 -0
  80. data/samples/demo_gl_tex.rb +197 -0
  81. data/samples/demo_music.rb +75 -0
  82. data/samples/demo_rubygame.rb +284 -0
  83. data/samples/demo_sfont.rb +52 -0
  84. data/samples/demo_ttf.rb +193 -0
  85. data/samples/demo_utf8.rb +53 -0
  86. data/samples/fist.bmp +0 -0
  87. data/samples/load_and_blit.rb +22 -0
  88. data/samples/panda.png +0 -0
  89. data/samples/punch.wav +0 -0
  90. data/samples/ruby.png +0 -0
  91. data/samples/song.ogg +0 -0
  92. data/samples/term16.png +0 -0
  93. data/samples/whiff.wav +0 -0
  94. metadata +152 -0
@@ -0,0 +1,69 @@
1
+ /*
2
+ * Rubygame -- Ruby code and bindings to SDL to facilitate game creation
3
+ * Copyright (C) 2004-2007 John Croisant
4
+ *
5
+ * This library is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
9
+ *
10
+ * This library is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ * Lesser General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Lesser General Public
16
+ * License along with this library; if not, write to the Free Software
17
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
+ *
19
+ */
20
+
21
+ #ifndef _RUBYGAME_TTF_H
22
+ #define _RUBYGAME_TTF_H
23
+
24
+ #include "SDL_ttf.h"
25
+
26
+ #ifndef SDL_TTF_MAJOR_VERSION
27
+ #define SDL_TTF_MAJOR_VERSION 0
28
+ #endif
29
+
30
+ #ifndef SDL_TTF_MINOR_VERSION
31
+ #define SDL_TTF_MINOR_VERSION 0
32
+ #endif
33
+
34
+ #ifndef SDL_TTF_PATCHLEVEL
35
+ #define SDL_TTF_PATCHLEVEL 0
36
+ #endif
37
+
38
+ extern void Init_rubygame_ttf();
39
+
40
+ extern VALUE cTTF;
41
+
42
+ extern VALUE rbgm_ttf_setup(VALUE);
43
+ extern VALUE rbgm_ttf_quit(VALUE);
44
+ extern VALUE rbgm_ttf_new(VALUE, VALUE, VALUE);
45
+ extern VALUE rbgm_ttf_initialize(int, VALUE*, VALUE);
46
+
47
+ extern VALUE rbgm_ttf_getbold(VALUE);
48
+ extern VALUE rbgm_ttf_setbold(VALUE, VALUE);
49
+
50
+ extern VALUE rbgm_ttf_getitalic(VALUE);
51
+ extern VALUE rbgm_ttf_setitalic(VALUE, VALUE);
52
+
53
+ extern VALUE rbgm_ttf_getunderline(VALUE);
54
+ extern VALUE rbgm_ttf_setunderline(VALUE, VALUE);
55
+
56
+ extern VALUE rbgm_ttf_height(VALUE);
57
+ extern VALUE rbgm_ttf_ascent(VALUE);
58
+ extern VALUE rbgm_ttf_descent(VALUE);
59
+ extern VALUE rbgm_ttf_lineskip(VALUE);
60
+
61
+ extern VALUE rbgm_ttf_sizetext(VALUE, VALUE);
62
+ extern VALUE rbgm_ttf_size_utf8(VALUE, VALUE);
63
+ extern VALUE rbgm_ttf_size_unicode(VALUE, VALUE);
64
+
65
+ extern VALUE rbgm_ttf_render(int, VALUE*, VALUE);
66
+ extern VALUE rbgm_ttf_render_utf8(int , VALUE*, VALUE);
67
+ extern VALUE rbgm_ttf_render_unicode(int , VALUE*, VALUE);
68
+
69
+ #endif
Binary file
Binary file
data/lib/rubygame.rb ADDED
@@ -0,0 +1,41 @@
1
+ #--
2
+ # Rubygame -- Ruby code and bindings to SDL to facilitate game creation
3
+ # Copyright (C) 2004-2007 John Croisant
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
+ #++
19
+
20
+ # This is the file that should be imported, it in turn imports rubygame.so
21
+ # (which has all of the C code for rubygame) and all the other rubygame modules
22
+
23
+ require "rbconfig"
24
+
25
+ require "rubygame_core"
26
+
27
+ %W{ rubygame_gfx rubygame_image rubygame_ttf rubygame_mixer }.each do |mod|
28
+ begin
29
+ require mod
30
+ rescue LoadError
31
+ warn( "Warning: Unable to require optional module: #{mod}.") if $VERBOSE
32
+ end
33
+ end
34
+
35
+ require "rubygame/color"
36
+ require "rubygame/constants"
37
+ require "rubygame/event"
38
+ require "rubygame/queue"
39
+ require "rubygame/rect"
40
+ require "rubygame/sprite"
41
+ require "rubygame/clock"
@@ -0,0 +1,12 @@
1
+ clock.rb
2
+ constants.rb
3
+ event.rb
4
+ ftor.rb
5
+ hotspot.rb
6
+ keyconstants.rb
7
+ MANIFEST
8
+ mediabag.rb
9
+ queue.rb
10
+ rect.rb
11
+ sfont.rb
12
+ sprite.rb
@@ -0,0 +1,128 @@
1
+ #--
2
+ # Rubygame -- Ruby code and bindings to SDL to facilitate game creation
3
+ # Copyright (C) 2004-2007 John Croisant
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
+ #++
19
+
20
+ module Rubygame
21
+ # Clock provides class methods for tracking running time and delaying
22
+ # execution of the program for specified time periods. This is used to
23
+ # provide a consistent framerate, prevent the program from using
24
+ # all the processor time, etc.
25
+ #
26
+ # Clock also provides instance methods to make it convenient to
27
+ # monitor and limit application framerate. See #tick.
28
+ class Clock
29
+ # The runtime when the Clock was initialized.
30
+ attr_reader :start
31
+ # The number of times #tick has been called.
32
+ attr_reader :ticks
33
+
34
+ # Create a new Clock instance.
35
+ def initialize()
36
+ @start = Clock.runtime()
37
+ @last_tick = @start
38
+ @ticks = 0
39
+ @target_frametime = nil
40
+ yield self if block_given?
41
+ end
42
+
43
+ # The target frametime (milliseconds/frame). See #tick
44
+ attr_accessor :target_frametime
45
+
46
+ # Returns the current target framerate (frames/second).
47
+ # This is an alternate way to access @target_frametime.
48
+ # Same as: 1000.0 / #target_frametime
49
+ def target_framerate
50
+ if @target_frametime
51
+ 1000.0 / @target_frametime
52
+ else
53
+ nil
54
+ end
55
+ rescue ZeroDivisionError
56
+ return nil
57
+ end
58
+
59
+ # Sets the target number of frames per second to +framerate+.
60
+ # This is an alternate way to access @target_frametime.
61
+ # Same as: #target_frametime = 1000.0 / framerate
62
+ def target_framerate=( framerate )
63
+ if framerate
64
+ @target_frametime = 1000.0 / framerate
65
+ else
66
+ @target_frametime = nil
67
+ end
68
+ rescue ZeroDivisionError
69
+ @target_frametime = nil
70
+ end
71
+
72
+ # call-seq: lifetime() -> Numeric
73
+ #
74
+ # Returns time in milliseconds since this Clock instance was created.
75
+ def lifetime
76
+ Clock.runtime() - @start
77
+ end
78
+
79
+ # call-seq: framerate() -> Numeric
80
+ #
81
+ # Return the actual framerate (frames per second) recorded by the Clock.
82
+ # See #tick.
83
+ #
84
+ # TODO: sample only a few seconds in the past, instead of the
85
+ # entire lifetime of the Clock.
86
+ def framerate
87
+ # below is same as: return @ticks / (lifetime / 1000.0)
88
+ return 1000.0 * @ticks / lifetime()
89
+ rescue ZeroDivisionError
90
+ return 0
91
+ end
92
+
93
+ # Returns the number of milliseconds since you last called this method.
94
+ #
95
+ # You must call this method once per frame (i.e. per iteration of
96
+ # your main loop) if you want to use the framerate monitoring and/or
97
+ # framerate limiting features.
98
+ #
99
+ # Framerate monitoring allows you to check the framerate (frames per
100
+ # second) with the #framerate method.
101
+ #
102
+ # Framerate limiting allows you to prevent the application from running
103
+ # too fast (and using 100% of processor time) by pausing the program
104
+ # very briefly each frame. The pause duration is calculated each frame
105
+ # to maintain a constant framerate.
106
+ #
107
+ # Framerate limiting is only enabled if you have set the
108
+ # #target_framerate= or #target_frametime=.
109
+ # If you have done that, this method will automatically perform the
110
+ # delay each time you call it.
111
+ #
112
+ # (Please note that no effort is made to correct a framerate
113
+ # which is *slower* than the target framerate. Clock can't
114
+ # make your code run faster, only slow it down if it is
115
+ # running too fast.)
116
+ def tick()
117
+ passed = Clock.runtime() - @last_tick # how long since the last tick?
118
+ if @target_frametime
119
+ return Clock.delay(@target_frametime - passed) + passed
120
+ end
121
+ return passed
122
+ ensure
123
+ @last_tick = Clock.runtime()
124
+ @ticks += 1
125
+ end
126
+
127
+ end # class Clock
128
+ end #module Rubygame
@@ -0,0 +1,79 @@
1
+ #--
2
+ # Rubygame -- Ruby code and bindings to SDL to facilitate game creation
3
+ # Copyright (C) 2007 John Croisant
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
+ #++
19
+
20
+ require 'rubygame/color/models/base'
21
+ require 'rubygame/color/models/rgb'
22
+ require 'rubygame/color/models/hsv'
23
+ require 'rubygame/color/models/hsl'
24
+
25
+ require 'rubygame/color/palettes/palette'
26
+ require 'rubygame/color/palettes/x11'
27
+ require 'rubygame/color/palettes/css'
28
+
29
+ module Rubygame
30
+
31
+ # The Color module contains classes related to colors.
32
+ #
33
+ # Available color representations:
34
+ #
35
+ # ColorRGB:: color class with red, green, and blue components.
36
+ # ColorHSV:: color class with hue, saturation, and value components.
37
+ # ColorHSL:: color class with hue, saturation, and luminosity components.
38
+ #
39
+ # The Palette class allows you to conveniently store and access a
40
+ # collection of many different colors, with inheritance from
41
+ # included Palettes.
42
+ #
43
+ # The available predefined palettes are:
44
+ #
45
+ # X11:: palette with the default X11 colors
46
+ # CSS:: palette used with HTML and CSS, very similar to X11
47
+ # GLOBAL:: special palette used for automatic lookup (see below)
48
+ #
49
+ # The GLOBAL palette is special; it is used for automatic color lookup
50
+ # in functions like Surface#draw_circle and TTF#render.It includes the
51
+ # CSS palette by default; you can include other palettes or define new
52
+ # custom colors in GLOBAL to make them available for automatic lookup.
53
+ #
54
+ # For convenience, you can access the GLOBAL palette through the
55
+ # #[] and #[]= methods:
56
+ #
57
+ # include Rubygame
58
+ # player_color = Color[:red]
59
+ # Color[:favorite] = Color[:azure]
60
+ #
61
+ module Color
62
+
63
+ (GLOBAL = Palette.new()).include(CSS) # :nodoc:
64
+
65
+ # Retrieve a color from the GLOBAL palette.
66
+ # See Palette#[]
67
+ def self.[]( name )
68
+ GLOBAL[name]
69
+ end
70
+
71
+ # Store a color in the GLOBAL palette.
72
+ # See Palette#[]=
73
+ def self.[]=( name, color )
74
+ GLOBAL[name] = color
75
+ end
76
+
77
+ end
78
+ end
79
+
@@ -0,0 +1,106 @@
1
+ #--
2
+ # Rubygame -- Ruby code and bindings to SDL to facilitate game creation
3
+ # Copyright (C) 2007 John Croisant
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
+ #++
19
+
20
+
21
+ # A mix-in module defining color arithmetic operations.
22
+ module ColorBase
23
+
24
+ # Perform color addition with another color of any type.
25
+ # The alpha of the new color will be equal to the alpha
26
+ # of the receiver.
27
+ def +(other)
28
+ wrap( simple_op(other) { |a,b| a + b } )
29
+ end
30
+
31
+ # Perform color subtraction with another color of any type.
32
+ # The alpha of the new color will be equal to the alpha
33
+ # of the receiver.
34
+ def -(other)
35
+ wrap( simple_op(other) { |a,b| a - b } )
36
+ end
37
+
38
+ # Perform color multiplication with another color of any type.
39
+ # The alpha of the new color will be equal to the alpha
40
+ # of the receiver.
41
+ def *(other)
42
+ wrap( simple_op(other) { |a,b| a * b } )
43
+ end
44
+
45
+ # Perform color division with another color of any type.
46
+ # The alpha of the new color will be equal to the alpha
47
+ # of the receiver.
48
+ def /(other)
49
+ wrap( simple_op(other) { |a,b| a / b } )
50
+ end
51
+
52
+ # Layer this color over another color.
53
+ def over(other)
54
+ c1, c2 = self.to_rgba_ary, other.to_rgba_ary
55
+ a1, a2 = c1[3], c2[3]
56
+
57
+ rgba = [0,1,2].collect do |i|
58
+ clamp( a1*c1.at(i) + a2*c2.at(i)*(1-a1) )
59
+ end
60
+
61
+ rgba << ( a1 + a2*(1-a1) )
62
+
63
+ wrap( rgba )
64
+ end
65
+
66
+ # Average this color with another color. (Linear weighted average)
67
+ #
68
+ # A weight of 0.0 means 0% of this color, 100% of the other.
69
+ # A weight of 1.0 means 100% of this color, 0% of the other.
70
+ # A weight of 0.5 means 50% of each color.
71
+ #
72
+ def average(other, weight=0.5)
73
+ c1, c2 = self.to_rgba_ary, other.to_rgba_ary
74
+
75
+ rgba = [0,1,2,3].collect do |i|
76
+ clamp( c1.at(i)*weight + c2.at(i)*(1-weight) )
77
+ end
78
+
79
+ wrap( rgba )
80
+ end
81
+
82
+ private
83
+
84
+ def wrap( rgba )
85
+ self.class.new_from_rgba( rgba )
86
+ end
87
+
88
+ def simple_op(other, &block)
89
+ c1, c2 = self.to_rgba_ary, other.to_rgba_ary
90
+ a1, a2 = c1[3], c2[3]
91
+
92
+ rgba = [0,1,2].collect do |i|
93
+ clamp( block.call( a1*c1.at(i), a2*c2.at(i) ) )
94
+ end
95
+
96
+ rgba << a1
97
+
98
+ return rgba
99
+ end
100
+
101
+ def clamp(v, min=0.0, max=1.0)
102
+ v = min if v < min
103
+ v = max if v > max
104
+ return v
105
+ end
106
+ end