rubygame 2.5.3 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/CREDITS +6 -4
  2. data/NEWS +79 -0
  3. data/README +55 -72
  4. data/ROADMAP +20 -13
  5. data/doc/custom_sdl_load_paths.rdoc +79 -0
  6. data/doc/getting_started.rdoc +65 -36
  7. data/doc/keyboard_symbols.rdoc +243 -0
  8. data/doc/macosx_install.rdoc +49 -35
  9. data/doc/windows_install.rdoc +36 -108
  10. data/lib/rubygame.rb +62 -24
  11. data/lib/rubygame/audio.rb +147 -0
  12. data/lib/rubygame/clock.rb +164 -1
  13. data/lib/rubygame/color.rb +40 -7
  14. data/lib/rubygame/color/models/hsl.rb +1 -1
  15. data/lib/rubygame/color/models/hsv.rb +1 -1
  16. data/lib/rubygame/color/models/rgb.rb +1 -1
  17. data/lib/rubygame/color/palettes/css.rb +1 -3
  18. data/lib/rubygame/color/palettes/x11.rb +1 -2
  19. data/lib/rubygame/constants.rb +297 -0
  20. data/lib/rubygame/deprecated_mixer.rb +555 -0
  21. data/lib/rubygame/event.rb +122 -6
  22. data/lib/rubygame/event_handler.rb +3 -1
  23. data/lib/rubygame/event_hook.rb +6 -2
  24. data/lib/rubygame/event_triggers.rb +1 -1
  25. data/lib/rubygame/events.rb +416 -1
  26. data/lib/rubygame/ftor.rb +1 -7
  27. data/lib/rubygame/gfx.rb +583 -0
  28. data/lib/rubygame/gl.rb +107 -0
  29. data/lib/rubygame/image.rb +140 -0
  30. data/lib/rubygame/joystick.rb +184 -0
  31. data/lib/rubygame/main.rb +82 -0
  32. data/lib/rubygame/mediabag.rb +1 -1
  33. data/lib/rubygame/mixer.rb +30 -0
  34. data/lib/rubygame/music.rb +493 -0
  35. data/lib/rubygame/queue.rb +3 -1
  36. data/lib/rubygame/rect.rb +9 -9
  37. data/lib/rubygame/screen.rb +357 -0
  38. data/lib/rubygame/shared.rb +40 -4
  39. data/lib/rubygame/sound.rb +428 -0
  40. data/lib/rubygame/surface.rb +626 -0
  41. data/lib/rubygame/ttf.rb +311 -0
  42. data/samples/FreeSans.ttf +0 -0
  43. data/samples/README +6 -5
  44. data/samples/demo_draw.rb +1 -1
  45. data/samples/demo_gl.rb +3 -1
  46. data/samples/demo_gl_tex.rb +4 -2
  47. data/samples/demo_rubygame.rb +114 -105
  48. data/samples/demo_sfont.rb +1 -1
  49. data/samples/demo_ttf.rb +3 -1
  50. data/samples/demo_utf8.rb +1 -1
  51. data/samples/image_viewer.rb +118 -0
  52. data/samples/load_and_blit.rb +1 -1
  53. data/samples/rubygame.png +0 -0
  54. metadata +34 -40
  55. data/Rakefile +0 -537
  56. data/doc/extended_readme.rdoc +0 -49
  57. data/ext/body/rubygame_body.so +0 -0
  58. data/ext/rubygame/rubygame_clock.c +0 -301
  59. data/ext/rubygame/rubygame_clock.h +0 -32
  60. data/ext/rubygame/rubygame_event.c +0 -760
  61. data/ext/rubygame/rubygame_event.h +0 -48
  62. data/ext/rubygame/rubygame_event2.c +0 -661
  63. data/ext/rubygame/rubygame_event2.h +0 -29
  64. data/ext/rubygame/rubygame_gfx.c +0 -942
  65. data/ext/rubygame/rubygame_gfx.h +0 -101
  66. data/ext/rubygame/rubygame_gl.c +0 -154
  67. data/ext/rubygame/rubygame_gl.h +0 -32
  68. data/ext/rubygame/rubygame_image.c +0 -252
  69. data/ext/rubygame/rubygame_image.h +0 -41
  70. data/ext/rubygame/rubygame_joystick.c +0 -336
  71. data/ext/rubygame/rubygame_joystick.h +0 -41
  72. data/ext/rubygame/rubygame_main.c +0 -158
  73. data/ext/rubygame/rubygame_main.h +0 -36
  74. data/ext/rubygame/rubygame_mixer.c +0 -1024
  75. data/ext/rubygame/rubygame_mixer.h +0 -36
  76. data/ext/rubygame/rubygame_music.c +0 -1017
  77. data/ext/rubygame/rubygame_music.h +0 -29
  78. data/ext/rubygame/rubygame_screen.c +0 -572
  79. data/ext/rubygame/rubygame_screen.h +0 -45
  80. data/ext/rubygame/rubygame_shared.c +0 -269
  81. data/ext/rubygame/rubygame_shared.h +0 -69
  82. data/ext/rubygame/rubygame_sound.c +0 -863
  83. data/ext/rubygame/rubygame_sound.h +0 -29
  84. data/ext/rubygame/rubygame_surface.c +0 -1153
  85. data/ext/rubygame/rubygame_surface.h +0 -62
  86. data/ext/rubygame/rubygame_ttf.c +0 -599
  87. data/ext/rubygame/rubygame_ttf.h +0 -69
  88. data/samples/keys.rb +0 -52
