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.
Files changed (76) hide show
  1. data/.gitignore +1 -0
  2. data/.rspec +3 -0
  3. data/README.md +62 -0
  4. data/Rakefile +33 -23
  5. data/VERSION +1 -1
  6. data/ext/audio.c +473 -0
  7. data/ext/color.c +4 -4
  8. data/ext/event.c +25 -3
  9. data/ext/extconf.rb +35 -22
  10. data/ext/font.c +287 -0
  11. data/ext/image.c +682 -33
  12. data/ext/joystick.c +9 -9
  13. data/ext/ray.c +166 -55
  14. data/ext/ray.h +120 -9
  15. data/ext/ray_osx.m +161 -0
  16. data/ext/rect.c +31 -4
  17. data/lib/ray/audio.rb +52 -0
  18. data/lib/ray/color.rb +16 -0
  19. data/lib/ray/dsl.rb +1 -3
  20. data/lib/ray/dsl/event.rb +1 -39
  21. data/lib/ray/dsl/event_listener.rb +38 -0
  22. data/lib/ray/dsl/event_runner.rb +3 -1
  23. data/lib/ray/dsl/event_translator.rb +74 -8
  24. data/lib/ray/dsl/handler.rb +3 -33
  25. data/lib/ray/dsl/matcher.rb +129 -23
  26. data/lib/ray/font.rb +108 -0
  27. data/lib/ray/font_set.rb +37 -0
  28. data/lib/ray/game.rb +171 -34
  29. data/lib/ray/helper.rb +43 -5
  30. data/lib/ray/image.rb +90 -3
  31. data/lib/ray/image_set.rb +35 -0
  32. data/lib/ray/joystick.rb +30 -0
  33. data/lib/ray/music_set.rb +35 -0
  34. data/lib/ray/ray.rb +17 -9
  35. data/lib/ray/rect.rb +51 -0
  36. data/lib/ray/resource_set.rb +92 -0
  37. data/lib/ray/scene.rb +220 -51
  38. data/lib/ray/sound_set.rb +35 -0
  39. data/lib/ray/sprite.rb +184 -0
  40. data/psp/ext.c +4 -0
  41. data/samples/hello_world/hello.rb +35 -0
  42. data/samples/hello_world/hello_dsl.rb +24 -0
  43. data/samples/pong/pong.rb +128 -0
  44. data/samples/sokoban/level_1 +7 -0
  45. data/samples/sokoban/sokoban.rb +370 -0
  46. data/spec/ray/audio_spec.rb +146 -0
  47. data/spec/ray/color_spec.rb +13 -0
  48. data/spec/ray/event_spec.rb +57 -168
  49. data/spec/ray/font_spec.rb +93 -0
  50. data/spec/ray/image_set_spec.rb +48 -0
  51. data/spec/ray/image_spec.rb +130 -44
  52. data/spec/ray/joystick_spec.rb +13 -9
  53. data/spec/ray/matcher_spec.rb +32 -55
  54. data/spec/ray/ray_spec.rb +33 -31
  55. data/spec/ray/rect_spec.rb +80 -0
  56. data/spec/ray/resource_set_spec.rb +105 -0
  57. data/spec/ray/sprite_spec.rb +163 -0
  58. data/spec/res/VeraMono.ttf +0 -0
  59. data/spec/res/aqua2.bmp +0 -0
  60. data/spec/res/pop.wav +0 -0
  61. data/spec/spec.opts +4 -0
  62. data/spec/spec_helper.rb +8 -0
  63. data/yard_ext.rb +91 -0
  64. metadata +104 -38
  65. data/bin/ray +0 -5
  66. data/bin/ray_irb +0 -4
  67. data/ext/SDLMain.h +0 -17
  68. data/ext/SDLMain.m +0 -381
  69. data/lib/ray/config.rb +0 -84
  70. data/lib/ray/dsl/converter.rb +0 -65
  71. data/lib/ray/dsl/listener.rb +0 -30
  72. data/lib/ray/dsl/type.rb +0 -58
  73. data/spec/ray/config_spec.rb +0 -90
  74. data/spec/ray/conversion_spec.rb +0 -43
  75. data/spec/ray/type_spec.rb +0 -17
  76. data/spec_runner.rb +0 -27
