rubygame 2.3.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/CREDITS CHANGED
@@ -58,3 +58,8 @@
58
58
  Email:: mokkan at users.sourceforge.net
59
59
  Contribution:: Patch to add Screen.icon=
60
60
  Date:: 2007-11-21 (r597)
61
+
62
+ - <b>Elio Cuevas Gómez</b> / elcugo
63
+ Email:: elcugo at gmail.com
64
+ Contribution:: Patch to fix color conversion segfault on x86_64.
65
+ Date:: 2008-07-31
data/NEWS CHANGED
@@ -1,5 +1,93 @@
1
1
  = NEWS
2
2
 
3
+ == Rubygame 2.4.0
4
+
5
+ Release focus: Events.
6
+
7
+ === Features
8
+
9
+ - New Events module, with a suite of new and revised event classes.
10
+ The new classes offer full functionality as the older classes.
11
+
12
+ - Use Rubygame::EventQueue#enable_new_style_events to enable the new
13
+ event classes. This will become the default in Rubygame 3.0.
14
+
15
+ - Uses symbols instead of integer constants for keyboard keys and
16
+ mouse buttons (e.g. :a, :space, :mouse_left, :mouse_right).
17
+
18
+ - Better unicode / international keyboard text input support.
19
+ (See Rubygame::Events::KeyPressed#string)
20
+
21
+ - More natural and memorable class naming scheme.
22
+
23
+ - New hook-based event handling system.
24
+ (NOTE: Requires use of the new event classes.)
25
+
26
+ - Rubygame::EventHandler class.
27
+ EventHandler holds many EventHook instances. It handles each event
28
+ by passing it to matching hooks.
29
+
30
+ - Rubygame::EventHandler::HasEventHandler mixin module.
31
+ Include this in your custom classes to add easy event handling
32
+ and event hook creation abilities.
33
+
34
+ - Rubygame::EventHook class.
35
+
36
+ - Rubygame::EventActions module.
37
+ Has several pre-made event action classes to use with EventHook.
38
+
39
+ - Rubygame::EventTriggers module.
40
+ Has several pre-made event trigger classes to use with EventHook.
41
+
42
+ - Added Rubygame.enable_key_repeat and Rubygame.disable_key_repeat.
43
+ Thanks to atiaxi for this new feature!
44
+
45
+ === Fixes
46
+
47
+ - Fixed: EventQueue#peek_each didn't yield any events.
48
+
49
+ - Fixed: Segfault in extract_rgba_u8_as_u8() on x86_64 systems.
50
+ Thanks to ElCuGo for this fix!
51
+
52
+ - Fixed: Several "cast from pointer" warnings on x86_64 systems.
53
+
54
+ - Fixed: Build system didn't correctly compile with debug symbols
55
+ when using "debug" option.
56
+
57
+ - Fixed: Surface#get_at didn't work correctly for 8-bit Surfaces.
58
+
59
+ - Fixed: Ftor.new_from_to would always complain about "wrong number
60
+ of arguments". Thanks to atiaxi for this fix!
61
+
62
+ === Other Stuff
63
+
64
+ - The panda demo (samples/demo_rubygame.rb) has been renovated to
65
+ demonstrate how to use the new features, and to be a better example.
66
+
67
+ - Old event classes are deprecated and will be removed in 3.0.
68
+ - ActiveEvent (use Events::InputFocusGained,
69
+ Events::InputFocusLost,
70
+ Events::MouseFocusGained,
71
+ Events::MouseFocusLost,
72
+ Events::WindowMinimized, and
73
+ Events::WindowUnminimized)
74
+ - ExposeEvent (use Events::WindowExposed)
75
+ - JoyAxisEvent (use Events::JoystickAxisMoved)
76
+ - JoyBallEvent (use Events::JoystickBallMoved)
77
+ - JoyDownEvent (use Events::JoystickButtonPressed)
78
+ - JoyHatEvent (use Events::JoystickHatMoved)
79
+ - JoyUpEvent (use Events::JoystickButtonReleased)
80
+ - KeyDownEvent (use Events::KeyPressed)
81
+ - KeyUpEvent (use Events::KeyReleased)
82
+ - MouseDownEvent (use Events::MousePressed)
83
+ - MouseMotionEvent (use Events::MouseMoved)
84
+ - MouseUpEvent (use Events::MouseReleased)
85
+ - QuitEvent (use Events::QuitRequested)
86
+ - ResizeEvent (use Events::WindowResized)
87
+
88
+
89
+
90
+
3
91
  == Rubygame 2.3.0
4
92
 
5
93
  Release focus: Media resources.
data/README CHANGED
@@ -13,7 +13,7 @@
13
13
  event and game object management.
14
14
 
15
15
  === Relevant Links
16
- 1. Rubygame: http://rubygame.sourceforge.net
16
+ 1. Rubygame: http://rubygame.org
17
17
  2. Ruby: http://www.ruby-lang.org
18
18
  3. Pygame: http://www.pygame.org
19
19
  4. SDL: http://www.libsdl.org
@@ -106,18 +106,22 @@
106
106
 
107
107
  == Usage
108
108
 
109
- See the documentation (online at http://rubygame.sourceforge.net, or
109
+ See the documentation (online at http://docs.rubygame.org, or
110
110
  generated locally with the 'rake rdoc' command).
111
111
 
112
112
  We also recommend that you take a peek at the demo applications in
113
- the 'samples' directory, especially chimp.rb.
113
+ the 'samples' directory, especially demo_rubygame.rb and chimp.rb.
114
114
 
115
115
  == License
116
116
 
117
117
  Rubygame is distributed under the terms of the GNU Lesser GPL.
118
118
  See LICENSE for more details.
119
119
 
120
+ The contents of the file 'Rakefile' is licensed under the terms of the
121
+ MIT license. See that file for more details.
122
+
120
123
  Some of the sample files are distributed under licenses other than the
121
124
  GNU Lesser GPL. See 'samples/README' and 'samples/GPL' for more details.
122
125
 
123
- John Croisant (jacius at users.sourceforge.net)
126
+
127
+ John Croisant (jacius at gmail.com)
data/ROADMAP CHANGED
@@ -4,55 +4,33 @@ This represents the direction Rubygame will be going in, but
4
4
  keep in mind that specific details may change over time.
5
5
 
6
6
 
7
- == 2.4.0 (next minor release)
8
-
9
- Release focus: Events.
10
-
11
- - New EventHook class, has 3 parts: owner, trigger, and action.
12
- - New trigger classes, e.g. KeyPressedTrigger (matches key presses)
13
- - New action classes, e.g. MethodAction (calls a method on owner)
14
-
15
- - New EventHandler class
16
- - Holds many EventHook instances, feeds the event to each
17
- matching hook.
18
-
19
- - New HasEventHandler mixin, can embed in sprite, etc. classes
20
- for easy event handling and hook creation.
21
-
22
- - New Events module, with a suite of new and revised event classes.
23
-
24
- - Eliminate integer constants in favor of symbols
25
- - Keyboard keys are symbols (e.g. :up, :a, :space)
26
- - Mouse buttons are symbols (e.g. :mouse_left, :mouse_wheel_up)
27
-
28
- - Nicer, more natural naming scheme
29
- - Drop the word "Event" from the class names.
30
- - "Down" and "Up" (e.g. in KeyDownEvent) become "Pressed"
31
- and "Released" (e.g. KeyPressed).
32
- - MouseMotionEvent becomes MouseMoved.
33
- - Other miscellaneous changes.
34
-
35
- - Better unicode / international keyboard support
36
- - KeyPress#string gives a UTF8 bytestring with the glyph that was
37
- generated by the keypress (useful for text input in GUIs).
38
-
39
- - Old versions of the event classes stay the same, but are deprecated.
40
-
41
-
42
-
43
7
  == 2.X.0 (_possible_ minor releases before 3.0.0)
44
8
 
45
- === Focus: Time
9
+ === Focus: Clock
46
10
 
47
- - New Events::Tick class with lots of information
48
- - Time since last frame, in both seconds and milliseconds.
11
+ - New Events::ClockTicked class with lots of information
12
+ - Time since last frame, in both seconds and milliseconds
49
13
  - Current time
50
14
  - Current framerate
51
15
 
52
16
  - New clock class
53
- - Based on Ruby's timer (allows multi-threading).
17
+ - Based on Ruby's timer (allows multi-threading)
54
18
  - Better framerate calculation algorithm
55
- - #tick returns an instance of Events::Tick.
19
+ - #tick returns an instance of Events::Tick
20
+
21
+
22
+ === Focus: Surface & Rect
23
+
24
+ - Surface improvements
25
+ - Make Surface instances copyable and marshalable
26
+ - Support for palettes on 8-bit Surfaces
27
+ - To Fix: New Surfaces never have alpha channels
28
+ - To Fix: Surface#set_at doesn't respect alpha
29
+ - To Add: Surface#pixels= (set pixel data directly)
30
+ - To Add: Surface.load_from_pixels (create from pixel data)
31
+
32
+ - Rewrite Rect class in C for speed
33
+
56
34
 
57
35
  === Focus: Sprites
58
36
 
@@ -105,5 +83,3 @@ Release focus: Events.
105
83
  - Screen#update (cannot pass object with rect attribute)
106
84
  - Screen#update_rects (same as above)
107
85
  - Why not just call the ruby function from within C?
108
-
109
-
data/Rakefile CHANGED
@@ -1,3 +1,41 @@
1
+ #
2
+ # This is the Rakefile for Rubygame. It's used for
3
+ # compiling, packaging, installing generating the
4
+ # documentation, and running specs.
5
+ #
6
+
7
+
8
+ # The version number for Rubygame.
9
+ RUBYGAME_VERSION = [2,4,0]
10
+
11
+
12
+ #
13
+ # The following terms (the MIT license) apply to this Rakefile:
14
+ #
15
+ # Copyright (c) 2008 John Croisant
16
+ #
17
+ # Permission is hereby granted, free of charge, to any person
18
+ # obtaining a copy of this software and associated documentation files
19
+ # (the "Software"), to deal in the Software without restriction,
20
+ # including without limitation the rights to use, copy, modify, merge,
21
+ # publish, distribute, sublicense, and/or sell copies of the Software,
22
+ # and to permit persons to whom the Software is furnished to do so,
23
+ # subject to the following conditions:
24
+ #
25
+ # The above copyright notice and this permission notice shall be
26
+ # included in all copies or substantial portions of the Software.
27
+ #
28
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
32
+ # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
33
+ # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
34
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35
+ # SOFTWARE.
36
+ #
37
+
38
+
1
39
  require 'rubygems'
2
40
  Gem::manage_gems
3
41
 
@@ -48,14 +86,12 @@ end
48
86
  OBJEXT = from_env_or_config("OBJEXT")
49
87
  DLEXT = from_env_or_config("DLEXT")
50
88
 
51
- RUBYGAME_VERSION = [2,3,0]
52
-
53
89
  gem_spec = Gem::Specification.new do |s|
54
90
  s.name = "rubygame"
55
91
  s.version = RUBYGAME_VERSION.join(".")
56
92
  s.author = "John Croisant"
57
- s.email = "jacius@users.sourceforge.net"
58
- s.homepage = "http://rubygame.sourceforge.net/"
93
+ s.email = "jacius@gmail.com"
94
+ s.homepage = "http://rubygame.org/"
59
95
  s.summary = "Clean and powerful library for game programming"
60
96
  s.has_rdoc = true
61
97
 
@@ -192,7 +228,6 @@ string_option :sitelibdir
192
228
  CFLAGS = [from_env_or_config("CFLAGS"),
193
229
  try_sdl_config("--cflags"),
194
230
  "-I. -I#{CONFIG['topdir']}",
195
- ("-g" if $options[:debug]),
196
231
  "-DRUBYGAME_MAJOR_VERSION=#{RUBYGAME_VERSION[0]}",
197
232
  "-DRUBYGAME_MINOR_VERSION=#{RUBYGAME_VERSION[1]}",
198
233
  "-DRUBYGAME_PATCHLEVEL=#{RUBYGAME_VERSION[2]}"
@@ -283,7 +318,7 @@ class ExtensionModule
283
318
  ])\
284
319
  do |t|
285
320
 
286
- compile_command = "#{from_env_or_config('CC')} -c #{CFLAGS} #{t.source} -o #{t.name}"
321
+ compile_command = "#{from_env_or_config('CC')} -c #{CFLAGS} #{"-g " if $options[:debug]} #{t.source} -o #{t.name}"
287
322
 
288
323
  # If compile command includes i386 arch, and we're not allowing universal
289
324
  if( /-arch i386/ === compile_command and not $options[:universal] )
@@ -303,7 +338,7 @@ class ExtensionModule
303
338
  FileList.new("#{@directory}*.c").each do |source|
304
339
  object = source.sub(".c", ".#{OBJEXT}")
305
340
  file object => ([source] + depends_headers( source )) do |t|
306
- compile_command = "#{CONFIG['CC']} -c #{CFLAGS} #{source} -o #{t.name}"
341
+ compile_command = "#{CONFIG['CC']} -c #{CFLAGS} #{"-g " if $options[:debug]} #{source} -o #{t.name}"
307
342
  if( $options[:verbose] )
308
343
  try_shell { sh compile_command }
309
344
  else
@@ -334,6 +369,7 @@ rubygame_core = ExtensionModule.new do |core|
334
369
  core.objs = ['rubygame_main',
335
370
  'rubygame_shared',
336
371
  'rubygame_event',
372
+ 'rubygame_event2',
337
373
  'rubygame_gl',
338
374
  'rubygame_joystick',
339
375
  'rubygame_screen',
@@ -424,15 +460,63 @@ task :install => [:install_ext, :install_lib]
424
460
 
425
461
 
426
462
 
463
+ #########
464
+ # SPECS #
465
+ #########
466
+
427
467
  begin
428
468
  require 'spec/rake/spectask'
429
469
 
430
- desc "Run all specs (tests)"
470
+
471
+ desc "Run all specs"
431
472
  Spec::Rake::SpecTask.new do |t|
432
- t.spec_files = FileList['test/*_spec.rb']
473
+ t.spec_files = FileList['spec/*_spec.rb']
433
474
  end
475
+
476
+
477
+ namespace :spec do
478
+ desc "Run all specs"
479
+ Spec::Rake::SpecTask.new(:all) do |t|
480
+ t.spec_files = FileList['spec/*_spec.rb']
481
+ end
482
+
483
+ desc "Run spec/[name]_spec.rb (e.g. 'color')"
484
+ task :name do
485
+ puts( "This is just a stand-in spec.",
486
+ "Run rake spec:[name] where [name] is e.g. 'color', 'music'." )
487
+ end
488
+ end
489
+
490
+
491
+ rule(/spec:.+/) do |t|
492
+ name = t.name.gsub("spec:","")
493
+
494
+ path = File.join( File.dirname(__FILE__),'spec','%s_spec.rb'%name )
495
+
496
+ if File.exist? path
497
+ Spec::Rake::SpecTask.new(name) do |t|
498
+ t.spec_files = [path]
499
+ end
500
+
501
+ puts "\nRunning spec/%s_spec.rb"%name
502
+
503
+ Rake::Task[name].invoke
504
+ else
505
+ puts "File does not exist: %s"%path
506
+ end
507
+
508
+ end
509
+
434
510
  rescue LoadError
511
+
512
+ error = "ERROR: RSpec is not installed?"
513
+
435
514
  task :spec do
436
- puts "ERROR: RSpec is not installed?"
515
+ puts error
516
+ end
517
+
518
+ rule( /spec:.*/ ) do
519
+ puts error
437
520
  end
521
+
438
522
  end
@@ -48,7 +48,7 @@ In order to use Rubygame applications on Mac OS X, you must use a special wrappe
48
48
 
49
49
 
50
50
  == Installing Rubygame
51
- 1. {Download and unpack Rubygame}[https://sourceforge.net/project/showfiles.php?group_id=172781].
51
+ 1. {Download and unpack Rubygame}[http://rubyforge.org/frs/?group_id=5089].
52
52
  2. From within the rubygame directory:
53
53
 
54
54
  sudo rake install
@@ -61,7 +61,7 @@ In order to use Rubygame applications on Mac OS X, you must use a special wrappe
61
61
  If all went well, you can now run Rubygame applications like so:
62
62
  <code>rsdl a_rubygame_app.rb</code>
63
63
 
64
- If something bad happened along the way, you can {submit a support request}[https://sourceforge.net/tracker/?func=add&group_id=172781&atid=862995]
64
+ If something bad happened along the way, you can {email rubygame-users}[https://sourceforge.net/mail/?group_id=172781]
65
65
  and we'll try to help! Be sure to include plenty of details and paste any error
66
66
  messages that occur (plus a good bit of the text right before the error
67
67
  messages).
@@ -63,9 +63,9 @@ This will allow the libraries to be detected properly later on.
63
63
  == Step 2: Get Rubygame
64
64
 
65
65
  If you haven't already, download the latest Rubygame source from the
66
- {download page}[http://sourceforge.net/project/showfiles.php?group_id=172781].
66
+ {download page}[http://rubyforge.org/frs/?group_id=5089].
67
67
  If you're feeling adventurous, you could try the in-development code from
68
- the {Subversion repository}[http://sourceforge.net/svn/?group_id=172781].
68
+ the {Git repository}[http://github.com/jacius/rubygame].
69
69
  You can decompress the .tar.bz2 file with either MSYS' <code>tar</code>
70
70
  (<code>tar xvjf rubygame-2.0.0.tar.bz2</code>) or a program like
71
71
  {7zip}[http://www.7-zip.org].
@@ -22,6 +22,7 @@
22
22
  #include "rubygame_event.h"
23
23
 
24
24
  void Rubygame_Init_Event();
25
+
25
26
  VALUE cEvent;
26
27
  VALUE cActiveEvent;
27
28
  VALUE cKeyDownEvent;
@@ -298,6 +299,117 @@ VALUE rbgm_fetchevents(VALUE self)
298
299
  return event_array;
299
300
  }
300
301
 
302
+
303
+
304
+ /* Convert an argument to #enable_key_repeat into an integer
305
+ * number of milliseconds.
306
+ *
307
+ * Argument must be nil, :default, or a numeric greater than 0.001.
308
+ */
309
+ int rg_get_keyrepeat_value( VALUE vvalue, int default_value, char *name )
310
+ {
311
+
312
+ int value;
313
+
314
+ if( NIL_P(vvalue) )
315
+ {
316
+ return default_value;
317
+ }
318
+
319
+ switch( TYPE(vvalue) ){
320
+ case T_SYMBOL: {
321
+ if( make_symbol("default") == vvalue )
322
+ {
323
+ return default_value;
324
+ }
325
+ else
326
+ {
327
+ rb_raise( rb_eArgError, "unsupported symbol '%s' for %s",
328
+ RSTRING(rb_inspect(vvalue))->ptr, name );
329
+ }
330
+ }
331
+
332
+ default: {
333
+ int value = NUM2INT(vvalue) * 1000; /* seconds -> milleseconds */
334
+
335
+ if( value < 1 )
336
+ {
337
+ rb_raise( rb_eArgError, "%s must be at least 0.001 seconds (got %s)",
338
+ name, RSTRING(rb_inspect(vvalue))->ptr);
339
+ }
340
+
341
+ return value;
342
+ }
343
+ }
344
+ }
345
+
346
+
347
+
348
+ /*
349
+ * call-seq:
350
+ * enable_key_repeat( delay=:default, interval=:default )
351
+ *
352
+ * Enable key repeat, so that additional keyboard release and press
353
+ * events are automatically generated for as long as the key is held
354
+ * down. See also #disable_key_repeat.
355
+ *
356
+ * delay:: how many seconds to wait before starting to repeat.
357
+ * Default is 0.5 seconds. (Numeric or :default, optional)
358
+ *
359
+ * interval:: how many seconds to wait in between repetitions after
360
+ * the first one. Default is 0.03 seconds.
361
+ * (Numeric or :default, optional)
362
+ *
363
+ */
364
+ VALUE rg_enable_key_repeat(int argc, VALUE *argv, VALUE module)
365
+ {
366
+
367
+ VALUE vdelay, vinterval;
368
+ rb_scan_args(argc, argv, "02", &vdelay, &vinterval);
369
+
370
+
371
+ int delay = rg_get_keyrepeat_value( vdelay,
372
+ SDL_DEFAULT_REPEAT_DELAY,
373
+ "delay" );
374
+
375
+ int interval = rg_get_keyrepeat_value( vinterval,
376
+ SDL_DEFAULT_REPEAT_INTERVAL,
377
+ "interval" );
378
+
379
+
380
+ int result = SDL_EnableKeyRepeat( delay, interval );
381
+
382
+ if (result != 0) {
383
+ rb_raise(eSDLError, "Could not enable key repeat: %s",
384
+ SDL_GetError());
385
+ }
386
+
387
+ return Qnil;
388
+ }
389
+
390
+
391
+
392
+ /*
393
+ * call-seq:
394
+ * disable_key_repeat
395
+ *
396
+ * Disable key repeat, undoing the effect of #enable_key_repeat.
397
+ *
398
+ */
399
+ VALUE rg_disable_key_repeat(VALUE module)
400
+ {
401
+ int result = SDL_EnableKeyRepeat( 0, 0 );
402
+
403
+ if (result != 0) {
404
+ rb_raise(eSDLError, "Could not disable key repeat: %s",
405
+ SDL_GetError());
406
+ }
407
+
408
+ return Qnil;
409
+ }
410
+
411
+
412
+
301
413
  /*
302
414
  *--
303
415
  * The event documentation is in rubygame/lib/rubygame/event.rb
@@ -310,6 +422,10 @@ void Rubygame_Init_Event()
310
422
  #endif
311
423
 
312
424
  rb_define_singleton_method(mRubygame, "fetch_sdl_events",rbgm_fetchevents,0);
425
+ rb_define_singleton_method(mRubygame, "enable_key_repeat",
426
+ rg_enable_key_repeat, -1);
427
+ rb_define_singleton_method(mRubygame, "disable_key_repeat",
428
+ rg_disable_key_repeat, 0);
313
429
 
314
430
  cEvent = rb_define_class_under(mRubygame,"Event",rb_cObject);
315
431
  cActiveEvent = rb_define_class_under(mRubygame,"ActiveEvent",cEvent);