ray 0.0.0.pre2 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.rspec +3 -0
- data/README.md +62 -0
- data/Rakefile +33 -23
- data/VERSION +1 -1
- data/ext/audio.c +473 -0
- data/ext/color.c +4 -4
- data/ext/event.c +25 -3
- data/ext/extconf.rb +35 -22
- data/ext/font.c +287 -0
- data/ext/image.c +682 -33
- data/ext/joystick.c +9 -9
- data/ext/ray.c +166 -55
- data/ext/ray.h +120 -9
- data/ext/ray_osx.m +161 -0
- data/ext/rect.c +31 -4
- data/lib/ray/audio.rb +52 -0
- data/lib/ray/color.rb +16 -0
- data/lib/ray/dsl.rb +1 -3
- data/lib/ray/dsl/event.rb +1 -39
- data/lib/ray/dsl/event_listener.rb +38 -0
- data/lib/ray/dsl/event_runner.rb +3 -1
- data/lib/ray/dsl/event_translator.rb +74 -8
- data/lib/ray/dsl/handler.rb +3 -33
- data/lib/ray/dsl/matcher.rb +129 -23
- data/lib/ray/font.rb +108 -0
- data/lib/ray/font_set.rb +37 -0
- data/lib/ray/game.rb +171 -34
- data/lib/ray/helper.rb +43 -5
- data/lib/ray/image.rb +90 -3
- data/lib/ray/image_set.rb +35 -0
- data/lib/ray/joystick.rb +30 -0
- data/lib/ray/music_set.rb +35 -0
- data/lib/ray/ray.rb +17 -9
- data/lib/ray/rect.rb +51 -0
- data/lib/ray/resource_set.rb +92 -0
- data/lib/ray/scene.rb +220 -51
- data/lib/ray/sound_set.rb +35 -0
- data/lib/ray/sprite.rb +184 -0
- data/psp/ext.c +4 -0
- data/samples/hello_world/hello.rb +35 -0
- data/samples/hello_world/hello_dsl.rb +24 -0
- data/samples/pong/pong.rb +128 -0
- data/samples/sokoban/level_1 +7 -0
- data/samples/sokoban/sokoban.rb +370 -0
- data/spec/ray/audio_spec.rb +146 -0
- data/spec/ray/color_spec.rb +13 -0
- data/spec/ray/event_spec.rb +57 -168
- data/spec/ray/font_spec.rb +93 -0
- data/spec/ray/image_set_spec.rb +48 -0
- data/spec/ray/image_spec.rb +130 -44
- data/spec/ray/joystick_spec.rb +13 -9
- data/spec/ray/matcher_spec.rb +32 -55
- data/spec/ray/ray_spec.rb +33 -31
- data/spec/ray/rect_spec.rb +80 -0
- data/spec/ray/resource_set_spec.rb +105 -0
- data/spec/ray/sprite_spec.rb +163 -0
- data/spec/res/VeraMono.ttf +0 -0
- data/spec/res/aqua2.bmp +0 -0
- data/spec/res/pop.wav +0 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +8 -0
- data/yard_ext.rb +91 -0
- metadata +104 -38
- data/bin/ray +0 -5
- data/bin/ray_irb +0 -4
- data/ext/SDLMain.h +0 -17
- data/ext/SDLMain.m +0 -381
- data/lib/ray/config.rb +0 -84
- data/lib/ray/dsl/converter.rb +0 -65
- data/lib/ray/dsl/listener.rb +0 -30
- data/lib/ray/dsl/type.rb +0 -58
- data/spec/ray/config_spec.rb +0 -90
- data/spec/ray/conversion_spec.rb +0 -43
- data/spec/ray/type_spec.rb +0 -17
- data/spec_runner.rb +0 -27
data/ext/joystick.c
CHANGED
@@ -79,9 +79,17 @@ VALUE ray_joystick_open(VALUE self) {
|
|
79
79
|
return self;
|
80
80
|
}
|
81
81
|
|
82
|
+
/* @return [true, false] true if the joystick is closed */
|
83
|
+
VALUE ray_joystick_closed(VALUE self) {
|
84
|
+
ray_joystick *joy = NULL;
|
85
|
+
Data_Get_Struct(self, ray_joystick, joy);
|
86
|
+
|
87
|
+
return joy->joystick == NULL ? Qtrue : Qfalse;
|
88
|
+
}
|
89
|
+
|
82
90
|
/* Closes the joystick. Can be called even if closed? is true. */
|
83
91
|
VALUE ray_joystick_close(VALUE self) {
|
84
|
-
if (
|
92
|
+
if (ray_joystick_closed(self) == Qtrue)
|
85
93
|
return Qnil;
|
86
94
|
|
87
95
|
SDL_JoystickClose(ray_rb2joystick(self));
|
@@ -94,14 +102,6 @@ VALUE ray_joystick_close(VALUE self) {
|
|
94
102
|
return Qnil;
|
95
103
|
}
|
96
104
|
|
97
|
-
/* @return [true, false] true if the joystick is closed */
|
98
|
-
VALUE ray_joystick_closed(VALUE self) {
|
99
|
-
ray_joystick *joy = NULL;
|
100
|
-
Data_Get_Struct(self, ray_joystick, joy);
|
101
|
-
|
102
|
-
return joy->joystick == NULL ? Qtrue : Qfalse;
|
103
|
-
}
|
104
|
-
|
105
105
|
/* @return [Integer] The number of buttons on this joystick */
|
106
106
|
VALUE ray_joystick_button_count(VALUE self) {
|
107
107
|
return INT2FIX(SDL_JoystickNumButtons(ray_rb2joystick(self)));
|
data/ext/ray.c
CHANGED
@@ -1,16 +1,93 @@
|
|
1
1
|
#include "ray.h"
|
2
2
|
|
3
|
+
#ifdef HAVE_COCOA
|
4
|
+
extern void ray_osx_init();
|
5
|
+
extern void ray_osx_close();
|
6
|
+
#endif
|
7
|
+
|
3
8
|
VALUE ray_mRay = Qnil;
|
4
9
|
|
5
|
-
/*
|
6
|
-
|
7
|
-
|
10
|
+
/*
|
11
|
+
@overload init(opts = {})
|
12
|
+
Inits Ray.
|
13
|
+
|
14
|
+
@option opts [Integer] :frequency Audio frequency (defaults to 22050)
|
15
|
+
@option opts [Integer] :format A constant declared in Ray::Audio
|
16
|
+
@option opts [true] :mono or :stereo Set :mono or :stereo to true to enable
|
17
|
+
one of them.
|
18
|
+
@option opts [Integer] :chunk_size Size of a chunk (defaults to 1024)
|
19
|
+
*/
|
20
|
+
VALUE ray_init(int argc, VALUE *argv, VALUE self) {
|
21
|
+
VALUE hash = Qnil;
|
22
|
+
rb_scan_args(argc, argv, "01", &hash);
|
23
|
+
|
24
|
+
#ifdef HAVE_COCOA
|
25
|
+
ray_osx_init();
|
26
|
+
#endif
|
27
|
+
|
28
|
+
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) == -1) {
|
29
|
+
rb_raise(rb_eRuntimeError, "Couldn't init the SDL (%s)",
|
30
|
+
SDL_GetError());
|
31
|
+
}
|
32
|
+
|
33
|
+
#ifdef HAVE_SDL_TTF
|
34
|
+
if (!TTF_WasInit()) {
|
35
|
+
if (TTF_Init() == -1) {
|
36
|
+
rb_raise(rb_eRuntimeError, "Couldn't init SDL_TTF (%s)",
|
37
|
+
TTF_GetError());
|
38
|
+
}
|
39
|
+
}
|
40
|
+
#endif
|
41
|
+
|
42
|
+
#ifdef HAVE_SDL_MIXER
|
43
|
+
int frequency = MIX_DEFAULT_FREQUENCY;
|
44
|
+
uint16_t format = MIX_DEFAULT_FORMAT;
|
45
|
+
int channels = MIX_DEFAULT_CHANNELS;
|
46
|
+
int chunk_size = 1024;
|
47
|
+
|
48
|
+
if (!NIL_P(hash)) {
|
49
|
+
VALUE rb_freq, rb_format, rb_chunk_size;
|
50
|
+
if (!NIL_P(rb_freq = rb_hash_aref(hash, RAY_SYM("frequency"))))
|
51
|
+
frequency = NUM2INT(rb_freq);
|
52
|
+
|
53
|
+
if (!NIL_P(rb_format = rb_hash_aref(hash, RAY_SYM("format"))))
|
54
|
+
format = NUM2INT(rb_format);
|
55
|
+
|
56
|
+
if (RTEST(rb_hash_aref(hash, RAY_SYM("mono"))))
|
57
|
+
channels = 1;
|
58
|
+
else if (RTEST(rb_hash_aref(hash, RAY_SYM("stereo"))))
|
59
|
+
channels = 2;
|
60
|
+
|
61
|
+
if (!NIL_P(rb_chunk_size = rb_hash_aref(hash, RAY_SYM("chunk_size"))))
|
62
|
+
chunk_size = NUM2INT(rb_chunk_size);
|
63
|
+
}
|
64
|
+
|
65
|
+
if (Mix_OpenAudio(frequency, format, channels, chunk_size) == -1) {
|
66
|
+
rb_raise(rb_eRuntimeError, "Couldn't open audio (%s)",
|
67
|
+
Mix_GetError());
|
68
|
+
}
|
69
|
+
#endif
|
70
|
+
|
8
71
|
return Qnil;
|
9
72
|
}
|
10
73
|
|
11
74
|
/* Stops ray */
|
12
75
|
VALUE ray_stop(VALUE self) {
|
76
|
+
#ifdef HAVE_SDL_MIXER
|
77
|
+
Mix_CloseAudio();
|
78
|
+
#endif
|
79
|
+
|
80
|
+
#ifdef HAVE_SDL_TTF
|
81
|
+
/*
|
82
|
+
Freeing a font after TTF_Quit causes a segfault, but, Ruby being
|
83
|
+
garbage called, we can't be sure a font won't be freed later.
|
84
|
+
*/
|
85
|
+
|
86
|
+
/* TTF_Quit(); */
|
87
|
+
#endif
|
88
|
+
|
13
89
|
SDL_Quit();
|
90
|
+
/* The pool is never drained on OSX */
|
14
91
|
return Qnil;
|
15
92
|
}
|
16
93
|
|
@@ -50,6 +127,9 @@ ray_video_mode ray_parse_video_mode(VALUE hash) {
|
|
50
127
|
if (RTEST(rb_hash_aref(hash, RAY_SYM("no_frame"))))
|
51
128
|
flags |= SDL_NOFRAME;
|
52
129
|
|
130
|
+
if (RTEST(rb_hash_aref(hash, RAY_SYM("resizable"))))
|
131
|
+
flags |= SDL_RESIZABLE;
|
132
|
+
|
53
133
|
ray_video_mode mode = {
|
54
134
|
NUM2INT(width),
|
55
135
|
NUM2INT(height),
|
@@ -63,35 +143,36 @@ ray_video_mode ray_parse_video_mode(VALUE hash) {
|
|
63
143
|
}
|
64
144
|
|
65
145
|
/*
|
66
|
-
|
146
|
+
@overload create_window(hash)
|
147
|
+
Creates a new window.
|
67
148
|
|
68
|
-
|
69
|
-
|
70
|
-
|
149
|
+
If both hw_surface and sws_urface are false, hw_surface
|
150
|
+
will be considered as true. :sw_surface should be true
|
151
|
+
if you want to acess
|
71
152
|
|
72
|
-
|
153
|
+
@return [Ray::Image] An image representing the window
|
73
154
|
|
74
|
-
|
75
|
-
|
155
|
+
@option hash [Integer] :width Width of the window
|
156
|
+
@option hash [Integer] :height Height of the window
|
76
157
|
|
77
|
-
|
78
|
-
|
158
|
+
@option hash [Integer] :w Alias for width
|
159
|
+
@option hash [Integer] :h Alias for height
|
79
160
|
|
80
|
-
|
81
|
-
|
82
|
-
|
161
|
+
@option hash [Integer] :bits_per_pixel Bits per pixel. Valid values are
|
162
|
+
8, 15, 16, 24, and 32.
|
163
|
+
@option hash [Integer] :bpp Alias for bits_per_pixel
|
83
164
|
|
84
|
-
|
165
|
+
@option hash [true, false] :hw_surface Creates the surface in video memory
|
85
166
|
(default)
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
167
|
+
@option hash [true, false] :sw_surface Creates the surface in system memory
|
168
|
+
@option hash [true, false] :async_blit Enables asynchronous updates of the
|
169
|
+
the surface
|
170
|
+
@option hash [true, false] :double_buf Enables double buffering. Ignored
|
171
|
+
if sw_surface is set.
|
172
|
+
@option hash [true, false] :fullscreen Creates a full screen window.
|
173
|
+
@option hash [true, false] :resizable Creates a resizable window.
|
174
|
+
@option hash [true, false] :no_frame Disables window decoration if
|
175
|
+
possible.
|
95
176
|
*/
|
96
177
|
VALUE ray_create_window(VALUE self, VALUE hash) {
|
97
178
|
ray_video_mode mode = ray_parse_video_mode(hash);
|
@@ -107,8 +188,10 @@ VALUE ray_create_window(VALUE self, VALUE hash) {
|
|
107
188
|
}
|
108
189
|
|
109
190
|
/*
|
110
|
-
@
|
111
|
-
|
191
|
+
@overload can_use_mode?(hash)
|
192
|
+
@param [Hash] hash Same options as in create_window
|
193
|
+
@return [true, false] True if the video mode described by hash
|
194
|
+
can be used.
|
112
195
|
*/
|
113
196
|
VALUE ray_can_use_mode(VALUE self, VALUE hash) {
|
114
197
|
ray_video_mode mode = ray_parse_video_mode(hash);
|
@@ -118,8 +201,9 @@ VALUE ray_can_use_mode(VALUE self, VALUE hash) {
|
|
118
201
|
}
|
119
202
|
|
120
203
|
/*
|
121
|
-
|
122
|
-
|
204
|
+
@overload icon=(icon)
|
205
|
+
Sets the window icon
|
206
|
+
@param [Ray::Image] icon The icon to display
|
123
207
|
*/
|
124
208
|
VALUE ray_set_icon(VALUE self, VALUE icon) {
|
125
209
|
SDL_WM_SetIcon(ray_rb2surface(icon), NULL);
|
@@ -136,7 +220,10 @@ VALUE ray_window_title(VALUE self) {
|
|
136
220
|
return rb_str_new2(title);
|
137
221
|
}
|
138
222
|
|
139
|
-
/*
|
223
|
+
/*
|
224
|
+
@overload window_title=(title)
|
225
|
+
Sets the window title
|
226
|
+
*/
|
140
227
|
VALUE ray_set_window_title(VALUE self, VALUE title) {
|
141
228
|
char *icon = NULL;
|
142
229
|
|
@@ -158,7 +245,10 @@ VALUE ray_text_icon(VALUE self) {
|
|
158
245
|
return rb_str_new2(icon);
|
159
246
|
}
|
160
247
|
|
161
|
-
/*
|
248
|
+
/*
|
249
|
+
@overload text_icon=(val)
|
250
|
+
Sets the window text icon
|
251
|
+
*/
|
162
252
|
VALUE ray_set_text_icon(VALUE self, VALUE icon) {
|
163
253
|
char *title;
|
164
254
|
|
@@ -180,7 +270,10 @@ VALUE ray_grab_input(VALUE self) {
|
|
180
270
|
return (mode == SDL_GRAB_ON) ? Qtrue : Qfalse;
|
181
271
|
}
|
182
272
|
|
183
|
-
/*
|
273
|
+
/*
|
274
|
+
@overload grab_input=(grab)
|
275
|
+
Sets the grab input to true or false
|
276
|
+
*/
|
184
277
|
VALUE ray_set_grab_input(VALUE self, VALUE grab) {
|
185
278
|
SDL_WM_GrabInput(RTEST(grab) ? SDL_GRAB_ON : SDL_GRAB_OFF);
|
186
279
|
return grab;
|
@@ -204,10 +297,37 @@ VALUE ray_has_image_support(VALUE self) {
|
|
204
297
|
#endif
|
205
298
|
}
|
206
299
|
|
300
|
+
/* @return [true, false] true if Ray supports graphical effect like rotations */
|
301
|
+
VALUE ray_has_gfx_support(VALUE self) {
|
302
|
+
#ifdef HAVE_SDL_GFX
|
303
|
+
return Qtrue;
|
304
|
+
#else
|
305
|
+
return Qfalse;
|
306
|
+
#endif
|
307
|
+
}
|
308
|
+
|
309
|
+
/* @return [true, false] true if Ray supports ttf fonts */
|
310
|
+
VALUE ray_has_font_support(VALUE self) {
|
311
|
+
#ifdef HAVE_SDL_TTF
|
312
|
+
return Qtrue;
|
313
|
+
#else
|
314
|
+
return Qfalse;
|
315
|
+
#endif
|
316
|
+
}
|
317
|
+
|
318
|
+
/* @return [true, false] true if Ray supports audio playback */
|
319
|
+
VALUE ray_has_audio_support(VALUE self) {
|
320
|
+
#ifdef HAVE_SDL_MIXER
|
321
|
+
return Qtrue;
|
322
|
+
#else
|
323
|
+
return Qfalse;
|
324
|
+
#endif
|
325
|
+
}
|
326
|
+
|
207
327
|
void Init_ray_ext() {
|
208
328
|
ray_mRay = rb_define_module("Ray");
|
209
329
|
|
210
|
-
rb_define_module_function(ray_mRay, "init", ray_init,
|
330
|
+
rb_define_module_function(ray_mRay, "init", ray_init, -1);
|
211
331
|
rb_define_module_function(ray_mRay, "stop", ray_stop, 0);
|
212
332
|
|
213
333
|
rb_define_module_function(ray_mRay, "create_window", ray_create_window, 1);
|
@@ -227,6 +347,12 @@ void Init_ray_ext() {
|
|
227
347
|
|
228
348
|
rb_define_module_function(ray_mRay, "has_image_support?",
|
229
349
|
ray_has_image_support, 0);
|
350
|
+
rb_define_module_function(ray_mRay, "has_gfx_support?",
|
351
|
+
ray_has_gfx_support, 0);
|
352
|
+
rb_define_module_function(ray_mRay, "has_font_support?",
|
353
|
+
ray_has_font_support, 0);
|
354
|
+
rb_define_module_function(ray_mRay, "has_audio_support?",
|
355
|
+
ray_has_audio_support, 0);
|
230
356
|
|
231
357
|
Init_ray_image();
|
232
358
|
Init_ray_color();
|
@@ -234,33 +360,18 @@ void Init_ray_ext() {
|
|
234
360
|
Init_ray_event();
|
235
361
|
Init_ray_joystick();
|
236
362
|
|
237
|
-
#ifdef
|
238
|
-
|
363
|
+
#ifdef HAVE_SDL_TTF
|
364
|
+
Init_ray_font();
|
239
365
|
#endif
|
240
|
-
}
|
241
366
|
|
242
|
-
#
|
243
|
-
|
244
|
-
int main(int argc, char *argv[]) {
|
245
|
-
#if defined(HAVE_RUBY_RUN_NODE)
|
246
|
-
ruby_init();
|
247
|
-
Init_ray_ext();
|
248
|
-
ruby_run_node(ruby_options(argc, argv));
|
249
|
-
#elif defined(HAVE_RUBY_RUN)
|
250
|
-
ruby_init();
|
251
|
-
Init_ray_ext();
|
252
|
-
ruby_init_loadpath();
|
253
|
-
ruby_options(argc, argv);
|
254
|
-
ruby_run();
|
255
|
-
#else
|
256
|
-
fprintf(stderr, "Please use \"require 'ray'\" on this platform\n");
|
257
|
-
return 1;
|
367
|
+
#ifdef HAVE_SDL_MIXER
|
368
|
+
Init_ray_audio();
|
258
369
|
#endif
|
259
370
|
|
260
|
-
|
261
|
-
|
262
|
-
|
371
|
+
#ifdef PSP
|
372
|
+
Init_ray_psp();
|
263
373
|
#endif
|
374
|
+
}
|
264
375
|
|
265
376
|
#ifdef PSP
|
266
377
|
|
data/ext/ray.h
CHANGED
@@ -1,10 +1,13 @@
|
|
1
|
+
#ifndef RAY_H_
|
2
|
+
#define RAY_H_
|
3
|
+
|
1
4
|
#ifndef PSP
|
2
5
|
# include "ruby.h"
|
3
6
|
#else
|
4
7
|
# include <ruby/ruby.h>
|
5
8
|
#endif
|
6
9
|
|
7
|
-
#if defined(HAVE_SDL_H)
|
10
|
+
#if defined(HAVE_SDL_H)
|
8
11
|
# include <SDL.h>
|
9
12
|
#else
|
10
13
|
# include <SDL/SDL.h>
|
@@ -16,14 +19,66 @@
|
|
16
19
|
# include <pspctrl.h>
|
17
20
|
#endif
|
18
21
|
|
19
|
-
#if defined(
|
20
|
-
# if defined(
|
21
|
-
#
|
22
|
-
#
|
22
|
+
#if defined(HAVE_SDL_IMAGE_H)
|
23
|
+
# if !defined(HAVE_SDL_IMAGE)
|
24
|
+
# define HAVE_SDL_IMAGE
|
25
|
+
# endif
|
26
|
+
# include <SDL_image.h>
|
27
|
+
#else
|
28
|
+
# if defined(HAVE_SDL_SDL_IMAGE_H)
|
29
|
+
# if !defined(HAVE_SDL_IMAGE)
|
30
|
+
# define HAVE_SDL_IMAGE
|
31
|
+
# endif
|
23
32
|
# include <SDL/SDL_image.h>
|
24
33
|
# endif
|
25
34
|
#endif
|
26
35
|
|
36
|
+
#if defined(HAVE_SDL_ROTOZOOM_H)
|
37
|
+
# if !defined(HAVE_SDL_GFX)
|
38
|
+
# define HAVE_SDL_GFX
|
39
|
+
# endif
|
40
|
+
# include <SDL_gfxPrimitives.h>
|
41
|
+
# include <SDL_rotozoom.h>
|
42
|
+
# include <SDL_imageFilter.h>
|
43
|
+
#else
|
44
|
+
# if defined(HAVE_SDL_SDL_ROTOZOOM_H)
|
45
|
+
# if !defined(HAVE_SDL_GFX)
|
46
|
+
# define HAVE_SDL_GFX
|
47
|
+
# endif
|
48
|
+
# include <SDL/SDL_gfxPrimitives.h>
|
49
|
+
# include <SDL/SDL_rotozoom.h>
|
50
|
+
# include <SDL/SDL_imageFilter.h>
|
51
|
+
# endif
|
52
|
+
#endif
|
53
|
+
|
54
|
+
#if defined(HAVE_SDL_TTF_H)
|
55
|
+
# if !defined(HAVE_SDL_TTF)
|
56
|
+
# define HAVE_SDL_TTF
|
57
|
+
# endif
|
58
|
+
# include <SDL_ttf.h>
|
59
|
+
#else
|
60
|
+
# if defined(HAVE_SDL_SDL_TTF_H)
|
61
|
+
# if !defined(HAVE_SDL_TTF)
|
62
|
+
# define HAVE_SDL_TTF
|
63
|
+
# endif
|
64
|
+
# include <SDL/SDL_ttf.h>
|
65
|
+
# endif
|
66
|
+
#endif
|
67
|
+
|
68
|
+
#if defined(HAVE_SDL_MIXER_H)
|
69
|
+
# if !defined(HAVE_SDL_MIXER)
|
70
|
+
# define HAVE_SDL_MIXER
|
71
|
+
# endif
|
72
|
+
# include <SDL_mixer.h>
|
73
|
+
#else
|
74
|
+
# if defined(HAVE_SDL_SDL_MIXER_H)
|
75
|
+
# if !defined(HAVE_SDL_MIXER)
|
76
|
+
# define HAVE_SDL_MIXER
|
77
|
+
# endif
|
78
|
+
# include <SDL/SDL_mixer.h>
|
79
|
+
# endif
|
80
|
+
#endif
|
81
|
+
|
27
82
|
#ifdef __cplusplus
|
28
83
|
extern "C" {
|
29
84
|
#if 0
|
@@ -39,6 +94,16 @@ extern VALUE ray_cColor;
|
|
39
94
|
extern VALUE ray_cRect;
|
40
95
|
extern VALUE ray_cEvent;
|
41
96
|
|
97
|
+
#ifdef HAVE_SDL_TTF
|
98
|
+
extern VALUE ray_cFont;
|
99
|
+
#endif
|
100
|
+
|
101
|
+
#ifdef HAVE_SDL_MIXER
|
102
|
+
extern VALUE ray_mAudio;
|
103
|
+
extern VALUE ray_cSound;
|
104
|
+
extern VALUE ray_cMusic;
|
105
|
+
#endif
|
106
|
+
|
42
107
|
#ifdef PSP
|
43
108
|
extern VALUE ray_eTimeoutError;
|
44
109
|
extern VALUE ray_mWlan;
|
@@ -65,10 +130,8 @@ typedef struct {
|
|
65
130
|
} ray_video_mode;
|
66
131
|
|
67
132
|
typedef struct {
|
68
|
-
VALUE self;
|
69
133
|
SDL_Surface *surface;
|
70
|
-
|
71
|
-
int mustFree; /* Should we call SDL_FreeSurface? */
|
134
|
+
int must_free; /* Should we call SDL_FreeSurface? */
|
72
135
|
} ray_image;
|
73
136
|
|
74
137
|
typedef struct {
|
@@ -81,11 +144,30 @@ typedef struct {
|
|
81
144
|
SDL_Joystick *joystick;
|
82
145
|
} ray_joystick;
|
83
146
|
|
147
|
+
#ifdef HAVE_SDL_TTF
|
148
|
+
typedef struct {
|
149
|
+
TTF_Font *font;
|
150
|
+
} ray_font;
|
151
|
+
#endif
|
152
|
+
|
153
|
+
#ifdef HAVE_SDL_MIXER
|
154
|
+
typedef struct {
|
155
|
+
Mix_Chunk *sound;
|
156
|
+
} ray_sound;
|
157
|
+
|
158
|
+
typedef struct {
|
159
|
+
Mix_Music *music;
|
160
|
+
} ray_music;
|
161
|
+
#endif
|
162
|
+
|
84
163
|
/* Convertion functions */
|
85
164
|
|
86
|
-
/** Converts a surface into a ruby object */
|
165
|
+
/** Converts a surface into a ruby object (won't free it) */
|
87
166
|
VALUE ray_create_image(SDL_Surface *surface);
|
88
167
|
|
168
|
+
/** Converts a surface into a ruby object (will free it) */
|
169
|
+
VALUE ray_create_gc_image(SDL_Surface *surface);
|
170
|
+
|
89
171
|
/** Converts a color into a ruby object */
|
90
172
|
VALUE ray_col2rb(ray_color color);
|
91
173
|
|
@@ -107,12 +189,31 @@ SDL_Surface *ray_rb2surface(VALUE object);
|
|
107
189
|
/** Converts a ruby object into a rect */
|
108
190
|
ray_rect ray_rb2rect(VALUE object);
|
109
191
|
|
192
|
+
/**
|
193
|
+
Converts a ruby object into a rect even if it's not an intance
|
194
|
+
of Ray::Rect.
|
195
|
+
*/
|
196
|
+
ray_rect ray_convert_to_rect(VALUE obj);
|
197
|
+
|
110
198
|
/** Converts a ruby object into an event */
|
111
199
|
SDL_Event *ray_rb2event(VALUE object);
|
112
200
|
|
113
201
|
/** Converts a ruby object into a joystick */
|
114
202
|
SDL_Joystick *ray_rb2joystick(VALUE object);
|
115
203
|
|
204
|
+
#ifdef HAVE_SDL_TTF
|
205
|
+
/** Converts a ruby object into a font */
|
206
|
+
TTF_Font *ray_rb2font(VALUE object);
|
207
|
+
#endif
|
208
|
+
|
209
|
+
#ifdef HAVE_SDL_MIXER
|
210
|
+
/** Converts a ruby object into a sound chunk */
|
211
|
+
Mix_Chunk *ray_rb2chunk(VALUE object);
|
212
|
+
|
213
|
+
/** Converts a ruby object into a music */
|
214
|
+
Mix_Music *ray_rb2music(VALUE object);
|
215
|
+
#endif
|
216
|
+
|
116
217
|
/* Initializers */
|
117
218
|
|
118
219
|
void Init_ray_ext();
|
@@ -122,6 +223,14 @@ void Init_ray_rect();
|
|
122
223
|
void Init_ray_event();
|
123
224
|
void Init_ray_joystick();
|
124
225
|
|
226
|
+
#ifdef HAVE_SDL_TTF
|
227
|
+
void Init_ray_font();
|
228
|
+
#endif
|
229
|
+
|
230
|
+
#ifdef HAVE_SDL_MIXER
|
231
|
+
void Init_ray_audio();
|
232
|
+
#endif
|
233
|
+
|
125
234
|
#ifdef PSP
|
126
235
|
void Init_ray_psp();
|
127
236
|
#endif
|
@@ -132,3 +241,5 @@ void Init_ray_psp();
|
|
132
241
|
#endif
|
133
242
|
}
|
134
243
|
#endif
|
244
|
+
|
245
|
+
#endif
|