data/ext/ray_osx.m ADDED
@@ -0,0 +1,161 @@
1
+ #ifdef HAVE_SDL_H
2
+ # include <SDL.h>
3
+ #else
4
+ # include <SDL/SDL.h>
5
+ #endif
6
+
7
+ #include <Cocoa/Cocoa.h>
8
+
9
+ struct CPSProcessSerNum {
10
+ UInt32 lo;
11
+ UInt32 hi;
12
+ };
13
+
14
+ typedef struct CPSProcessSerNum CPSProcessSerNum;
15
+
16
+ extern OSErr CPSGetCurrentProcess(CPSProcessSerNum *psn);
17
+ extern OSErr CPSEnableForegroundOperation(CPSProcessSerNum *psn,
18
+ UInt32 _arg2,
19
+ UInt32 _arg3,
20
+ UInt32 _arg4,
21
+ UInt32 _arg5);
22
+ extern OSErr CPSSetFrontProcess(CPSProcessSerNum *psn);
23
+ extern OSErr CPSSetProcessName(CPSProcessSerNum *psn, const char *processname);
24
+
25
+ static NSAutoreleasePool *ray_pool = nil;
26
+
27
+ @interface NSApplication (SDL_Missing_Methods)
28
+ - (void)setAppleMenu:(NSMenu *)menu;
29
+ @end
30
+
31
+ @interface RayApplication : NSApplication
32
+ @end
33
+
34
+ @implementation RayApplication
35
+ - (void)terminate:(id)sender {
36
+ SDL_Event event;
37
+ event.type = SDL_QUIT;
38
+ SDL_PushEvent(&event);
39
+ }
40
+ @end
41
+
42
+ NSString *ray_osx_appname() {
43
+ const NSDictionary *dict;
44
+ NSString *appName = 0;
45
+
46
+ dict = (const NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle());
47
+ if (dict)
48
+ appName = [dict objectForKey: @"CFBundleName"];
49
+
50
+ if ([appName length] == 0)
51
+ appName = [[NSProcessInfo processInfo] processName];
52
+
53
+ return appName;
54
+ }
55
+
56
+ void ray_osx_setup_application_menu() {
57
+ NSMenu *appleMenu;
58
+ NSMenuItem *menuItem;
59
+ NSString *title;
60
+ NSString *appName;
61
+
62
+ appName = ray_osx_appname();
63
+ appleMenu = [[NSMenu alloc] initWithTitle:@""];
64
+
65
+ /* Add menu items */
66
+ title = [@"About " stringByAppendingString:appName];
67
+ [appleMenu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:)
68
+ keyEquivalent:@""];
69
+
70
+ [appleMenu addItem:[NSMenuItem separatorItem]];
71
+
72
+ title = [@"Hide " stringByAppendingString:appName];
73
+ [appleMenu addItemWithTitle:title action:@selector(hide:)
74
+ keyEquivalent:@"h"];
75
+
76
+ menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Hide Others"
77
+ action:@selector(hideOtherApplications:)
78
+ keyEquivalent:@"h"];
79
+ [menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)];
80
+
81
+ [appleMenu addItemWithTitle:@"Show All"
82
+ action:@selector(unhideAllApplications:)
83
+ keyEquivalent:@""];
84
+
85
+ [appleMenu addItem:[NSMenuItem separatorItem]];
86
+
87
+ title = [@"Quit " stringByAppendingString:appName];
88
+ [appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"];
89
+
90
+ /* Put menu into the menubar */
91
+ menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
92
+ [menuItem setSubmenu:appleMenu];
93
+ [[NSApp mainMenu] addItem:menuItem];
94
+
95
+ /* Tell the application object that this is now the application menu */
96
+ [NSApp setAppleMenu:appleMenu];
97
+
98
+ /* Finally give up our references to the objects */
99
+ [appleMenu release];
100
+ [menuItem release];
101
+ }
102
+
103
+ void ray_osx_setup_window_menu() {
104
+ NSMenu *windowMenu;
105
+ NSMenuItem *windowMenuItem;
106
+ NSMenuItem *menuItem;
107
+
108
+ windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
109
+
110
+ /* "Minimize" item */
111
+ menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize"
112
+ action:@selector(performMiniaturize:)
113
+ keyEquivalent:@"m"];
114
+ [windowMenu addItem:menuItem];
115
+ [menuItem release];
116
+
117
+ /* Put menu into the menubar */
118
+ windowMenuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil
119
+ keyEquivalent:@""];
120
+ [windowMenuItem setSubmenu:windowMenu];
121
+ [[NSApp mainMenu] addItem:windowMenuItem];
122
+
123
+ /* Tell the application object that this is now the window menu */
124
+ [NSApp setWindowsMenu:windowMenu];
125
+
126
+ /* Finally give up our references to the objects */
127
+ [windowMenu release];
128
+ [windowMenuItem release];
129
+ }
130
+
131
+ void ray_osx_init() {
132
+ if (ray_pool)
133
+ return;
134
+
135
+ ray_pool = [[NSAutoreleasePool alloc] init];
136
+
137
+ [RayApplication sharedApplication];
138
+
139
+ [NSApp setMainMenu:[[[NSMenu alloc] init] autorelease]];
140
+ ray_osx_setup_application_menu();
141
+ ray_osx_setup_window_menu();
142
+
143
+ CPSProcessSerNum psn;
144
+
145
+ CPSGetCurrentProcess(&psn);
146
+ NSString *nameNSString = ray_osx_appname();
147
+ const char *nameString = [nameNSString UTF8String];
148
+ CPSSetProcessName(&psn, nameString);
149
+
150
+ CPSEnableForegroundOperation(&psn, 0x03, 0x3C, 0x2C, 0x1103);
151
+ CPSSetFrontProcess(&psn);
152
+
153
+ [NSApp finishLaunching];
154
+ [NSApp updateWindows];
155
+ [NSApp activateIgnoringOtherApps:true];
156
+ }
157
+
158
+ void ray_osx_close() {
159
+ [ray_pool drain];
160
+ ray_pool = nil;
161
+ }
data/ext/rect.c CHANGED
@@ -26,6 +26,21 @@ ray_rect ray_rb2rect(VALUE obj) {
26
26
  return *rect;
27
27
  }
