gosling 2.3.0 → 2.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/lib/gosling.rb +4 -4
- data/lib/gosling/actor.rb +328 -328
- data/lib/gosling/circle.rb +65 -65
- data/lib/gosling/collision.rb +499 -499
- data/lib/gosling/image_library.rb +24 -24
- data/lib/gosling/inheritance_error.rb +4 -4
- data/lib/gosling/matrix_cache.rb +23 -21
- data/lib/gosling/object_cache.rb +48 -48
- data/lib/gosling/patches.rb +42 -42
- data/lib/gosling/polygon.rb +122 -122
- data/lib/gosling/rect.rb +41 -41
- data/lib/gosling/sprite.rb +50 -50
- data/lib/gosling/transformable.rb +413 -413
- data/lib/gosling/utils.rb +20 -20
- data/lib/gosling/vector_cache.rb +21 -21
- data/lib/gosling/version.rb +7 -7
- data/spec/actor_spec.rb +627 -627
- data/spec/circle_spec.rb +46 -46
- data/spec/collision_spec.rb +1755 -1755
- data/spec/image_library_spec.rb +19 -19
- data/spec/matrix_cache_spec.rb +25 -25
- data/spec/object_cache_spec.rb +22 -22
- data/spec/polygon_spec.rb +284 -284
- data/spec/rect_spec.rb +86 -86
- data/spec/spec_helper.rb +3 -3
- data/spec/sprite_spec.rb +45 -45
- data/spec/transformable_spec.rb +479 -479
- data/spec/vector_cache_spec.rb +80 -80
- metadata +3 -4
data/spec/vector_cache_spec.rb
CHANGED
@@ -1,80 +1,80 @@
|
|
1
|
-
class VectorCache
|
2
|
-
def cache
|
3
|
-
@cache
|
4
|
-
end
|
5
|
-
end
|
6
|
-
|
7
|
-
describe VectorCache do
|
8
|
-
describe '.get' do
|
9
|
-
context 'when there are no Vec3 objects available' do
|
10
|
-
before do
|
11
|
-
VectorCache.instance.clear
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'creates a new Vec3 and returns it' do
|
15
|
-
new_vector = Snow::Vec3.new
|
16
|
-
expect(Snow::Vec3).to receive(:new).and_return(new_vector)
|
17
|
-
v = VectorCache.instance.get
|
18
|
-
expect(v).to equal(new_vector)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
context 'when there are Vec3 objects available' do
|
23
|
-
before do
|
24
|
-
VectorCache.instance.clear
|
25
|
-
@recycled_vector = Snow::Vec3.new
|
26
|
-
VectorCache.instance.recycle(@recycled_vector)
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'does not create a new Vec3' do
|
30
|
-
expect(Snow::Vec3).not_to receive(:new)
|
31
|
-
VectorCache.instance.get
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'returns one of the cached Vec3' do
|
35
|
-
expect(VectorCache.instance.get).to eq(@recycled_vector)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe '.recycle' do
|
41
|
-
it 'expects a Vec3' do
|
42
|
-
expect{ VectorCache.instance.recycle(Snow::Vec3.new) }.not_to raise_error
|
43
|
-
expect{ VectorCache.instance.recycle(:foo) }.to raise_error(ArgumentError)
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'adds the Vec3 to the cache' do
|
47
|
-
v = Snow::Vec3.new
|
48
|
-
VectorCache.instance.recycle(v)
|
49
|
-
expect(VectorCache.instance.cache.values).to include(v)
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'zeros out the Vec3' do
|
53
|
-
v = Snow::Vec3[1, 2, 3]
|
54
|
-
VectorCache.instance.recycle(v)
|
55
|
-
expect(v.x).to eq(0)
|
56
|
-
expect(v.y).to eq(0)
|
57
|
-
expect(v.z).to eq(0)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
describe '.clear' do
|
62
|
-
it 'removes all Vec3 from the cache' do
|
63
|
-
VectorCache.instance.recycle(Snow::Vec3.new)
|
64
|
-
VectorCache.instance.recycle(Snow::Vec3.new)
|
65
|
-
VectorCache.instance.recycle(Snow::Vec3.new)
|
66
|
-
VectorCache.instance.clear
|
67
|
-
expect(VectorCache.instance.size).to eq(0)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
describe '.size' do
|
72
|
-
it 'returns the number of Vec3 in the cache' do
|
73
|
-
VectorCache.instance.clear
|
74
|
-
VectorCache.instance.recycle(Snow::Vec3.new)
|
75
|
-
VectorCache.instance.recycle(Snow::Vec3.new)
|
76
|
-
VectorCache.instance.recycle(Snow::Vec3.new)
|
77
|
-
expect(VectorCache.instance.size).to eq(3)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
1
|
+
class VectorCache
|
2
|
+
def cache
|
3
|
+
@cache
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
describe VectorCache do
|
8
|
+
describe '.get' do
|
9
|
+
context 'when there are no Vec3 objects available' do
|
10
|
+
before do
|
11
|
+
VectorCache.instance.clear
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'creates a new Vec3 and returns it' do
|
15
|
+
new_vector = Snow::Vec3.new
|
16
|
+
expect(Snow::Vec3).to receive(:new).and_return(new_vector)
|
17
|
+
v = VectorCache.instance.get
|
18
|
+
expect(v).to equal(new_vector)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'when there are Vec3 objects available' do
|
23
|
+
before do
|
24
|
+
VectorCache.instance.clear
|
25
|
+
@recycled_vector = Snow::Vec3.new
|
26
|
+
VectorCache.instance.recycle(@recycled_vector)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'does not create a new Vec3' do
|
30
|
+
expect(Snow::Vec3).not_to receive(:new)
|
31
|
+
VectorCache.instance.get
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'returns one of the cached Vec3' do
|
35
|
+
expect(VectorCache.instance.get).to eq(@recycled_vector)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '.recycle' do
|
41
|
+
it 'expects a Vec3' do
|
42
|
+
expect{ VectorCache.instance.recycle(Snow::Vec3.new) }.not_to raise_error
|
43
|
+
expect{ VectorCache.instance.recycle(:foo) }.to raise_error(ArgumentError)
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'adds the Vec3 to the cache' do
|
47
|
+
v = Snow::Vec3.new
|
48
|
+
VectorCache.instance.recycle(v)
|
49
|
+
expect(VectorCache.instance.cache.values).to include(v)
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'zeros out the Vec3' do
|
53
|
+
v = Snow::Vec3[1, 2, 3]
|
54
|
+
VectorCache.instance.recycle(v)
|
55
|
+
expect(v.x).to eq(0)
|
56
|
+
expect(v.y).to eq(0)
|
57
|
+
expect(v.z).to eq(0)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe '.clear' do
|
62
|
+
it 'removes all Vec3 from the cache' do
|
63
|
+
VectorCache.instance.recycle(Snow::Vec3.new)
|
64
|
+
VectorCache.instance.recycle(Snow::Vec3.new)
|
65
|
+
VectorCache.instance.recycle(Snow::Vec3.new)
|
66
|
+
VectorCache.instance.clear
|
67
|
+
expect(VectorCache.instance.size).to eq(0)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe '.size' do
|
72
|
+
it 'returns the number of Vec3 in the cache' do
|
73
|
+
VectorCache.instance.clear
|
74
|
+
VectorCache.instance.recycle(Snow::Vec3.new)
|
75
|
+
VectorCache.instance.recycle(Snow::Vec3.new)
|
76
|
+
VectorCache.instance.recycle(Snow::Vec3.new)
|
77
|
+
expect(VectorCache.instance.size).to eq(3)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
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.3.
|
4
|
+
version: 2.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Amos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gosu
|
@@ -114,8 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
114
|
- !ruby/object:Gem::Version
|
115
115
|
version: '0'
|
116
116
|
requirements: []
|
117
|
-
|
118
|
-
rubygems_version: 2.5.2
|
117
|
+
rubygems_version: 3.0.6
|
119
118
|
signing_key:
|
120
119
|
specification_version: 4
|
121
120
|
summary: A library for creating 2D apps
|