rubygame 2.2.0-i586-linux

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 +123 -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.o +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.o +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.o +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.o +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.o +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.o +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.o +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.o +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.o +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.o +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.o +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.o +0 -0
  52. data/ext/rubygame/rubygame_ttf.so +0 -0
  53. data/lib/rubygame/MANIFEST +12 -0
  54. data/lib/rubygame/clock.rb +128 -0
  55. data/lib/rubygame/color/models/base.rb +106 -0
  56. data/lib/rubygame/color/models/hsl.rb +153 -0
  57. data/lib/rubygame/color/models/hsv.rb +149 -0
  58. data/lib/rubygame/color/models/rgb.rb +78 -0
  59. data/lib/rubygame/color/palettes/css.rb +49 -0
  60. data/lib/rubygame/color/palettes/palette.rb +100 -0
  61. data/lib/rubygame/color/palettes/x11.rb +177 -0
  62. data/lib/rubygame/color.rb +79 -0
  63. data/lib/rubygame/constants.rb +238 -0
  64. data/lib/rubygame/event.rb +313 -0
  65. data/lib/rubygame/ftor.rb +370 -0
  66. data/lib/rubygame/hotspot.rb +265 -0
  67. data/lib/rubygame/keyconstants.rb +237 -0
  68. data/lib/rubygame/mediabag.rb +94 -0
  69. data/lib/rubygame/queue.rb +288 -0
  70. data/lib/rubygame/rect.rb +612 -0
  71. data/lib/rubygame/sfont.rb +223 -0
  72. data/lib/rubygame/sprite.rb +511 -0
  73. data/lib/rubygame.rb +41 -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,100 @@
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
+ class Rubygame::Color::Palette
21
+
22
+ # Create a new Palette with the given name => color pairs.
23
+ def initialize( colors = {} )
24
+ @includes = []
25
+
26
+ @colors = {}
27
+ colors.each_pair do |name, color|
28
+ @colors[sanitize_name(name)] = color
29
+ end
30
+ end
31
+
32
+ # Retrieve a color by name from this palette.
33
+ #
34
+ # The name can be a Symbol or String. See #sanitize_name.
35
+ #
36
+ # If the color cannot be found in this palette, search
37
+ # each of the #included palettes (recursively, depth-first,
38
+ # to a maximum depth of 5 levels).
39
+ #
40
+ # If the color is not found in this palette or any included
41
+ # palettes, raise IndexError.
42
+ #
43
+ def []( name )
44
+ c = lookup( sanitize_name( name ) )
45
+ raise IndexError, "unknown color #{name}" unless c
46
+ return c
47
+ end
48
+
49
+ # Store a color by name in this palette. See #sanitize_name
50
+ def []=( name, color )
51
+ name = sanitize_name( name )
52
+ @colors[name] = color
53
+ end
54
+
55
+ # Include another palette in this one. If a color cannot be
56
+ # found in this palette, the included palette(s) will be searched.
57
+ # See also #uninclude.
58
+ #
59
+ # Has no effect if the palette is already included.
60
+ def include( palette )
61
+ @includes += [palette] unless @includes.include? palette
62
+ end
63
+
64
+ # Remove the other palette from this one, so that it won't be
65
+ # searched for missing colors anymore. Has no effect if the
66
+ # other palette hasn't been #included.
67
+ def uninclude( palette )
68
+ @includes -= [palette]
69
+ end
70
+
71
+ protected
72
+
73
+ # Recursive color lookup
74
+ def lookup( name, max_depth=5 ) # :nodoc:
75
+ return nil if max_depth < 0
76
+
77
+ color = @colors[name]
78
+
79
+ unless color
80
+ @includes.each { |palette|
81
+ c = palette.lookup(name, max_depth-1)
82
+ color = c if c
83
+ }
84
+ end
85
+
86
+ return color
87
+ end
88
+
89
+ private
90
+
91
+ # Takes either a Symbol or a String, and converts it to a
92
+ # lowercase Symbol with spaces converted to underscores.
93
+ #
94
+ # E.g. "Alice Blue" and :ALICE_BLUE both become :alice_blue.
95
+ #
96
+ def sanitize_name( name )
97
+ name.to_s.gsub(' ','_').downcase.intern
98
+ end
99
+
100
+ end
@@ -0,0 +1,177 @@
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'
21
+ require 'rubygame/color/palettes/palette'
22
+
23
+ module Rubygame
24
+ module Color
25
+
26
+ # :enddoc:
27
+
28
+ # The X11 module contains all the colors in the X11 palette
29
+ # by symbol name, e.g. :alice_blue, :dark_olive_green, etc.
30
+ #
31
+ # The list of colors is derived from
32
+ # http://en.wikipedia.org/wiki/X11_color_names
33
+ # as accessed on 2007-12-17.
34
+ X11 = Palette.new({
35
+ :alice_blue => ColorRGB.new( [0.94117, 0.97254, 1.00000] ),
36
+ :antique_white => ColorRGB.new( [0.98039, 0.92156, 0.84313] ),
37
+ :aqua => ColorRGB.new( [0.00000, 1.00000, 1.00000] ),
38
+ :aquamarine => ColorRGB.new( [0.49803, 1.00000, 0.83137] ),
39
+ :azure => ColorRGB.new( [0.94117, 1.00000, 1.00000] ),
40
+ :beige => ColorRGB.new( [0.96078, 0.96078, 0.86274] ),
41
+ :bisque => ColorRGB.new( [1.00000, 0.89411, 0.76862] ),
42
+ :black => ColorRGB.new( [0.00000, 0.00000, 0.00000] ),
43
+ :blanched_almond => ColorRGB.new( [1.00000, 0.92156, 0.80392] ),
44
+ :blue => ColorRGB.new( [0.00000, 0.00000, 1.00000] ),
45
+ :blue_violet => ColorRGB.new( [0.54117, 0.16862, 0.88627] ),
46
+ :brown => ColorRGB.new( [0.64705, 0.16470, 0.16470] ),
47
+ :burly_wood => ColorRGB.new( [0.87058, 0.72156, 0.52941] ),
48
+ :cadet_blue => ColorRGB.new( [0.37254, 0.61960, 0.62745] ),
49
+ :chartreuse => ColorRGB.new( [0.49803, 1.00000, 0.00000] ),
50
+ :chocolate => ColorRGB.new( [0.82352, 0.41176, 0.11764] ),
51
+ :coral => ColorRGB.new( [1.00000, 0.49803, 0.31372] ),
52
+ :cornflower_blue => ColorRGB.new( [0.39215, 0.58431, 0.92941] ),
53
+ :cornsilk => ColorRGB.new( [1.00000, 0.97254, 0.86274] ),
54
+ :crimson => ColorRGB.new( [0.86274, 0.07843, 0.23529] ),
55
+ :cyan => ColorRGB.new( [0.00000, 1.00000, 1.00000] ),
56
+ :dark_blue => ColorRGB.new( [0.00000, 0.00000, 0.54509] ),
57
+ :dark_cyan => ColorRGB.new( [0.00000, 0.54509, 0.54509] ),
58
+ :dark_goldenrod => ColorRGB.new( [0.72156, 0.52549, 0.04313] ),
59
+ :dark_gray => ColorRGB.new( [0.66274, 0.66274, 0.66274] ),
60
+ :dark_green => ColorRGB.new( [0.00000, 0.39215, 0.00000] ),
61
+ :dark_khaki => ColorRGB.new( [0.74117, 0.71764, 0.41960] ),
62
+ :dark_magenta => ColorRGB.new( [0.54509, 0.00000, 0.54509] ),
63
+ :dark_olive_green => ColorRGB.new( [0.33333, 0.41960, 0.18431] ),
64
+ :dark_orange => ColorRGB.new( [1.00000, 0.54901, 0.00000] ),
65
+ :dark_orchid => ColorRGB.new( [0.60000, 0.19607, 0.80000] ),
66
+ :dark_red => ColorRGB.new( [0.54509, 0.00000, 0.00000] ),
67
+ :dark_salmon => ColorRGB.new( [0.91372, 0.58823, 0.47843] ),
68
+ :dark_sea_green => ColorRGB.new( [0.56078, 0.73725, 0.56078] ),
69
+ :dark_slate_blue => ColorRGB.new( [0.28235, 0.23921, 0.54509] ),
70
+ :dark_slate_gray => ColorRGB.new( [0.18431, 0.30980, 0.30980] ),
71
+ :dark_turquoise => ColorRGB.new( [0.00000, 0.80784, 0.81960] ),
72
+ :dark_violet => ColorRGB.new( [0.58039, 0.00000, 0.82745] ),
73
+ :deep_pink => ColorRGB.new( [1.00000, 0.07843, 0.57647] ),
74
+ :deep_sky_blue => ColorRGB.new( [0.00000, 0.74901, 1.00000] ),
75
+ :dim_gray => ColorRGB.new( [0.41176, 0.41176, 0.41176] ),
76
+ :dodger_blue => ColorRGB.new( [0.11764, 0.56470, 1.00000] ),
77
+ :fire_brick => ColorRGB.new( [0.69803, 0.13333, 0.13333] ),
78
+ :floral_white => ColorRGB.new( [1.00000, 0.98039, 0.94117] ),
79
+ :forest_green => ColorRGB.new( [0.13333, 0.54509, 0.13333] ),
80
+ :fuchsia => ColorRGB.new( [1.00000, 0.00000, 1.00000] ),
81
+ :gainsboro => ColorRGB.new( [0.86274, 0.86274, 0.86274] ),
82
+ :ghost_white => ColorRGB.new( [0.97254, 0.97254, 1.00000] ),
83
+ :gold => ColorRGB.new( [1.00000, 0.84313, 0.00000] ),
84
+ :goldenrod => ColorRGB.new( [0.85490, 0.64705, 0.12549] ),
85
+ :gray => ColorRGB.new( [0.50196, 0.50196, 0.50196] ),
86
+ :green => ColorRGB.new( [0.00000, 0.50196, 0.00000] ),
87
+ :green_yellow => ColorRGB.new( [0.67843, 1.00000, 0.18431] ),
88
+ :honeydew => ColorRGB.new( [0.94117, 1.00000, 0.94117] ),
89
+ :hot_pink => ColorRGB.new( [1.00000, 0.41176, 0.70588] ),
90
+ :indian_red => ColorRGB.new( [0.80392, 0.36078, 0.36078] ),
91
+ :indigo => ColorRGB.new( [0.29411, 0.00000, 0.50980] ),
92
+ :ivory => ColorRGB.new( [1.00000, 1.00000, 0.94117] ),
93
+ :khaki => ColorRGB.new( [0.94117, 0.90196, 0.54901] ),
94
+ :lavender => ColorRGB.new( [0.90196, 0.90196, 0.98039] ),
95
+ :lavender_blush => ColorRGB.new( [1.00000, 0.94117, 0.96078] ),
96
+ :lawn_green => ColorRGB.new( [0.48627, 0.98823, 0.00000] ),
97
+ :lemon_chiffon => ColorRGB.new( [1.00000, 0.98039, 0.80392] ),
98
+ :light_blue => ColorRGB.new( [0.67843, 0.84705, 0.90196] ),
99
+ :light_coral => ColorRGB.new( [0.94117, 0.50196, 0.50196] ),
100
+ :light_cyan => ColorRGB.new( [0.87843, 1.00000, 1.00000] ),
101
+ :light_goldenrod_yellow => ColorRGB.new( [0.98039, 0.98039, 0.82352] ),
102
+ :light_green => ColorRGB.new( [0.56470, 0.93333, 0.56470] ),
103
+ :light_grey => ColorRGB.new( [0.82745, 0.82745, 0.82745] ),
104
+ :light_pink => ColorRGB.new( [1.00000, 0.71372, 0.75686] ),
105
+ :light_salmon => ColorRGB.new( [1.00000, 0.62745, 0.47843] ),
106
+ :light_sea_green => ColorRGB.new( [0.12549, 0.69803, 0.66666] ),
107
+ :light_sky_blue => ColorRGB.new( [0.52941, 0.80784, 0.98039] ),
108
+ :light_slate_gray => ColorRGB.new( [0.46666, 0.53333, 0.60000] ),
109
+ :light_steel_blue => ColorRGB.new( [0.69019, 0.76862, 0.87058] ),
110
+ :light_yellow => ColorRGB.new( [1.00000, 1.00000, 0.87843] ),
111
+ :lime => ColorRGB.new( [0.00000, 1.00000, 0.00000] ),
112
+ :lime_green => ColorRGB.new( [0.19607, 0.80392, 0.19607] ),
113
+ :linen => ColorRGB.new( [0.98039, 0.94117, 0.90196] ),
114
+ :magenta => ColorRGB.new( [1.00000, 0.00000, 1.00000] ),
115
+ :maroon => ColorRGB.new( [0.50196, 0.00000, 0.00000] ),
116
+ :medium_aquamarine => ColorRGB.new( [0.40000, 0.80392, 0.66666] ),
117
+ :medium_blue => ColorRGB.new( [0.00000, 0.00000, 0.80392] ),
118
+ :medium_orchid => ColorRGB.new( [0.72941, 0.33333, 0.82745] ),
119
+ :medium_purple => ColorRGB.new( [0.57647, 0.43921, 0.85882] ),
120
+ :medium_sea_green => ColorRGB.new( [0.23529, 0.70196, 0.44313] ),
121
+ :medium_slate_blue => ColorRGB.new( [0.48235, 0.40784, 0.93333] ),
122
+ :medium_spring_green => ColorRGB.new( [0.00000, 0.98039, 0.60392] ),
123
+ :medium_turquoise => ColorRGB.new( [0.28235, 0.81960, 0.80000] ),
124
+ :medium_violet_red => ColorRGB.new( [0.78039, 0.08235, 0.52156] ),
125
+ :midnight_blue => ColorRGB.new( [0.09803, 0.09803, 0.43921] ),
126
+ :mint_cream => ColorRGB.new( [0.96078, 1.00000, 0.98039] ),
127
+ :misty_rose => ColorRGB.new( [1.00000, 0.89411, 0.88235] ),
128
+ :moccasin => ColorRGB.new( [1.00000, 0.89411, 0.70980] ),
129
+ :navajo_white => ColorRGB.new( [1.00000, 0.87058, 0.67843] ),
130
+ :navy => ColorRGB.new( [0.00000, 0.00000, 0.50196] ),
131
+ :old_lace => ColorRGB.new( [0.99215, 0.96078, 0.90196] ),
132
+ :olive => ColorRGB.new( [0.50196, 0.50196, 0.00000] ),
133
+ :olive_drab => ColorRGB.new( [0.41960, 0.55686, 0.13725] ),
134
+ :orange => ColorRGB.new( [1.00000, 0.64705, 0.00000] ),
135
+ :orange_red => ColorRGB.new( [1.00000, 0.27058, 0.00000] ),
136
+ :orchid => ColorRGB.new( [0.85490, 0.43921, 0.83921] ),
137
+ :pale_goldenrod => ColorRGB.new( [0.93333, 0.90980, 0.66666] ),
138
+ :pale_green => ColorRGB.new( [0.59607, 0.98431, 0.59607] ),
139
+ :pale_turquoise => ColorRGB.new( [0.68627, 0.93333, 0.93333] ),
140
+ :pale_violet_red => ColorRGB.new( [0.85882, 0.43921, 0.57647] ),
141
+ :papaya_whip => ColorRGB.new( [1.00000, 0.93725, 0.83529] ),
142
+ :peach_puff => ColorRGB.new( [1.00000, 0.85490, 0.72549] ),
143
+ :peru => ColorRGB.new( [0.80392, 0.52156, 0.24705] ),
144
+ :pink => ColorRGB.new( [1.00000, 0.75294, 0.79607] ),
145
+ :plum => ColorRGB.new( [0.86666, 0.62745, 0.86666] ),
146
+ :powder_blue => ColorRGB.new( [0.69019, 0.87843, 0.90196] ),
147
+ :purple => ColorRGB.new( [0.50196, 0.00000, 0.50196] ),
148
+ :red => ColorRGB.new( [1.00000, 0.00000, 0.00000] ),
149
+ :rosy_brown => ColorRGB.new( [0.73725, 0.56078, 0.56078] ),
150
+ :royal_blue => ColorRGB.new( [0.25490, 0.41176, 0.88235] ),
151
+ :saddle_brown => ColorRGB.new( [0.54509, 0.27058, 0.07450] ),
152
+ :salmon => ColorRGB.new( [0.98039, 0.50196, 0.44705] ),
153
+ :sandy_brown => ColorRGB.new( [0.95686, 0.64313, 0.37647] ),
154
+ :sea_green => ColorRGB.new( [0.18039, 0.54509, 0.34117] ),
155
+ :seashell => ColorRGB.new( [1.00000, 0.96078, 0.93333] ),
156
+ :sienna => ColorRGB.new( [0.62745, 0.32156, 0.17647] ),
157
+ :silver => ColorRGB.new( [0.75294, 0.75294, 0.75294] ),
158
+ :sky_blue => ColorRGB.new( [0.52941, 0.80784, 0.92156] ),
159
+ :slate_blue => ColorRGB.new( [0.41568, 0.35294, 0.80392] ),
160
+ :slate_gray => ColorRGB.new( [0.43921, 0.50196, 0.56470] ),
161
+ :snow => ColorRGB.new( [1.00000, 0.98039, 0.98039] ),
162
+ :spring_green => ColorRGB.new( [0.00000, 1.00000, 0.49803] ),
163
+ :steel_blue => ColorRGB.new( [0.27450, 0.50980, 0.70588] ),
164
+ :tan => ColorRGB.new( [0.82352, 0.70588, 0.54901] ),
165
+ :teal => ColorRGB.new( [0.00000, 0.50196, 0.50196] ),
166
+ :thistle => ColorRGB.new( [0.84705, 0.74901, 0.84705] ),
167
+ :tomato => ColorRGB.new( [1.00000, 0.38823, 0.27843] ),
168
+ :turquoise => ColorRGB.new( [0.25098, 0.87843, 0.81568] ),
169
+ :violet => ColorRGB.new( [0.93333, 0.50980, 0.93333] ),
170
+ :wheat => ColorRGB.new( [0.96078, 0.87058, 0.70196] ),
171
+ :white => ColorRGB.new( [1.00000, 1.00000, 1.00000] ),
172
+ :white_smoke => ColorRGB.new( [0.96078, 0.96078, 0.96078] ),
173
+ :yellow => ColorRGB.new( [1.00000, 1.00000, 0.00000] ),
174
+ :yellow_green => ColorRGB.new( [0.60392, 0.80392, 0.19607] )
175
+ })
176
+ end
177
+ end
@@ -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,238 @@
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
+
22
+ module Mouse
23
+ # Hash to translate mouse button sym to string
24
+ MOUSE2STR = {
25
+ MOUSE_LEFT => "left",
26
+ MOUSE_MIDDLE => "middle",
27
+ MOUSE_RIGHT => "right"
28
+ }
29
+ # And to translate the other way...
30
+ STR2MOUSE = MOUSE2STR.invert()
31
+ # And allow numbers too (1 = left, so on)...
32
+ STR2MOUSE[1] = MOUSE_LEFT
33
+ STR2MOUSE[2] = MOUSE_MIDDLE
34
+ STR2MOUSE[3] = MOUSE_RIGHT
35
+ end # module Mouse
36
+
37
+ module Key
38
+ # All the keys which have ASCII print values
39
+ # It is 87 lines from here to the closing }, if you want to skip it...
40
+ KEY2ASCII = {
41
+ K_BACKSPACE => "\b",
42
+ K_TAB => "\t",
43
+ K_RETURN => "\n", #SDL docs: "\r". Win vs *nix? What about Mac?
44
+ K_ESCAPE => "^[",
45
+ K_SPACE => " ",
46
+ K_EXCLAIM => "!",
47
+ K_QUOTEDBL => "\"",
48
+ K_HASH => "#",
49
+ K_DOLLAR => "$",
50
+ K_AMPERSAND => "&",
51
+ K_QUOTE => "\'",
52
+ K_LEFTPAREN => "(",
53
+ K_RIGHTPAREN => ")",
54
+ K_ASTERISK => "*",
55
+ K_PLUS => "+",
56
+ K_COMMA => ",",
57
+ K_MINUS => "-",
58
+ K_PERIOD => ".",
59
+ K_SLASH => "/",
60
+ K_0 => "0",
61
+ K_1 => "1",
62
+ K_2 => "2",
63
+ K_3 => "3",
64
+ K_4 => "4",
65
+ K_5 => "5",
66
+ K_6 => "6",
67
+ K_7 => "7",
68
+ K_8 => "8",
69
+ K_9 => "9",
70
+ K_COLON => ":",
71
+ K_SEMICOLON => ";",
72
+ K_LESS => "<",
73
+ K_EQUALS => "=",
74
+ K_GREATER => ">",
75
+ K_QUESTION => "?",
76
+ K_AT => "@",
77
+ K_LEFTBRACKET => "[",
78
+ K_BACKSLASH => "\\",
79
+ K_RIGHTBRACKET => "]",
80
+ K_CARET => "^",
81
+ K_UNDERSCORE => "_",
82
+ K_BACKQUOTE => "`",
83
+ K_A => "a",
84
+ K_B => "b",
85
+ K_C => "c",
86
+ K_D => "d",
87
+ K_E => "e",
88
+ K_F => "f",
89
+ K_G => "g",
90
+ K_H => "h",
91
+ K_I => "i",
92
+ K_J => "j",
93
+ K_K => "k",
94
+ K_L => "l",
95
+ K_M => "m",
96
+ K_N => "n",
97
+ K_O => "o",
98
+ K_P => "p",
99
+ K_Q => "q",
100
+ K_R => "r",
101
+ K_S => "s",
102
+ K_T => "t",
103
+ K_U => "u",
104
+ K_V => "v",
105
+ K_W => "w",
106
+ K_X => "x",
107
+ K_Y => "y",
108
+ K_Z => "z",
109
+ K_KP0 => "0",
110
+ K_KP1 => "1",
111
+ K_KP2 => "2",
112
+ K_KP3 => "3",
113
+ K_KP4 => "4",
114
+ K_KP5 => "5",
115
+ K_KP6 => "6",
116
+ K_KP7 => "7",
117
+ K_KP8 => "8",
118
+ K_KP9 => "9",
119
+ K_KP_PERIOD => ".",
120
+ K_KP_DIVIDE => "/",
121
+ K_KP_MULTIPLY => "*",
122
+ K_KP_MINUS => "-",
123
+ K_KP_PLUS => "+",
124
+ K_KP_ENTER => "\n", #again, SDL docs say "\r"
125
+ K_KP_EQUALS => "=",
126
+ }
127
+
128
+ # And to translate the other way...
129
+ ASCII2KEY = KEY2ASCII.invert()
130
+ # accept uppercase letters too, return same as lowercase version:
131
+ ("a".."z").each{ |letter| ASCII2KEY[letter.upcase] = ASCII2KEY[letter] }
132
+
133
+ # All the keys that are affected by the Shift key, in lower case
134
+ # 49 lines from here to the end of the hash
135
+ KEY2LOWER = {
136
+ K_QUOTE => "\'",
137
+ K_COMMA => ",",
138
+ K_MINUS => "-",
139
+ K_PERIOD => ".",
140
+ K_SLASH => "/",
141
+ K_0 => "0",
142
+ K_1 => "1",
143
+ K_2 => "2",
144
+ K_3 => "3",
145
+ K_4 => "4",
146
+ K_5 => "5",
147
+ K_6 => "6",
148
+ K_7 => "7",
149
+ K_8 => "8",
150
+ K_9 => "9",
151
+ K_SEMICOLON => ";",
152
+ K_EQUALS => "=",
153
+ K_LEFTBRACKET => "[",
154
+ K_BACKSLASH => "\\",
155
+ K_RIGHTBRACKET => "]",
156
+ K_BACKQUOTE => "`",
157
+ K_A => "a",
158
+ K_B => "b",
159
+ K_C => "c",
160
+ K_D => "d",
161
+ K_E => "e",
162
+ K_F => "f",
163
+ K_G => "g",
164
+ K_H => "h",
165
+ K_I => "i",
166
+ K_J => "j",
167
+ K_K => "k",
168
+ K_L => "l",
169
+ K_M => "m",
170
+ K_N => "n",
171
+ K_O => "o",
172
+ K_P => "p",
173
+ K_Q => "q",
174
+ K_R => "r",
175
+ K_S => "s",
176
+ K_T => "t",
177
+ K_U => "u",
178
+ K_V => "v",
179
+ K_W => "w",
180
+ K_X => "x",
181
+ K_Y => "y",
182
+ K_Z => "z",
183
+ }
184
+
185
+ # All the keys that are affected by the Shift key, in UPPER case
186
+ # 49 lines from here to the end of the hash
187
+ KEY2UPPER = {
188
+ K_QUOTE => "\"",
189
+ K_COMMA => "<",
190
+ K_MINUS => "_",
191
+ K_PERIOD => ">",
192
+ K_SLASH => "?",
193
+ K_0 => ")",
194
+ K_1 => "!",
195
+ K_2 => "@",
196
+ K_3 => "#",
197
+ K_4 => "$",
198
+ K_5 => "%",
199
+ K_6 => "^",
200
+ K_7 => "&",
201
+ K_8 => "*",
202
+ K_9 => "(",
203
+ K_SEMICOLON => ":",
204
+ K_EQUALS => "+",
205
+ K_LEFTBRACKET => "{",
206
+ K_BACKSLASH => "|",
207
+ K_RIGHTBRACKET => "}",
208
+ K_BACKQUOTE => "~",
209
+ K_A => "A",
210
+ K_B => "B",
211
+ K_C => "C",
212
+ K_D => "D",
213
+ K_E => "E",
214
+ K_F => "F",
215
+ K_G => "G",
216
+ K_H => "H",
217
+ K_I => "I",
218
+ K_J => "J",
219
+ K_K => "K",
220
+ K_L => "L",
221
+ K_M => "M",
222
+ K_N => "N",
223
+ K_O => "O",
224
+ K_P => "P",
225
+ K_Q => "Q",
226
+ K_R => "R",
227
+ K_S => "S",
228
+ K_T => "T",
229
+ K_U => "U",
230
+ K_V => "V",
231
+ K_W => "W",
232
+ K_X => "X",
233
+ K_Y => "Y",
234
+ K_Z => "Z",
235
+ }
236
+ end #module Key
237
+
238
+ end # module Rubygame