@@ -1,29 +0,0 @@
1
- /*
2
- * Interface to SDL_mixer music playback and mixing.
3
- *--
4
- * Rubygame -- Ruby code and bindings to SDL to facilitate game creation
5
- * Copyright (C) 2004-2008 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
-
24
- #ifndef _RUBYGAME_MUSIC_H
25
- #define _RUBYGAME_MUSIC_H
26
-
27
- extern void Rubygame_Init_Music();
28
-
29
- #endif
@@ -1,572 +0,0 @@
1
- /*
2
- * Screen -- Rubygame-bound SDL display window
3
- *
4
- * --
5
- * Rubygame -- Ruby code and bindings to SDL to facilitate game creation
6
- * Copyright (C) 2004-2007 John Croisant
7
- *
8
- * This library is free software; you can redistribute it and/or
9
- * modify it under the terms of the GNU Lesser General Public
10
- * License as published by the Free Software Foundation; either
11
- * version 2.1 of the License, or (at your option) any later version.
12
- *
13
- * This library is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
- * Lesser General Public License for more details.
17
- *
18
- * You should have received a copy of the GNU Lesser General Public
19
- * License along with this library; if not, write to the Free Software
20
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
- * ++
22
- */
23
-
24
- #include "rubygame_shared.h"
25
- #include "rubygame_screen.h"
26
- #include "rubygame_surface.h"
27
-
28
- void Rubygame_Init_Screen();
29
-
30
- VALUE cScreen;
31
-
32
- VALUE rbgm_screen_setmode(int, VALUE*, VALUE);
33
- VALUE rbgm_screen_getsurface(VALUE);
34
-
35
- VALUE rbgm_screen_getresolution(VALUE);
36
-
37
- VALUE rbgm_screen_getcaption(VALUE);
38
- VALUE rbgm_screen_setcaption(VALUE, VALUE);
39
-
40
- VALUE rbgm_screen_seticon(VALUE, VALUE);
41
-
42
- VALUE rbgm_screen_update(int, VALUE*, VALUE);
43
- VALUE rbgm_screen_updaterects(VALUE, VALUE);
44
- VALUE rbgm_screen_flip(VALUE);
45
-
46
- VALUE rbgm_screen_getshowcursor(VALUE);
47
- VALUE rbgm_screen_setshowcursor(VALUE, VALUE);
48
-
49
-
50
- /* call-seq:
51
- * Screen.new( size, depth=0, flags=[SWSURFACE] ) -> Screen
52
- * (alias: open)
53
- *
54
- * Create a new Rubygame window if there is none, or modify the existing one.
55
- * You cannot create more than one Screen; the existing one will be replaced.
56
- * (This is a limitation of SDL.)
57
- * Returns the resulting Screen.
58
- *
59
- * This method takes these arguments:
60
- * size:: requested window size (in pixels), in the form [width,height]
61
- * depth:: requested color depth (in bits per pixel). If 0 (default), the
62
- * current system color depth.
63
- * flags:: an Array of zero or more of the following flags (located under the
64
- * Rubygame module).
65
- *
66
- * SWSURFACE:: Create the video surface in system memory.
67
- * HWSURFACE:: Create the video surface in video memory.
68
- * ASYNCBLIT:: Enables the use of asynchronous updates of the
69
- * display surface. This will usually slow down
70
- * blitting on single CPU machines, but may provide a
71
- * speed increase on SMP systems.
72
- * ANYFORMAT:: Normally, if a video surface of the requested
73
- * bits-per-pixel (bpp) is not available, Rubygame
74
- * will emulate one with a shadow surface. Passing
75
- * +ANYFORMAT+ prevents this and causes Rubygame to
76
- * use the video surface regardless of its depth.
77
- * DOUBLEBUF:: Enable hardware double buffering; only valid with
78
- * +HWSURFACE+. Calling #flip will flip the
79
- * buffers and update the screen. All drawing will
80
- * take place on the surface that is not displayed at
81
- * the moment. If double buffering could not be
82
- * enabled then #flip will just update the
83
- * entire screen.
84
- * FULLSCREEN:: Rubygame will attempt to use a fullscreen mode. If
85
- * a hardware resolution change is not possible (for
86
- * whatever reason), the next higher resolution will
87
- * be used and the display window centered on a black
88
- * background.
89
- * OPENGL:: Create an OpenGL rendering context. You must set
90
- * proper OpenGL video attributes with GL#set_attrib
91
- * before calling this method with this flag. You can
92
- * then use separate opengl libraries (for example rbogl)
93
- * to do all OpenGL-related functions.
94
- * Please note that you can't blit or draw regular SDL
95
- * Surfaces onto an OpenGL-mode screen; you must use
96
- * OpenGL functions.
97
- * RESIZABLE:: Create a resizable window. When the window is
98
- * resized by the user, a ResizeEvent is
99
- * generated and this method can be called again
100
- * with the new size.
101
- * NOFRAME:: If possible, create a window with no title bar or
102
- * frame decoration.
103
- * Fullscreen modes automatically have this flag set.
104
- */
105
- VALUE rbgm_screen_new(int argc, VALUE *argv, VALUE module)
106
- {
107
- SDL_Surface *screen;
108
- int w, h, depth;
109
- Uint32 flags;
110
- VALUE vsize, vdepth, vflags;
111
-
112
- rb_scan_args(argc, argv, "12", &vsize, &vdepth, &vflags);
113
-
114
- vsize = convert_to_array(vsize);
115
- w = NUM2INT(rb_ary_entry(vsize,0));
116
- h = NUM2INT(rb_ary_entry(vsize,1));
117
-
118
- depth = 0;
119
- if( RTEST(vdepth) )
120
- {
121
- depth = NUM2INT(vdepth);
122
- }
123
-
124
- flags = collapse_flags(vflags); /* in rubygame_shared */
125
-
126
- screen = SDL_SetVideoMode( w,h,depth,flags );
127
-
128
- if( screen==NULL )
129
- {
130
- rb_raise(eSDLError,"Couldn't set [%d x %d] %d bpp video mode: %s",
131
- w, h, depth, SDL_GetError());
132
- }
133
- //format = screen->format;
134
- //printf("New screen will be: %dx%d, %d bpp. Masks: %d, %d, %d, %d\n",w,h,depth,format->Rmask,format->Gmask,format->Bmask,format->Amask);
135
- return Data_Wrap_Struct( cScreen,0,0,screen );
136
- }
137
-
138
-
139
- /* call-seq:
140
- * Screen.set_mode( size, depth=0, flags=[SWSURFACE] ) -> Screen
141
- *
142
- * Deprecated alias for Screen.new. This method will be REMOVED
143
- * in Rubygame 3.0. You should use Screen.new (or its alias, Screen.open)
144
- * instead.
145
- */
146
- VALUE rbgm_screen_setmode(int argc, VALUE *argv, VALUE module)
147
- {
148
- rg_deprecated("Rubygame::Screen.set_mode", "3.0");
149
- return rbgm_screen_new(argc, argv, module);
150
- }
151
-
152
- /* call-seq:
153
- * Screen.instance( size, depth=0, flags=[SWSURFACE] ) -> Screen
154
- *
155
- * Deprecated alias for Screen.new. This method will be REMOVED
156
- * in Rubygame 3.0. You should use Screen.new (or its alias, Screen.open)
157
- * instead.
158
- */
159
- VALUE rbgm_screen_instance(int argc, VALUE *argv, VALUE module)
160
- {
161
- rg_deprecated("Rubygame::Screen.instance", "3.0");
162
- return rbgm_screen_new(argc, argv, module);
163
- }
164
-
165
-
166
- /*
167
- * call-seq:
168
- * Screen.close
169
- *
170
- * Close the Screen, making the Rubygame window disappear.
171
- * This method also exits from fullscreen mode, if needed.
172
- *
173
- * After calling this method, you should discard any references
174
- * to the old Screen surface, as it is no longer valid, even
175
- * if you call Screen.new again.
176
- *
177
- * (Note: You do not need to close the Screen to change its size
178
- * or flags, you can simply call Screen.new while already open.)
179
- *
180
- */
181
- VALUE rbgm_screen_close(VALUE module)
182
- {
183
- SDL_QuitSubSystem(SDL_INIT_VIDEO);
184
- return Qnil;
185
- }
186
-
187
-
188
- /*
189
- * call-seq:
190
- * Screen.open?
191
- *
192
- * True if there is an open Rubygame window.
193
- * See Screen.new and Screen.close.
194
- *
195
- */
196
- VALUE rbgm_screen_openp(VALUE module)
197
- {
198
- return (SDL_GetVideoSurface() == NULL) ? Qfalse : Qtrue;
199
- }
200
-
201
-
202
-
203
- /* call-seq:
204
- * Screen.get_surface
205
- *
206
- * Returns the current display window, or raises SDLError if it
207
- * fails to get it (for example, if it doesn't exist yet).
208
- */
209
- VALUE rbgm_screen_getsurface(VALUE module)
210
- {
211
- SDL_Surface *surface;
212
- surface = SDL_GetVideoSurface();
213
- if(surface==NULL)
214
- {
215
- rb_raise(eSDLError,"Couldn't get video surface: %s",SDL_GetError());
216
- }
217
- return Data_Wrap_Struct( cScreen,0,0,surface );
218
- }
219
-
220
-
221
- /* call-seq:
222
- * Screen.get_resolution -> [width, height]
223
- *
224
- * Returns the pixel dimensions of the user's display (i.e. monitor).
225
- * (That is not the same as Screen#size, which only measures the
226
- * Rubygame window.) You can use this information to detect
227
- * how large of a Screen can fit on the user's display.
228
- *
229
- * This method can _only_ be used when there is no open Screen instance.
230
- * This method raises SDLError if there is a Screen instance (i.e.
231
- * you have done Screen.new before). This is a limitation of the SDL
232
- * function SDL_GetVideoInfo, which behaves differently when a Screen
233
- * is open than when it is closed.
234
- *
235
- * This method will also raise SDLError if it cannot get the display
236
- * size for some other reason.
237
- *
238
- */
239
- VALUE rbgm_screen_getresolution(VALUE module)
240
- {
241
- VALUE array;
242
- const SDL_VideoInfo* hw;
243
- init_video_system();
244
-
245
- /* Test for existing Screen */
246
- SDL_Surface *surface;
247
- surface = SDL_GetVideoSurface();
248
- if(surface != NULL)
249
- {
250
- rb_raise(eSDLError, "You cannot get resolution when there is " \
251
- "an open Screen. See the docs for the reason.");
252
- }
253
-
254
- hw = SDL_GetVideoInfo();
255
- if(hw==NULL)
256
- {
257
- rb_raise(eSDLError,"Couldn't get video info: %s",SDL_GetError());
258
- }
259
-
260
- array = rb_ary_new();
261
- rb_ary_push(array, INT2NUM(hw->current_w));
262
- rb_ary_push(array, INT2NUM(hw->current_h));
263
- return array;
264
- }
265
-
266
-
267
- /* Screen instance methods: */
268
-
269
-
270
- /* call-seq:
271
- * title -> String
272
- *
273
- * Returns the current window title for the Screen.
274
- * The default is an empty string.
275
- */
276
- VALUE rbgm_screen_getcaption(VALUE self)
277
- {
278
- char *title,*icon;
279
-
280
- SDL_WM_GetCaption( &title,&icon );
281
- if (title == NULL)
282
- title = "\0";
283
- /* We don't really care about icon. */
284
- return rb_str_new2(title);
285
- }
286
-
287
- /* call-seq:
288
- * title = title
289
- *
290
- * Sets the window title for the Screen.
291
- *
292
- * title:: a String, (usually) displayed at the top of the Rubygame
293
- * window (when not in fullscreen mode). If omitted or +nil+,
294
- * +title+ will be an empty string.
295
- * How this string is displayed (if at all) is system-dependent.
296
- */
297
- VALUE rbgm_screen_setcaption(VALUE self, VALUE title)
298
- {
299
- char *title_str;
300
- title_str = ""; /* default to blank */
301
-
302
- if( RTEST(title) )
303
- {
304
- title_str = StringValuePtr(title);
305
- }
306
- SDL_WM_SetCaption(title_str,title_str);
307
- return self;
308
- }
309
-
310
- /* call-seq:
311
- * icon = icon
312
- *
313
- * Sets the window icon for the Screen.
314
- *
315
- * icon:: a Rubygame::Surface to be displayed at the top of the Rubygame
316
- * window (when not in fullscreen mode), and in other OS-specific
317
- * areas (like the taskbar entry). If omitted or +nil+, no icon
318
- * will be shown at all.
319
- *
320
- * NOTE: The SDL docs state that icons on Win32 systems must be 32x32 pixels.
321
- * That may or may not be true anymore, but you might want to consider it
322
- * when creating games to run on Windows.
323
- *
324
- */
325
- VALUE rbgm_screen_seticon(VALUE self, VALUE data)
326
- {
327
- SDL_Surface *icon;
328
-
329
- Data_Get_Struct(data, SDL_Surface, icon);
330
- SDL_WM_SetIcon(icon, NULL);
331
-
332
- return self;
333
- }
334
-
335
- /* call-seq:
336
- * update()
337
- * update(rect)
338
- * update(x,y,w,h)
339
- *
340
- * Updates (refreshes) all or part of the Rubygame window, revealing to the
341
- * user any changes that have been made since the last update. If you're using
342
- * a double-buffered display (see Screen.new), you should use
343
- * Screen#flip instead.
344
- *
345
- * This method takes these arguments:
346
- * rect:: a Rubygame::Rect representing the area of the screen to update.
347
- * Can also be an length-4 Array, or given as 4 separate arguments.
348
- * If omitted or nil, the entire screen is updated.
349
- */
350
- VALUE rbgm_screen_update(int argc, VALUE *argv, VALUE self)
351
- {
352
- int x,y,w,h;
353
- SDL_Surface *screen;
354
- Data_Get_Struct(self,SDL_Surface,screen);
355
- VALUE vx, vy, vw, vh;
356
-
357
- rb_scan_args(argc, argv, "04", &vx, &vy, &vw, &vh);
358
-
359
- x = y = w = h = 0;
360
-
361
- if( RTEST(vx) )
362
- {
363
- switch( TYPE(vx) ) {
364
- case T_ARRAY: {
365
- if( RARRAY_LEN(vx) < 4 )
366
- {
367
- rb_raise(rb_eArgError,"Array is too short to be a Rect (%s for 4)",
368
- RARRAY_LEN(vx));
369
- }
370
- x = NUM2INT(rb_ary_entry(vx,0));
371
- y = NUM2INT(rb_ary_entry(vx,1));
372
- w = NUM2INT(rb_ary_entry(vx,2));
373
- h = NUM2INT(rb_ary_entry(vx,3));
374
- break;
375
- }
376
- case T_FLOAT:
377
- case T_BIGNUM:
378
- case T_FIXNUM: {
379
- x = NUM2INT(vx);
380
- y = NUM2INT(vy);
381
- w = NUM2INT(vw);
382
- h = NUM2INT(vh);
383
- break;
384
- }
385
- default: {
386
- rb_raise(rb_eTypeError,"Unrecognized type for x (wanted Array or Numeric).");
387
- break;
388
- }
389
- }
390
- }
391
-
392
- Sint16 left,top,right,bottom;
393
-
394
- left = min( max( 0, x ), screen->w );
395
- top = min( max( 0, y ), screen->h );
396
- right = min( max( left, x + w), screen->w );
397
- bottom = min( max( top, y + h), screen->h );
398
-
399
- x = left;
400
- y = top;
401
- w = right - left;
402
- h = bottom - top;
403
-
404
- SDL_UpdateRect(screen,x,y,w,h);
405
- return self;
406
- }
407
-
408
- /* call-seq:
409
- * update_rects(rects)
410
- *
411
- * Updates (as Screen#update does) several areas of the screen.
412
- *
413
- * This method takes these arguments:
414
- * rects:: an Array containing any number of Rect objects, each
415
- * rect representing a portion of the screen to update.
416
- */
417
- VALUE rbgm_screen_updaterects(VALUE self, VALUE array_rects)
418
- {
419
- int i, num_rects;
420
- VALUE each_rect;
421
- SDL_Surface *screen;
422
- SDL_Rect *rects;
423
-
424
- /* unwrap the Screen instance from self (VALUE) */
425
- Data_Get_Struct(self,SDL_Surface,screen);
426
-
427
- /* prepare an (uninitialized) array of Rects */
428
- array_rects = convert_to_array(array_rects);
429
- num_rects = RARRAY_LEN(array_rects);
430
- rects = ALLOCA_N(SDL_Rect, num_rects);
431
-
432
- /* initialize the array of Rects from array_rects */
433
- for( i=0; i < num_rects; i++ )
434
- {
435
- each_rect = convert_to_array(rb_ary_entry(array_rects,i));
436
-
437
- Sint16 x,y,left,top,right,bottom;
438
- Uint16 w,h;
439
-
440
- x = NUM2INT(rb_ary_entry(each_rect,0));
441
- y = NUM2INT(rb_ary_entry(each_rect,1));
442
- w = NUM2INT(rb_ary_entry(each_rect,2));
443
- h = NUM2INT(rb_ary_entry(each_rect,3));
444
-
445
- left = min( max( 0, x ), screen->w );
446
- top = min( max( 0, y ), screen->h );
447
- right = min( max( left, x + w), screen->w );
448
- bottom = min( max( top, y + h), screen->h );
449
-
450
- rects[i].x = left;
451
- rects[i].y = top;
452
- rects[i].w = right - left;
453
- rects[i].h = bottom - top;
454
- }
455
-
456
- /* call the SDL method to update from all these rects */
457
- SDL_UpdateRects( screen, num_rects, rects );
458
-
459
- return self;
460
- }
461
-
462
- /* call-seq:
463
- * flip()
464
- *
465
- * If the Rubygame display is double-buffered (see Screen.new), flips
466
- * the buffers and updates the whole screen. Otherwise, just updates the
467
- * whole screen.
468
- */
469
- VALUE rbgm_screen_flip(VALUE self)
470
- {
471
- SDL_Surface *screen;
472
- Data_Get_Struct(self, SDL_Surface, screen);
473
- SDL_Flip(screen);
474
- return self;
475
- }
476
-
477
- /* call-seq:
478
- * show_cursor? -> true or false
479
- *
480
- * Returns true if the mouse cursor is shown, or false if hidden. See also
481
- * #show_cursor=
482
- */
483
- VALUE rbgm_screen_getshowcursor(VALUE self)
484
- {
485
- return SDL_ShowCursor(SDL_QUERY);
486
- }
487
-
488
- /* call-seq:
489
- * show_cursor = value -> true or false or nil
490
- *
491
- * Set whether the mouse cursor is displayed or not. If +value+ is true,
492
- * the cursor will be shown; if false, it will be hidden. See also
493
- * #show_cursor?
494
- */
495
- VALUE rbgm_screen_setshowcursor(VALUE self, VALUE val)
496
- {
497
- int state;
498
-
499
- if(val == Qtrue) { state = SDL_ENABLE; }
500
- else if(val == Qfalse || val == Qnil) { state = SDL_DISABLE; }
501
- else { return Qnil; }
502
-
503
- return SDL_ShowCursor(state);
504
- }
505
-
506
- /*
507
- * Document-class: Rubygame::Screen
508
- *
509
- * Screen represents the display window for the game. The Screen is a
510
- * special Surface that is displayed to the user. By changing and then
511
- * updating the Screen many times per second, we can create the illusion
512
- * of continous motion.
513
- *
514
- * Screen inherits most of the Surface methods, and can be passed to methods
515
- * which expect a Surface, including Surface#blit and the Draw functions.
516
- * However, the Screen cannot have a colorkey or an alpha channel, so
517
- * Surface#set_colorkey and Surface#set_alpha are not inherited.
518
- *
519
- * Please note that only *one* Screen can exist, per application, at a time;
520
- * this is a limitation of SDL. You *must* use Screen.new (or its alias,
521
- * Screen.open) to create or modify the Screen.
522
- *
523
- * Also note that no changes to the Screen will be seen until it is refreshed.
524
- * See #update, #update_rects, and #flip for ways to refresh all or part of
525
- * the Screen.
526
- *
527
- */
528
- void Rubygame_Init_Screen()
529
- {
530
- #if 0
531
- mRubygame = rb_define_module("Rubygame");
532
- cSurface = rb_define_class_under(mRubygame,"Surface",rb_cObject);
533
- #endif
534
-
535
- /* Screen class */
536
- cScreen = rb_define_class_under(mRubygame,"Screen",cSurface);
537
- rb_define_singleton_method(cScreen,"new",rbgm_screen_new, -1);
538
- rb_define_alias(rb_singleton_class(cScreen),"open","new");
539
-
540
- rb_define_singleton_method(cScreen,"close", rbgm_screen_close, 0);
541
- rb_define_singleton_method(cScreen,"open?", rbgm_screen_openp, 0);
542
- rb_define_singleton_method(cScreen,"get_surface",rbgm_screen_getsurface, 0);
543
- rb_define_singleton_method(cScreen,"get_resolution",rbgm_screen_getresolution, 0);
544
-
545
- /* Deprecated: */
546
- rb_define_singleton_method(cScreen,"set_mode", rbgm_screen_setmode, -1);
547
- rb_define_singleton_method(cScreen,"instance", rbgm_screen_instance, -1);
548
-
549
-
550
-
551
- /* These are inherited from Surface, but should not be called on Screen */
552
- rb_undef_method(cScreen,"set_alpha");
553
- rb_undef_method(cScreen,"set_colorkey");
554
-
555
- /* Screen methods */
556
- rb_define_method(cScreen,"title",rbgm_screen_getcaption,0);
557
- rb_define_method(cScreen,"title=",rbgm_screen_setcaption,1);
558
- rb_define_method(cScreen,"icon=",rbgm_screen_seticon,1);
559
- rb_define_method(cScreen,"update",rbgm_screen_update,-1);
560
- rb_define_method(cScreen,"update_rects",rbgm_screen_updaterects,1);
561
- rb_define_method(cScreen,"flip",rbgm_screen_flip,0);
562
- rb_define_method(cScreen,"show_cursor?",rbgm_screen_getshowcursor,0);
563
- rb_define_method(cScreen,"show_cursor=",rbgm_screen_setshowcursor,1);
564
-
565
- /* Screen initialization flags */
566
- rb_define_const(mRubygame,"DOUBLEBUF",UINT2NUM(SDL_DOUBLEBUF));
567
- rb_define_const(mRubygame,"FULLSCREEN",UINT2NUM(SDL_FULLSCREEN));
568
- rb_define_const(mRubygame,"OPENGL",UINT2NUM(SDL_OPENGL));
569
- rb_define_const(mRubygame,"OPENGLBLIT",UINT2NUM(SDL_OPENGLBLIT));
570
- rb_define_const(mRubygame,"RESIZABLE",UINT2NUM(SDL_RESIZABLE));
571
- rb_define_const(mRubygame,"NOFRAME",UINT2NUM(SDL_NOFRAME));
572
- }