reflexion 0.1.9.1 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.doc/ext/reflex/application.cpp +2 -1
- data/.doc/ext/reflex/native.cpp +5 -1
- data/README.md +2 -2
- data/VERSION +1 -1
- data/ext/reflex/application.cpp +2 -1
- data/ext/reflex/native.cpp +5 -1
- data/lib/reflex/body.rb +2 -0
- data/lib/reflex/view.rb +3 -2
- data/lib/reflex/window.rb +3 -0
- data/lib/reflexion.rb +17 -22
- data/reflex.gemspec +1 -1
- data/samples/ios/hello/hello/main.cpp +1 -1
- data/samples/osx/hello/hello/main.cpp +1 -1
- data/samples/reflexion/breakout.rb +19 -27
- data/src/body.cpp +2 -2
- data/src/exception.cpp +1 -1
- data/src/ios/application.mm +7 -2
- data/src/ios/application_data.h +2 -2
- data/src/ios/event.h +2 -2
- data/src/ios/event.mm +1 -1
- data/src/ios/native_window.h +2 -2
- data/src/ios/native_window.mm +11 -7
- data/src/ios/opengl_view.mm +1 -1
- data/src/ios/window.mm +1 -1
- data/src/ios/window_data.h +2 -2
- data/src/osx/application_data.h +2 -2
- data/src/osx/event.h +2 -2
- data/src/osx/window_data.h +2 -2
- data/src/view.cpp +1 -1
- data/src/win32/defs.h +2 -2
- data/src/win32/opengl.h +2 -2
- data/src/world.cpp +1 -1
- data/src/world.h +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2bbd862d88e6ae5162205e9b1656a23ce6f62a70
|
4
|
+
data.tar.gz: 48e9ec4d9ee31e1edc662d7fe7e17e134a2024af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b8d6a218d4844bcda3f1faa9c6319c9708de00950e9d485e889ab43b184391ae4b13ead28b298942479de9f06c1a8c7c7d7cf9ec3b784a1ab51299a824024de
|
7
|
+
data.tar.gz: fe2306dac1b6d79b2e73848948392e82ad4ab9e65de34d50a6f0c38dcd597b2236dc8992b3a55d3e7e062f48c9f7cc483f1b87d9e9ce30ec9defb212dd8a30ae
|
@@ -12,6 +12,7 @@ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Reflex::Application)
|
|
12
12
|
|
13
13
|
#define THIS to<Reflex::Application*>(self)
|
14
14
|
|
15
|
+
#define CHECK_OBJ RUCY_CHECK_OBJ( Reflex::Application, self)
|
15
16
|
#define CHECK RUCY_CHECK_OBJECT(Reflex::Application, self)
|
16
17
|
|
17
18
|
#define CALL(fun) RUCY_WRAPPER_CALL(Reflex::Application, THIS, fun)
|
@@ -26,7 +27,7 @@ VALUE alloc(VALUE klass)
|
|
26
27
|
static
|
27
28
|
VALUE start(VALUE self)
|
28
29
|
{
|
29
|
-
|
30
|
+
CHECK_OBJ;
|
30
31
|
CALL(start());
|
31
32
|
return self;
|
32
33
|
}
|
data/.doc/ext/reflex/native.cpp
CHANGED
data/README.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.10
|
data/ext/reflex/application.cpp
CHANGED
@@ -12,6 +12,7 @@ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Reflex::Application)
|
|
12
12
|
|
13
13
|
#define THIS to<Reflex::Application*>(self)
|
14
14
|
|
15
|
+
#define CHECK_OBJ RUCY_CHECK_OBJ( Reflex::Application, self)
|
15
16
|
#define CHECK RUCY_CHECK_OBJECT(Reflex::Application, self)
|
16
17
|
|
17
18
|
#define CALL(fun) RUCY_WRAPPER_CALL(Reflex::Application, THIS, fun)
|
@@ -27,7 +28,7 @@ RUCY_END
|
|
27
28
|
static
|
28
29
|
RUCY_DEF0(start)
|
29
30
|
{
|
30
|
-
|
31
|
+
CHECK_OBJ;
|
31
32
|
CALL(start());
|
32
33
|
return self;
|
33
34
|
}
|
data/ext/reflex/native.cpp
CHANGED
data/lib/reflex/body.rb
CHANGED
data/lib/reflex/view.rb
CHANGED
@@ -24,8 +24,8 @@ module Reflex
|
|
24
24
|
|
25
25
|
def_delegators :body,
|
26
26
|
:static=, :static?, :dynamic=, :dynamic?,
|
27
|
-
:linear_velocity=,
|
28
|
-
:
|
27
|
+
:velocity=, :linear_velocity=, :angular_velocity=,
|
28
|
+
:velocity, :linear_velocity, :angular_velocity,
|
29
29
|
:density=, :density, :friction=, :friction, :restitution=, :restitution
|
30
30
|
|
31
31
|
alias add add_child
|
@@ -70,6 +70,7 @@ module Reflex
|
|
70
70
|
def gravity= (*args)
|
71
71
|
case arg = args[0]
|
72
72
|
when Point then set_gravity arg.x, arg.y
|
73
|
+
when Array then set_gravity arg[0], arg[1]
|
73
74
|
else set_gravity *args
|
74
75
|
end
|
75
76
|
end
|
data/lib/reflex/window.rb
CHANGED
@@ -23,6 +23,9 @@ module Reflex
|
|
23
23
|
:add_child, :remove_child, :find_children, :style, :meter2pixel, :meter,
|
24
24
|
:gravity=, :gravity, :wall, :debug=, :debug?
|
25
25
|
|
26
|
+
def_delegators :wall,
|
27
|
+
:friction=, :friction, :restitution=, :restitution
|
28
|
+
|
26
29
|
alias add add_child
|
27
30
|
alias remove remove_child
|
28
31
|
alias find find_children
|
data/lib/reflexion.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
|
4
|
+
require 'beeps'
|
4
5
|
require 'rays'
|
5
6
|
require 'reflex'
|
6
7
|
|
@@ -8,7 +9,7 @@ require 'reflex'
|
|
8
9
|
module Reflexion
|
9
10
|
|
10
11
|
|
11
|
-
include Rays, Reflex
|
12
|
+
include Beeps, Rays, Reflex
|
12
13
|
|
13
14
|
|
14
15
|
DEFAULTS = {
|
@@ -19,36 +20,33 @@ module Reflexion
|
|
19
20
|
|
20
21
|
class MainWindow < Window
|
21
22
|
|
22
|
-
attr_accessor :update, :draw, :key, :pointer
|
23
|
-
|
24
|
-
attr_reader :setup
|
25
|
-
|
26
23
|
attr_reader :event
|
27
24
|
|
28
|
-
def
|
29
|
-
|
30
|
-
|
25
|
+
def initialize (*args, &block)
|
26
|
+
super
|
27
|
+
$window = self
|
28
|
+
call_event nil, self, &$setup
|
31
29
|
end
|
32
30
|
|
33
31
|
def on_update (e)
|
34
32
|
super
|
35
33
|
redraw
|
36
|
-
call_event e, e,
|
34
|
+
call_event e, e, &$update
|
37
35
|
end
|
38
36
|
|
39
37
|
def on_draw (e)
|
40
38
|
super
|
41
|
-
call_event e, e.painter,
|
39
|
+
call_event e, e.painter, &$draw
|
42
40
|
end
|
43
41
|
|
44
42
|
def on_key (e)
|
45
43
|
super
|
46
|
-
call_event e, e,
|
44
|
+
call_event e, e, &$key
|
47
45
|
end
|
48
46
|
|
49
47
|
def on_pointer (e)
|
50
48
|
super
|
51
|
-
call_event e, e,
|
49
|
+
call_event e, e, &$pointer
|
52
50
|
end
|
53
51
|
|
54
52
|
def call_event (event, *args, &block)
|
@@ -61,10 +59,8 @@ module Reflexion
|
|
61
59
|
|
62
60
|
module_function
|
63
61
|
|
64
|
-
@@window = MainWindow.new DEFAULTS
|
65
|
-
|
66
62
|
def window ()
|
67
|
-
|
63
|
+
$window ||= MainWindow.new DEFAULTS
|
68
64
|
end
|
69
65
|
|
70
66
|
def event ()
|
@@ -72,28 +68,27 @@ module Reflexion
|
|
72
68
|
end
|
73
69
|
|
74
70
|
def setup (&block)
|
75
|
-
|
71
|
+
$setup = block
|
76
72
|
end
|
77
73
|
|
78
74
|
def update (&block)
|
79
|
-
|
75
|
+
$update = block
|
80
76
|
end
|
81
77
|
|
82
78
|
def draw (&block)
|
83
|
-
|
79
|
+
$draw = block
|
84
80
|
end
|
85
81
|
|
86
82
|
def key (&block)
|
87
|
-
|
83
|
+
$key = block
|
88
84
|
end
|
89
85
|
|
90
86
|
def pointer (&block)
|
91
|
-
|
87
|
+
$pointer = block
|
92
88
|
end
|
93
89
|
|
94
90
|
def start ()
|
95
|
-
window.show
|
96
|
-
Reflex.start
|
91
|
+
Reflex.start {window.show}
|
97
92
|
end
|
98
93
|
|
99
94
|
def quit ()
|
data/reflex.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
|
|
23
23
|
|
24
24
|
s.authors = %w[snori]
|
25
25
|
s.email = 'snori@xord.org'
|
26
|
-
s.homepage = "https://github.com/xord/
|
26
|
+
s.homepage = "https://github.com/xord/reflex"
|
27
27
|
|
28
28
|
s.platform = Gem::Platform::RUBY
|
29
29
|
s.required_ruby_version = '>=1.9.0'
|
@@ -1,52 +1,44 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
|
4
|
-
%w[xot rays reflex]
|
4
|
+
%w[xot beeps rays reflex]
|
5
5
|
.map {|s| File.expand_path "../../../../#{s}/lib", __FILE__}
|
6
6
|
.each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
|
7
7
|
|
8
8
|
require 'reflexion/include'
|
9
9
|
|
10
10
|
|
11
|
-
$
|
11
|
+
$hit, $bang = [880, 440].map {|n| Sound.new SineWave.new(freq: n), 0.1}
|
12
|
+
$garbages = []
|
12
13
|
|
13
|
-
|
14
|
-
|
14
|
+
def add_shape (klass: RectShape, frame: [0, 0, 100, 100], color: :white, type: :static)
|
15
|
+
window.add klass.new {
|
15
16
|
set frame: frame, fill: color, density: 1, friction: 0, restitution: 1, type => true
|
16
|
-
|
17
|
+
}
|
17
18
|
end
|
18
19
|
|
19
20
|
setup do
|
20
|
-
set size: [600, 400]
|
21
|
-
wall.set friction: 0
|
21
|
+
set size: [600, 400], friction: 0
|
22
22
|
5.times do |y|
|
23
23
|
10.times do |x|
|
24
|
-
|
25
|
-
|
26
|
-
on(:contact) {$garbages << self}
|
27
|
-
}
|
24
|
+
shape = add_shape frame: [(x + 1) * 50, (y + 1) * 20, 30, 10], color: [:white, :red, :green, :blue, :yellow][y]
|
25
|
+
shape.on(:contact) {$hit.play; $garbages << shape}
|
28
26
|
end
|
29
27
|
end
|
30
|
-
$bar
|
31
|
-
|
32
|
-
}
|
33
|
-
end
|
34
|
-
|
35
|
-
update do
|
36
|
-
$garbages.uniq.each {|o| o.parent.remove o}
|
37
|
-
$garbages.clear
|
38
|
-
end
|
39
|
-
|
40
|
-
draw do
|
41
|
-
text "#{event.fps.to_i} FPS", 10, 10
|
28
|
+
$bar = add_shape frame: [0, 350, 100, 20], color: :blue
|
29
|
+
bottom = add_shape frame: [0, window.h - 1, window.w, 1]
|
30
|
+
bottom.on(:contact) {|e| $bang.play; $garbages << e.view}
|
42
31
|
end
|
43
32
|
|
44
33
|
pointer do |e|
|
45
34
|
$bar.x = e.x - $bar.w / 2
|
46
35
|
if e.down?
|
47
|
-
|
48
|
-
|
49
|
-
set :linear_velocity, Point.new(rand(-1.0..1.0), -1).normal * 500
|
50
|
-
}
|
36
|
+
ball = add_shape klass: [EllipseShape, RectShape].sample, frame: [e.x, $bar.y - 20, 20, 20], type: :dynamic
|
37
|
+
ball.velocity = Point.new(rand(-1.0..1.0), -1).normal * 500
|
51
38
|
end
|
52
39
|
end
|
40
|
+
|
41
|
+
update do
|
42
|
+
$garbages.uniq.each {|o| o.parent.remove o}
|
43
|
+
$garbages.clear
|
44
|
+
end
|
data/src/body.cpp
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
#include <Box2D/Collision/Shapes/b2EdgeShape.h>
|
12
12
|
#include <Box2D/Collision/Shapes/b2ChainShape.h>
|
13
13
|
#include <Box2D/Collision/Shapes/b2PolygonShape.h>
|
14
|
-
#include
|
14
|
+
#include <xot/util.h>
|
15
15
|
#include "reflex/exception.h"
|
16
16
|
#include "reflex/painter.h"
|
17
17
|
#include "world.h"
|
@@ -212,7 +212,7 @@ namespace Reflex
|
|
212
212
|
invalid_state_error(__FILE__, __LINE__);
|
213
213
|
|
214
214
|
b2Fixture* f;
|
215
|
-
while (f = PTR->GetFixtureList())
|
215
|
+
while ((f = PTR->GetFixtureList()))
|
216
216
|
PTR->DestroyFixture(f);
|
217
217
|
}
|
218
218
|
|
data/src/exception.cpp
CHANGED
data/src/ios/application.mm
CHANGED
@@ -3,12 +3,17 @@
|
|
3
3
|
|
4
4
|
|
5
5
|
#include <assert.h>
|
6
|
-
#include <crt_externs.h>
|
7
6
|
#include "reflex/exception.h"
|
8
7
|
#include "application_data.h"
|
9
8
|
#import "app_delegate.h"
|
10
9
|
|
11
10
|
|
11
|
+
extern "C" {
|
12
|
+
char*** _NSGetArgv ();
|
13
|
+
int* _NSGetArgc ();
|
14
|
+
}
|
15
|
+
|
16
|
+
|
12
17
|
namespace Reflex
|
13
18
|
{
|
14
19
|
|
@@ -46,7 +51,7 @@ namespace Reflex
|
|
46
51
|
Application::start ()
|
47
52
|
{
|
48
53
|
UIApplicationMain(
|
49
|
-
*_NSGetArgc(), *_NSGetArgv(), nil, NSStringFromClass(
|
54
|
+
*_NSGetArgc(), *_NSGetArgv(), nil, NSStringFromClass(AppDelegate.class));
|
50
55
|
}
|
51
56
|
|
52
57
|
void
|
data/src/ios/application_data.h
CHANGED
data/src/ios/event.h
CHANGED
data/src/ios/event.mm
CHANGED
@@ -20,7 +20,7 @@ namespace Reflex
|
|
20
20
|
|
21
21
|
|
22
22
|
NativePointerEvent::NativePointerEvent (NSSet* touches, UIEvent* e, UIView* view, Type type)
|
23
|
-
: PointerEvent(type, POINTER_TOUCH, (coord) 0, (coord) 0)
|
23
|
+
: PointerEvent(type, POINTER_TOUCH, (coord) 0, (coord) 0, 0, 1, type == MOVE)
|
24
24
|
{
|
25
25
|
CGPoint p = correct_point(view, [touches anyObject]);
|
26
26
|
x = p.x;
|
data/src/ios/native_window.h
CHANGED
@@ -22,6 +22,8 @@
|
|
22
22
|
|
23
23
|
- (void) draw;
|
24
24
|
|
25
|
+
- (void) frameChanged;
|
26
|
+
|
25
27
|
- (void) keyDown: (UIEvent*) event;
|
26
28
|
|
27
29
|
- (void) keyUp: (UIEvent*) event;
|
@@ -34,6 +36,4 @@
|
|
34
36
|
|
35
37
|
- (void) touchesMoved: (NSSet*) touches withEvent: (UIEvent*) event;
|
36
38
|
|
37
|
-
+ (CGRect) frameRectForContentRect: (CGRect) contentRect;
|
38
|
-
|
39
39
|
@end// NativeWindow
|
data/src/ios/native_window.mm
CHANGED
@@ -26,7 +26,16 @@ namespace Reflex
|
|
26
26
|
|
27
27
|
static CGRect device_frame ()
|
28
28
|
{
|
29
|
-
|
29
|
+
UIScreen* screen = [UIScreen mainScreen];
|
30
|
+
CGRect rect = screen.applicationFrame;
|
31
|
+
CGFloat scale = screen.scale;
|
32
|
+
|
33
|
+
rect.origin.x = 0;
|
34
|
+
rect.origin.y = 0;
|
35
|
+
rect.size.width *= scale;
|
36
|
+
rect.size.height *= scale;
|
37
|
+
|
38
|
+
return rect;
|
30
39
|
}
|
31
40
|
|
32
41
|
|
@@ -38,7 +47,7 @@ static CGRect device_frame ()
|
|
38
47
|
if (!self) return nil;
|
39
48
|
|
40
49
|
pref = new Reflex::Window::Ref;
|
41
|
-
view_controller = [[OpenGLViewController alloc]
|
50
|
+
view_controller = [[OpenGLViewController alloc] init];
|
42
51
|
|
43
52
|
self.rootViewController = view_controller;
|
44
53
|
|
@@ -229,9 +238,4 @@ static CGRect device_frame ()
|
|
229
238
|
REF->on_pointer(&e);
|
230
239
|
}
|
231
240
|
|
232
|
-
+ (CGRect) frameRectForContentRect: (CGRect) contentRect
|
233
|
-
{
|
234
|
-
return device_frame();
|
235
|
-
}
|
236
|
-
|
237
241
|
@end// NativeWindow
|
data/src/ios/opengl_view.mm
CHANGED
data/src/ios/window.mm
CHANGED
data/src/ios/window_data.h
CHANGED
data/src/osx/application_data.h
CHANGED
data/src/osx/event.h
CHANGED
data/src/osx/window_data.h
CHANGED
data/src/view.cpp
CHANGED
data/src/win32/defs.h
CHANGED
data/src/win32/opengl.h
CHANGED
data/src/world.cpp
CHANGED
data/src/world.h
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reflexion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- snori
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -456,7 +456,7 @@ files:
|
|
456
456
|
- ".doc/ext/reflex/view.cpp"
|
457
457
|
- ".doc/ext/reflex/wheel_event.cpp"
|
458
458
|
- ".doc/ext/reflex/window.cpp"
|
459
|
-
homepage: https://github.com/xord/
|
459
|
+
homepage: https://github.com/xord/reflex
|
460
460
|
licenses: []
|
461
461
|
metadata: {}
|
462
462
|
post_install_message:
|