rubygame 2.2.0-i586-linux

Sign up to get free protection for your applications and to get access to all the features.
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,209 @@
1
+ /*
2
+ * Code that is common to all Rubygame modules.
3
+ *--
4
+ * Rubygame -- Ruby code and bindings to SDL to facilitate game creation
5
+ * Copyright (C) 2004-2007 John Croisant
6
+ *
7
+ * This library is free software; you can redistribute it and/or
8
+ * modify it under the terms of the GNU Lesser General Public
9
+ * License as published by the Free Software Foundation; either
10
+ * version 2.1 of the License, or (at your option) any later version.
11
+ *
12
+ * This library is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
+ * Lesser General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public
18
+ * License along with this library; if not, write to the Free Software
19
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
+ *++
21
+ */
22
+
23
+ #include "rubygame_shared.h"
24
+
25
+ VALUE mRubygame;
26
+ VALUE cSurface;
27
+ VALUE cRect;
28
+ VALUE eSDLError;
29
+ SDL_Rect *make_rect(int, int, int, int);
30
+ SDL_Color make_sdl_color(VALUE);
31
+ int init_video_system();
32
+ void Init_rubygame_shared();
33
+
34
+ SDL_Rect *make_rect(int x, int y, int w, int h)
35
+ {
36
+ SDL_Rect *rect;
37
+ rect = (SDL_Rect *) malloc(sizeof(SDL_Rect));
38
+ rect->x = x;
39
+ rect->y = y;
40
+ rect->w = w;
41
+ rect->h = h;
42
+ return rect;
43
+ }
44
+
45
+ VALUE make_symbol(char *string)
46
+ {
47
+ return ID2SYM(rb_intern(string));
48
+ }
49
+
50
+ /* Take either nil, Numeric or an Array of Numerics, returns Uint32. */
51
+ Uint32 collapse_flags(VALUE vflags)
52
+ {
53
+ Uint32 flags = 0;
54
+ int i;
55
+
56
+ if( RTEST(vflags) )
57
+ {
58
+ switch( TYPE(vflags) ){
59
+ case T_ARRAY: {
60
+ int len = RARRAY(vflags)->len;
61
+ for(i=0; i < len; i++)
62
+ {
63
+ flags |= NUM2UINT( rb_ary_entry( vflags,i ) );
64
+ }
65
+ break;
66
+ }
67
+ case T_BIGNUM: {
68
+ flags = rb_big2uint( vflags );
69
+ break;
70
+ }
71
+ case T_FIXNUM: {
72
+ flags = NUM2UINT( vflags );
73
+ break;
74
+ }
75
+ default: {
76
+ rb_raise(rb_eArgError,"Wrong type for argument `flags' (wanted Number or Array).");
77
+ }
78
+ }
79
+ }
80
+
81
+ return flags;
82
+ }
83
+
84
+ VALUE convert_to_array(VALUE val)
85
+ {
86
+ VALUE v = rb_check_array_type(val);
87
+ if( TYPE(v) != T_ARRAY )
88
+ {
89
+ rb_raise(rb_eTypeError, "can't convert %s into Array",
90
+ rb_obj_classname(val));
91
+ }
92
+ return v;
93
+ }
94
+
95
+ /* Takes a Color, Array, or color name (Symbol or String).
96
+ * Returns an RGBA Array, or raises eTypeError if it can't.
97
+ */
98
+ VALUE convert_color(VALUE color)
99
+ {
100
+ if( rb_respond_to(color, rb_intern("to_sdl_rgba_ary")) )
101
+ {
102
+ return rb_funcall( color, rb_intern("to_sdl_rgba_ary"), 0 );
103
+ }
104
+ else if( rb_respond_to(color, rb_intern("to_ary")) )
105
+ {
106
+ return convert_to_array( color );
107
+ }
108
+ else if( TYPE(color) == T_SYMBOL || TYPE(color) == T_STRING )
109
+ {
110
+ VALUE mColor = rb_const_get( mRubygame, rb_intern("Color") );
111
+ return convert_color( rb_funcall( mColor, rb_intern("[]"), 1, color) );
112
+ }
113
+ else
114
+ {
115
+ rb_raise(rb_eTypeError, "unsupported type %s for color",
116
+ rb_obj_classname(color));
117
+ }
118
+ }
119
+
120
+ SDL_Color make_sdl_color(VALUE vcolor)
121
+ {
122
+ SDL_Color color;
123
+ vcolor = convert_color(vcolor);
124
+ extract_rgb_u8_as_u8(vcolor, &(color.r), &(color.g), &(color.b));
125
+ return color;
126
+ }
127
+
128
+ void extract_rgb_u8_as_u8(VALUE color, Uint8 *r, Uint8 *g, Uint8 *b)
129
+ {
130
+ *r = NUM2UINT(rb_ary_entry(color, 0));
131
+ *g = NUM2UINT(rb_ary_entry(color, 1));
132
+ *b = NUM2UINT(rb_ary_entry(color, 2));
133
+ }
134
+
135
+ void extract_rgba_u8_as_u8(VALUE color, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
136
+ {
137
+ *r = NUM2UINT(rb_ary_entry(color, 0));
138
+ *g = NUM2UINT(rb_ary_entry(color, 1));
139
+ *b = NUM2UINT(rb_ary_entry(color, 2));
140
+
141
+ if( RARRAY(color)->len > 3 )
142
+ {
143
+ *a = NUM2UINT(rb_ary_entry(color, 3));
144
+ }
145
+ else
146
+ {
147
+ *a = 255;
148
+ }
149
+ }
150
+
151
+ /* --
152
+ *
153
+ * call-seq:
154
+ * init_video_system() -> int
155
+ *
156
+ * Initialize SDL's video subsystem.
157
+ * Return 0 (zero) on success, non-zero on failure.
158
+ *
159
+ * If it has already been initialized, return 0 immediately.
160
+ *
161
+ * ++
162
+ */
163
+ int init_video_system()
164
+ {
165
+ if( SDL_WasInit(SDL_INIT_VIDEO) == 0 )
166
+ {
167
+ return SDL_Init(SDL_INIT_VIDEO);
168
+ }
169
+ else
170
+ {
171
+ return 0;
172
+ }
173
+ }
174
+
175
+
176
+ void Init_rubygame_shared()
177
+ {
178
+
179
+ mRubygame = rb_define_module("Rubygame");
180
+
181
+ /* Rubygame::Surface class */
182
+ if( !rb_const_defined(mRubygame,rb_intern("Surface")) )
183
+ {
184
+ cSurface = rb_define_class_under(mRubygame,"Surface",rb_cObject);
185
+ }
186
+ else
187
+ {
188
+ cSurface = rb_const_get(mRubygame,rb_intern("Surface"));
189
+ }
190
+
191
+ /* Rubygame::SDLError class */
192
+ if( !rb_const_defined(mRubygame,rb_intern("SDLError")))
193
+ {
194
+ /* Indicates that an SDL function did not execute properly. */
195
+ eSDLError = rb_define_class_under(mRubygame,"SDLError",rb_eStandardError);
196
+ }
197
+ else
198
+ {
199
+ eSDLError = rb_const_get(mRubygame,rb_intern("SDLError"));
200
+ }
201
+
202
+ /* Rubygame::VERSIONS hash table */
203
+ if( !rb_const_defined(mRubygame, rb_intern("VERSIONS")))
204
+ {
205
+ /* A Hash containing the version s of rubygame and it's
206
+ * compile-time dependencies. */
207
+ rb_define_const(mRubygame,"VERSIONS",rb_hash_new());
208
+ }
209
+ }
@@ -0,0 +1,60 @@
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_SHARED_H
22
+ #define _RUBYGAME_SHARED_H
23
+
24
+ #include <SDL.h>
25
+ #include <ruby.h>
26
+ #include <stdio.h>
27
+
28
+ /* General */
29
+ extern VALUE mRubygame;
30
+ extern VALUE eSDLError;
31
+ extern VALUE cSurface;
32
+ extern VALUE cRect;
33
+
34
+ extern SDL_Rect *make_rect(int, int, int, int);
35
+ extern VALUE make_symbol(char *);
36
+ extern Uint32 collapse_flags(VALUE);
37
+ extern VALUE convert_to_array(VALUE);
38
+
39
+ extern SDL_Color make_sdl_color(VALUE);
40
+ extern void extract_rgb_u8_as_u8(VALUE, Uint8*, Uint8*, Uint8*);
41
+ extern void extract_rgba_u8_as_u8(VALUE, Uint8*, Uint8*, Uint8*, Uint8*);
42
+
43
+ extern int init_video_system();
44
+ extern void Init_rubygame_shared();
45
+
46
+ /* Apparently it is not desirable to define these functions when
47
+ * using Micrsoft Visual C.
48
+ */
49
+ #ifndef _MSC_VER
50
+
51
+ static inline int max(int a, int b) {
52
+ return a > b ? a : b;
53
+ }
54
+ static inline int min(int a, int b) {
55
+ return a > b ? b : a;
56
+ }
57
+
58
+ #endif
59
+
60
+ #endif
Binary file