gosling 2.0.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gosling/collision.rb +56 -1
- data/lib/gosling/polygon.rb +22 -4
- data/lib/gosling/transformable.rb +19 -59
- data/lib/gosling/version.rb +1 -1
- data/spec/collision_spec.rb +604 -331
- data/spec/polygon_spec.rb +57 -12
- data/spec/transformable_spec.rb +6 -0
- metadata +2 -2
data/spec/polygon_spec.rb
CHANGED
@@ -13,17 +13,64 @@ describe Gosling::Polygon do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
describe '#set_vertices' do
|
16
|
-
it '
|
16
|
+
it 'accepts an array of Vectors' do
|
17
17
|
vertices = [
|
18
18
|
Snow::Vec3[ 1, 0, 1],
|
19
19
|
Snow::Vec3[ 0, 1, 1],
|
20
20
|
Snow::Vec3[-1, 0, 1],
|
21
|
-
Snow::Vec3[ 0, -1, 1]
|
21
|
+
Snow::Vec3[ 0, -1, 1]
|
22
22
|
]
|
23
23
|
|
24
24
|
polygon = Gosling::Polygon.new(@window)
|
25
|
-
polygon.set_vertices(vertices)
|
26
|
-
expect(polygon.get_vertices).to
|
25
|
+
expect { polygon.set_vertices(vertices) }.not_to raise_error
|
26
|
+
expect(polygon.get_vertices.length).to eq(vertices.length)
|
27
|
+
vertices.each_index do |i|
|
28
|
+
expect(polygon.get_vertices[i].x).to eq(vertices[i].x)
|
29
|
+
expect(polygon.get_vertices[i].y).to eq(vertices[i].y)
|
30
|
+
end
|
31
|
+
|
32
|
+
vertices = [
|
33
|
+
Snow::Vec2[ 1, 0],
|
34
|
+
Snow::Vec2[ 0, 1],
|
35
|
+
Snow::Vec2[-1, 0]
|
36
|
+
]
|
37
|
+
|
38
|
+
expect { polygon.set_vertices(vertices) }.not_to raise_error
|
39
|
+
expect(polygon.get_vertices.length).to eq(vertices.length)
|
40
|
+
vertices.each_index do |i|
|
41
|
+
expect(polygon.get_vertices[i].x).to eq(vertices[i].x)
|
42
|
+
expect(polygon.get_vertices[i].y).to eq(vertices[i].y)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'accepts an array of arrays of numbers' do
|
47
|
+
vertices = [
|
48
|
+
[ 1, 0, 1],
|
49
|
+
[ 0, 1, 1],
|
50
|
+
[-1, 0, 1]
|
51
|
+
]
|
52
|
+
|
53
|
+
polygon = Gosling::Polygon.new(@window)
|
54
|
+
expect { polygon.set_vertices(vertices) }.not_to raise_error
|
55
|
+
expect(polygon.get_vertices.length).to eq(vertices.length)
|
56
|
+
vertices.each_index do |i|
|
57
|
+
expect(polygon.get_vertices[i].x).to eq(vertices[i][0])
|
58
|
+
expect(polygon.get_vertices[i].y).to eq(vertices[i][1])
|
59
|
+
end
|
60
|
+
|
61
|
+
vertices = [
|
62
|
+
[ 1, 0],
|
63
|
+
[ 0, 1],
|
64
|
+
[-1, 0],
|
65
|
+
[ 0, -1]
|
66
|
+
]
|
67
|
+
|
68
|
+
expect { polygon.set_vertices(vertices) }.not_to raise_error
|
69
|
+
expect(polygon.get_vertices.length).to eq(vertices.length)
|
70
|
+
vertices.each_index do |i|
|
71
|
+
expect(polygon.get_vertices[i].x).to eq(vertices[i][0])
|
72
|
+
expect(polygon.get_vertices[i].y).to eq(vertices[i][1])
|
73
|
+
end
|
27
74
|
end
|
28
75
|
|
29
76
|
it 'raises an error if the parameter is not an array' do
|
@@ -31,14 +78,12 @@ describe Gosling::Polygon do
|
|
31
78
|
expect { polygon.set_vertices("foo") }.to raise_error(ArgumentError)
|
32
79
|
end
|
33
80
|
|
34
|
-
it 'raises an error if the parameter array contains
|
81
|
+
it 'raises an error if the parameter array does not contains vectors or equivalents' do
|
35
82
|
vertices = [
|
36
|
-
[
|
37
|
-
[
|
38
|
-
[
|
39
|
-
[ 0, -1, 1],
|
83
|
+
['21', '3'],
|
84
|
+
['7', '-3'],
|
85
|
+
['4.212', '0.0']
|
40
86
|
]
|
41
|
-
|
42
87
|
polygon = Gosling::Polygon.new(@window)
|
43
88
|
expect { polygon.set_vertices(vertices) }.to raise_error(ArgumentError)
|
44
89
|
end
|
@@ -53,12 +98,12 @@ describe Gosling::Polygon do
|
|
53
98
|
expect { polygon.set_vertices(vertices) }.to raise_error(ArgumentError)
|
54
99
|
end
|
55
100
|
|
56
|
-
it 'raises an error if any vertices in the parameter array are not length
|
101
|
+
it 'raises an error if any vertices in the parameter array are not at least length 2' do
|
57
102
|
vertices = [
|
58
103
|
Snow::Vec3[ 1, 0, 1],
|
59
104
|
Snow::Vec3[ 0, 1, 0],
|
60
105
|
Snow::Vec2[-1, 0],
|
61
|
-
|
106
|
+
[0],
|
62
107
|
]
|
63
108
|
|
64
109
|
polygon = Gosling::Polygon.new(@window)
|
data/spec/transformable_spec.rb
CHANGED
@@ -122,6 +122,12 @@ describe Gosling::Transformable do
|
|
122
122
|
tf.rotation = r
|
123
123
|
expect(tf.rotation).to be == r
|
124
124
|
end
|
125
|
+
|
126
|
+
it 'does not allow non-finite floats' do
|
127
|
+
tf = TransformableThing.new
|
128
|
+
expect { tf.rotation = Float::NAN }.to raise_error(ArgumentError)
|
129
|
+
expect { tf.rotation = Float::INFINITY }.to raise_error(ArgumentError)
|
130
|
+
end
|
125
131
|
end
|
126
132
|
|
127
133
|
describe '#set_translation' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gosling
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Amos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-12-
|
11
|
+
date: 2018-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gosu
|