chipmunk-ffi 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{chipmunk-ffi}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Shawn Anderson"]
@@ -87,7 +87,6 @@ module CP
87
87
  Vec2.new @struct.v
88
88
  end
89
89
  def v=(pv)
90
- @struct.v = pv.struct
91
90
  @struct.v.pointer.put_bytes 0, pv.struct.to_bytes, 0,Vect.size
92
91
  self
93
92
  end
@@ -99,7 +98,6 @@ module CP
99
98
  end
100
99
  def f=(pf)
101
100
  @struct.f.pointer.put_bytes 0, pf.struct.to_bytes, 0,Vect.size
102
- @struct.f = pf.struct
103
101
  self
104
102
  end
105
103
  alias :force :f
@@ -122,27 +122,35 @@ module CP
122
122
 
123
123
  def add_collision_func(a,b,&block)
124
124
  beg = nil
125
- pre = Proc.new do |arb_ptr,space_ptr,data_ptr|
126
- begin
127
- arb = ArbiterStruct.new(arb_ptr)
128
-
129
- swapped = arb.swapped_col == 0 ? false : true
130
- arba = swapped ? arb.b : arb.a
131
- arbb = swapped ? arb.a : arb.b
132
-
133
- as = ShapeStruct.new(arba)
134
- a_obj_id = as.data.get_ulong 0
135
- rb_a = ObjectSpace._id2ref a_obj_id
136
-
137
- bs = ShapeStruct.new(arbb)
138
- b_obj_id = bs.data.get_ulong 0
139
- rb_b = ObjectSpace._id2ref b_obj_id
140
-
141
- block.call rb_a, rb_b
142
- 1
143
- rescue Exception => ex
144
- puts ex.message
145
- puts ex.backtrace
125
+ pre = nil
126
+ unless block.nil?
127
+ pre = Proc.new do |arb_ptr,space_ptr,data_ptr|
128
+ begin
129
+ arb = ArbiterStruct.new(arb_ptr)
130
+
131
+ swapped = arb.swapped_col == 0 ? false : true
132
+ arba = swapped ? arb.b : arb.a
133
+ arbb = swapped ? arb.a : arb.b
134
+
135
+ as = ShapeStruct.new(arba)
136
+ a_obj_id = as.data.get_ulong 0
137
+ rb_a = ObjectSpace._id2ref a_obj_id
138
+
139
+ bs = ShapeStruct.new(arbb)
140
+ b_obj_id = bs.data.get_ulong 0
141
+ rb_b = ObjectSpace._id2ref b_obj_id
142
+
143
+ block.call rb_a, rb_b
144
+ 1
145
+ rescue Exception => ex
146
+ puts ex.message
147
+ puts ex.backtrace
148
+ 0
149
+ end
150
+ end
151
+ else
152
+ # needed for old chipmunk style
153
+ pre = Proc.new do |arb_ptr,space_ptr,data_ptr|
146
154
  0
147
155
  end
148
156
  end
@@ -17,12 +17,21 @@ describe 'A new Body' do
17
17
  b.p.y.should == 0
18
18
 
19
19
  b.pos = vec2(4,6)
20
- # b.pos.x.should == 4
21
- # b.pos.y.should == 6
20
+ b.pos.x.should == 4
21
+ b.pos.y.should == 6
22
+ end
23
+
24
+ it 'can set its vel' do
25
+ b = CP::Body.new(5, 7)
26
+ b.p.x.should == 0
27
+ b.p.y.should == 0
28
+
29
+ b.v = vec2(4,6)
30
+ b.v.x.should == 4
31
+ b.v.y.should == 6
22
32
  end
23
33
 
24
34
  it 'can set its moment'
25
- it 'can set its vel'
26
35
  it 'can set its force'
27
36
  it 'can set its angle'
28
37
  it 'can set its angle_vel'
@@ -72,7 +72,14 @@ describe 'ShapeStruct in chipmunk' do
72
72
  s = CP::Shape::Circle.new bod, 40, CP::ZERO_VEC_2
73
73
  ShapeClassStruct.new(s.struct.klass).type.should == :circle_shape
74
74
  end
75
+
76
+ it 'can set its bodys v' do
77
+ bod = CP::Body.new 90, 76
78
+ s = CP::Shape::Circle.new bod, 20, CP::ZERO_VEC_2
79
+ s.body.v = vec2(4,5)
80
+ end
75
81
  end
82
+
76
83
  describe 'Segment class' do
77
84
  it 'can be created' do
78
85
  bod = CP::Body.new 90, 76
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chipmunk-ffi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shawn Anderson