28
28
 
29
+ ray_rect ray_convert_to_rect(VALUE obj) {
30
+ if (RAY_IS_A(obj, ray_cRect))
31
+ return ray_rb2rect(obj);
32
+ else if (RAY_IS_A(obj, rb_cArray))
33
+ return ray_rb2rect(rb_apply(ray_cRect, RAY_METH("new"), obj));
34
+ else {
35
+ rb_raise(rb_eTypeError, "Can't convert %s into Ray::Rect",
36
+ RAY_OBJ_CLASSNAME(obj));
37
+ }
38
+
39
+ /* Should never happen */
40
+ ray_rect empty_rect = {0, 0, 0, 0};
41
+ return empty_rect;
42
+ }
43
+
29
44
  VALUE ray_alloc_rect(VALUE self) {
30
45
  ray_rect *rect = malloc(sizeof(ray_rect));
31
46
  VALUE ret = Data_Wrap_Struct(self, 0, ray_free_rect, rect);
@@ -138,7 +153,10 @@ VALUE ray_rect_h(VALUE self) {
138
153
  return INT2FIX(rect->h);
139
154
  }
140
155
 
141
- /* Sets the position of the rect */
156
+ /*
157
+ @overload x=(val)
158
+ Sets the position of the rect
159
+ */
142
160
  VALUE ray_rect_set_x(VALUE self, VALUE val) {
143
161
  ray_rect *rect;
144
162
  Data_Get_Struct(self, ray_rect, rect);
@@ -148,7 +166,10 @@ VALUE ray_rect_set_x(VALUE self, VALUE val) {
148
166
  return val;
149
167
  }
150
168
 
151
- /* Sets the position of the rect */
169
+ /*
170
+ @overload y=(val)
171
+ Sets the position of the rect
172
+ */
152
173
  VALUE ray_rect_set_y(VALUE self, VALUE val) {
153
174
  ray_rect *rect;
154
175
  Data_Get_Struct(self, ray_rect, rect);
@@ -158,7 +179,10 @@ VALUE ray_rect_set_y(VALUE self, VALUE val) {
158
179
  return val;
159
180
  }
160
181
 
161
- /* Sets the size of the rect */
182
+ /*
183
+ @overload w=(val)
184
+ Sets the size of the rect
185
+ */
162
186
  VALUE ray_rect_set_w(VALUE self, VALUE val) {
163
187
  ray_rect *rect;
164
188
  Data_Get_Struct(self, ray_rect, rect);
@@ -168,7 +192,10 @@ VALUE ray_rect_set_w(VALUE self, VALUE val) {
168
192
  return val;
169
193
  }
170
194
 
171
- /* Sets the size of the rect */
195
+ /*
196
+ @overload h=(val)
197
+ Sets the size of the rect
198
+ */
172
199
  VALUE ray_rect_set_h(VALUE self, VALUE val) {
173
200
  ray_rect *rect;
174
201
  Data_Get_Struct(self, ray_rect, rect);
data/lib/ray/audio.rb ADDED
@@ -0,0 +1,52 @@
1
+ module Ray
2
+ # Represents an audio channel, where sounds are played.
3
+ class Channel
4
+ # Creates a channel.
5
+ # @param [Integer] id Identifer of the channel.
6
+ def initialize(id)
7
+ @id = id
8
+ end
9
+
10
+ # Plays a sound on the channel.
11
+ # @param [Ray::Sound] sound The sound to be played
12
+ # @param [Integer, :forever] times How many times the sound should be played.
13
+ def play(sound, times = 1)
14
+ sound.play(@id, times)
15
+ end
16
+
17
+ # Stops playing on the channel, without being able to resume.
18
+ def stop
19
+ Ray::Audio.stop(@id)
20
+ end
21
+
22
+ # Pauses the channel.
23
+ def pause
24
+ Ray::Audio.pause(@id)
25
+ end
26
+
27
+ # Resumes from pause.
28
+ def resume
29
+ Ray::Audio.resume(@id)
30
+ end
31
+
32
+ # @return [true, false] True if the channel is paused.
33
+ def paused?
34
+ Ray::Audio.paused?(@id)
35
+ end
36
+
37
+ # @return [true, false] True if a sound is being played.
38
+ def playing?
39
+ Ray::Audio.playing?(@id)
40
+ end
41
+ end
42
+
43
+ class Sound
44
+ extend Ray::ResourceSet
45
+ add_set(/^(.*)$/) { |filename| new(filename) }
46
+ end
47
+
48
+ class Music
49
+ extend Ray::ResourceSet
50
+ add_set(/^(.*)$/) { |filename| new(filename) }
51
+ end
52
+ end
data/lib/ray/color.rb CHANGED
@@ -17,6 +17,15 @@ module Ray
17
17
  "RGBA(#{r}, #{g}, #{b}, #{a})"
18
18
  end
19
19
 
20
+ def ==(obj)
21
+ return false unless obj.is_a? Color
22
+ r == obj.r && g == obj.g && b == obj.b && a == obj.a
23
+ end
24
+
25
+ def to_color
26
+ self
27
+ end
28
+
20
29
  alias :red :r
21
30
  alias :green :g
22
31
  alias :blue :b
@@ -28,3 +37,10 @@ module Ray
28
37
  alias :alpha= :a=
29
38
  end
30
39
  end
40
+
41
+ class Array
42
+ # Converts an Array to a color
43
+ def to_color
44
+ Ray::Color.new(*self)
45
+ end
46
+ end
data/lib/ray/dsl.rb CHANGED
@@ -5,15 +5,13 @@ module Ray
5
5
  module DSL; end
6
6
  end
7
7
 
8
- require 'ray/dsl/type'
9
8
  require 'ray/dsl/matcher'
10
- require 'ray/dsl/converter'
11
9
 
12
10
  require 'ray/dsl/event'
13
11
  require 'ray/dsl/handler'
14
12
  require 'ray/dsl/event_runner'
15
13
 
16
- require 'ray/dsl/listener'
14
+ require 'ray/dsl/event_listener'
17
15
  require 'ray/dsl/event_raiser'
18
16
 
19
17
  require 'ray/dsl/event_translator'
data/lib/ray/dsl/event.rb CHANGED
@@ -1,52 +1,14 @@
1
1
  module Ray
2
2
  module DSL
3
- # The events you can raise and listen to are instances of this class.
4
- # You should not manipulate them directly. In fact, they are created
5
- # and handled by the event runner, which happens to be greedy, and
6
- # therefore won't give an event to you. It will only give you its
7
- # arguments (you already know its type anyway.)
3
+ # Used internally to store event when raise_event is caled.
8
4
  class Event
9
- @@descriptions = {}
10
-
11
- def self.add_description(name, types)
12
- @@descriptions[name] = types
13
- end
14
-
15
- def self.description_of(name)
16
- @@descriptions[name]
17
- end
18
-
19
5
  def initialize(type, args)
20
6
  @type = type
21
7
  @args = args
22
-
23
- if desc = @@descriptions[@type]
24
- desc.each_with_index do |type, i|
25
- begin
26
- @args[i] = Ray.convert(@args[i], type)
27
- rescue TypeError
28
- return
29
- end
30
- end
31
- end
32
8
  end
33
9
 
34
10
  attr_reader :type
35
11
  attr_reader :args
36
12
  end
37
13
  end
38
-
39
- # This method decribes an event, which means Ray will be able to understand
40
- # that, when you say "image.png", you actually meant Ray::Image.new("image.png").
41
- #
42
- # If Ray can't convert your arguments, it will just let you continue that way.
43
- def self.describe_event(name, *types)
44
- DSL::Event.add_description(name, types.map { |i| Ray.resolve_type(i) })
45
- end
46
-
47
- # @return [Array<Module>] The types of the arguments for a given event, in the
48
- # right order.
49
- def self.description_for_event(name)
50
- DSL::Event.description_of(name)
51
- end
52
14
  end
@@ -0,0 +1,38 @@
1
+ module Ray
2
+ module DSL
3
+ # The module that allows you to do something when something else happened.
4
+ module EventListener
5
+ # Registers a block to listen to an event.
6
+ #
7
+ # Arguments are compared with the ones of the regex using === and,
8
+ # if it failed, ==.
9
+ #
10
+ # @param [Symbol] event Name of the event to listen to
11
+ # @param [DSL::Matcher, Regexp, Object] args List of arguments that should
12
+ # match the event's (if empty,
13
+ # the block will be called anyway)
14
+ def on(event, *args, &block)
15
+ return unless listener_runner
16
+ listener_runner.add_handler(event, args, block)
17
+ end
18
+
19
+ # @overload add_hook(event, ..., callable)
20
+ # Same as on, but the last argument is an object which responds to
21
+ # to_proc.
22
+ #
23
+ # @example
24
+ # add_hook :quit, method(:exit!)
25
+ def add_hook(event, *args)
26
+ on(event, *args[0...-1], &args.last)
27
+ end
28
+
29
+ def listener_runner
30
+ @__listener_runner
31
+ end
32
+
33
+ def listener_runner=(arg)
34
+ @__listener_runner = arg
35
+ end
36
+ end
37
+ end
38
+ end
@@ -1,9 +1,11 @@
1
+ require 'thread'
2
+
1
3
  module Ray
2
4
  module DSL
3
5
  # This class is the one that dispatches events in your program, the one that
4
6
  # makes everything work. You may want to create one by yourself if you don't
5
7
  # want to use the other classes that use it. You just have to call run every
6
- # time you need the events to be said.
8
+ # time you need the events to be processed.
7
9
  class EventRunner
8
10
  def initialize
9
11
  @handlers = []
@@ -1,36 +1,102 @@
1
1
  module Ray
2
2
  module DSL
3
3
  # Module charged to translate an instance of Ray::Event into the arguments
4
- # you pass to raise_event.
4
+ # you pass to raise_event. It is for instance used in Ray::Scene.
5
+ #
6
+ # == Raised events
7
+ # 1. quit
8
+ # 2. focus_gain(focus_type)
9
+ # 3. mouse_motion(rect), where [rect.x, rect.y] is where the user clicked.
10
+ # 4. mouse_press(button, rect)
11
+ # 5. mouse_release(button, rect)
12
+ # 6. key_press(key, mod_keys)
13
+ # 7. key_release(key, mod_keys)
14
+ # 8. window_resize(rect), where [rect.w, rect.h] is the size of the window.
15
+ # 9. joy_motion(joystick_id, axis_id, axis_value)
16
+ # 10. joy_press(joystick_id, button_id)
17
+ # 11. joy_release(joystick_id, button_id)
5
18
  module EventTranslator
6
- FOCUS_TYPE = {
19
+ FOCUS_TYPES = {
7
20
  Ray::Event::APPMOUSEFOCUS => :mouse_focus,
8
21
  Ray::Event::APPINPUTFOCUS => :input_focus,
9
22
  Ray::Event::APPACTIVE => :app_activity
10
23
  }
11
24
 
25
+ MOUSE_BUTTONS = {
26
+ Ray::Event::BUTTON_LEFT => :left,
27
+ Ray::Event::BUTTON_MIDDLE => :middle,
28
+ Ray::Event::BUTTON_RIGHT => :right,
29
+ Ray::Event::BUTTON_WHEELUP => :wheel_up,
30
+ Ray::Event::BUTTON_WHEELDOWN => :wheel_down
31
+ }
32
+
12
33
  class << self
13
- # @return [Array, nil] The arguments you should pass to raise_event.
34
+ # @return [Array] The arguments you should pass to raise_event.
14
35
  def translate_event(ev)
15
36
  case ev.type
16
- when 0 then nil
37
+ when Ray::Event::TYPE_NOEVENT then []
17
38
  when Ray::Event::TYPE_QUIT then quit(ev)
18
39
  when Ray::Event::TYPE_ACTIVEEVENT then active_event(ev)
19
40
  when Ray::Event::TYPE_MOUSEMOTION then mouse_motion(ev)
20
- else nil
41
+ when Ray::Event::TYPE_MOUSEBUTTONDOWN then mouse_press(ev)
42
+ when Ray::Event::TYPE_MOUSEBUTTONUP then mouse_release(ev)
43
+ when Ray::Event::TYPE_KEYDOWN then key_press(ev)
44
+ when Ray::Event::TYPE_KEYUP then key_release(ev)
45
+ when Ray::Event::TYPE_VIDEORESIZE then resize(ev)
46
+ when Ray::Event::TYPE_JOYAXISMOTION then joy_motion(ev)
47
+ when Ray::Event::TYPE_JOYBUTTONDOWN then joy_press(ev)
48
+ when Ray::Event::TYPE_JOYBUTTONUP then joy_release(ev)
49
+ else []
21
50
  end
22
51
  end
23
52
 
24
53
  def quit(ev)
25
- [:quit]
54
+ [[:quit]]
26
55
  end
27
56
 
28
57
  def active_event(ev)
29
- [ev.is_gain? ? :focus_gain : :focus_loss, FOCUS_TYPE[ev.focus_state]]
58
+ [[ev.is_gain? ? :focus_gain : :focus_loss,
59
+ FOCUS_TYPES[ev.focus_state]]]
30
60
  end
31
61
 
32
62
  def mouse_motion(ev)
33
- [:mouse_motion, Ray::Rect.new(ev.mouse_x, ev.mouse_y)]
63
+ [[:mouse_motion, Ray::Rect.new(ev.mouse_x, ev.mouse_y)]]
64
+ end
65
+
66
+ def mouse_press(ev)
67
+ [[:mouse_press,
68
+ MOUSE_BUTTONS[ev.mouse_button],
69
+ Ray::Rect.new(ev.mouse_x, ev.mouse_y)]]
70
+ end
71
+
72
+ def mouse_release(ev)
73
+ [[:mouse_release,
74
+ MOUSE_BUTTONS[ev.mouse_button],
75
+ Ray::Rect.new(ev.mouse_x, ev.mouse_y)]]
76
+ end
77
+
78
+ def key_press(ev)
79
+ [[:key_press, ev.key, ev.mod_keys]]
80
+ end
81
+
82
+ def key_release(ev)
83
+ [[:key_release, ev.key, ev.mod_keys]]
84
+ end
85
+
86
+ def resize(ev)
87
+ [[:window_resize, Ray::Rect.new(0, 0, ev.window_w, ev.window_h)]]
88
+ end
89
+
90
+ def joy_motion(ev)
91
+ [[:joy_motion, ev.joystick_id, ev.axis_id, ev.axis_value]]
92
+ end
93
+
94
+ def joy_press(ev)
95
+ [[:joy_press, ev.joystick_id, ev.joystick_button]]
96
+ end
97
+
98
+ def joy_release(ev)
99
+ [[:joy_release, ev.joystick_id, ev.joystick_button]]
34
100
  end
35
101
  end
36
102
  end