minigl 2.2.2 → 2.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +19 -19
- data/README.md +35 -36
- data/Rakefile +11 -11
- data/lib/minigl.rb +4 -4
- data/lib/minigl/forms.rb +1485 -1485
- data/lib/minigl/game_object.rb +379 -379
- data/lib/minigl/global.rb +729 -729
- data/lib/minigl/map.rb +256 -256
- data/lib/minigl/movement.rb +585 -585
- data/lib/minigl/text.rb +190 -188
- data/test/data/img/barbg.svg +73 -73
- data/test/data/img/barfg.svg +106 -106
- data/test/data/img/square.svg +66 -66
- data/test/data/img/square2.svg +66 -66
- data/test/data/img/square3.svg +76 -76
- data/test/data/img/tile1.svg +66 -66
- data/test/data/img/tile2.svg +66 -66
- data/test/game.rb +150 -150
- data/test/game_object_tests.rb +108 -108
- data/test/iso_game.rb +39 -39
- data/test/map_tests.rb +57 -57
- data/test/mov_game.rb +76 -76
- data/test/movement_tests.rb +86 -86
- data/test/res_tests.rb +45 -45
- data/test/vector_tests.rb +55 -55
- metadata +24 -24
data/test/movement_tests.rb
CHANGED
@@ -1,86 +1,86 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require_relative '../lib/minigl'
|
3
|
-
include MiniGL
|
4
|
-
|
5
|
-
class MovingObject
|
6
|
-
include Movement
|
7
|
-
def initialize x, y, w, h
|
8
|
-
@x = x; @y = y; @w = w; @h = h
|
9
|
-
@mass = 1.0
|
10
|
-
@speed = Vector.new 0, 0
|
11
|
-
@min_speed = Vector.new 0.01, 0.01
|
12
|
-
@max_speed = Vector.new 1000, 1000
|
13
|
-
@stored_forces = Vector.new 0, 0
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
class MovementTest < Test::Unit::TestCase
|
18
|
-
def setup
|
19
|
-
@window = GameWindow.new 800, 600, false
|
20
|
-
@obsts = [
|
21
|
-
Block.new(-1, 0, 1, 600, false),
|
22
|
-
Block.new(0, -1, 800, 1, false),
|
23
|
-
Block.new(800, 0, 1, 600, false),
|
24
|
-
Block.new(0, 600, 800, 1, false),
|
25
|
-
Block.new(280, 560, 40, 40, true)
|
26
|
-
]
|
27
|
-
@ramps = [
|
28
|
-
Ramp.new(600, 500, 200, 100, true),
|
29
|
-
Ramp.new(0, 500, 200, 100, false)
|
30
|
-
]
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_fall
|
34
|
-
o = MovingObject.new 480, 280, 40, 40
|
35
|
-
forces = Vector.new 0, 0
|
36
|
-
1000.times { o.move forces, @obsts, @ramps }
|
37
|
-
assert_equal 480, o.x
|
38
|
-
assert_equal 560, o.y
|
39
|
-
assert_equal 0, o.speed.x
|
40
|
-
assert_equal 0, o.speed.y
|
41
|
-
assert_equal @obsts[3], o.bottom
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_multiple_collision
|
45
|
-
o = MovingObject.new 750, 10, 40, 40
|
46
|
-
forces = Vector.new 50, -60
|
47
|
-
o.move forces, @obsts, @ramps
|
48
|
-
assert_equal 760, o.x
|
49
|
-
assert_equal 0, o.y
|
50
|
-
assert_equal 0, o.speed.x
|
51
|
-
assert_equal 0, o.speed.y
|
52
|
-
assert_equal @obsts[1], o.top
|
53
|
-
assert_equal @obsts[2], o.right
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_passable
|
57
|
-
o = MovingObject.new 480, 560, 40, 40
|
58
|
-
forces = Vector.new -250, 0
|
59
|
-
o.move forces, @obsts, @ramps
|
60
|
-
assert(o.x < @obsts[4].x)
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_left_ramp
|
64
|
-
o = MovingObject.new 380, 560, 40, 40
|
65
|
-
forces = Vector.new 10, 0
|
66
|
-
1000.times { o.move forces, @obsts, @ramps }
|
67
|
-
assert_equal 760, o.x
|
68
|
-
assert_equal 460, o.y
|
69
|
-
assert_equal 0, o.speed.x
|
70
|
-
assert_equal 0, o.speed.y
|
71
|
-
assert_equal @obsts[2], o.right
|
72
|
-
assert_equal @ramps[0], o.bottom
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_right_ramp
|
76
|
-
o = MovingObject.new 380, 560, 40, 40
|
77
|
-
forces = Vector.new -10, 0
|
78
|
-
1000.times { o.move forces, @obsts, @ramps }
|
79
|
-
assert_equal 0, o.x
|
80
|
-
assert_equal 460, o.y
|
81
|
-
assert_equal 0, o.speed.x
|
82
|
-
assert_equal 0, o.speed.y
|
83
|
-
assert_equal @obsts[0], o.left
|
84
|
-
assert_equal @ramps[1], o.bottom
|
85
|
-
end
|
86
|
-
end
|
1
|
+
require 'test/unit'
|
2
|
+
require_relative '../lib/minigl'
|
3
|
+
include MiniGL
|
4
|
+
|
5
|
+
class MovingObject
|
6
|
+
include Movement
|
7
|
+
def initialize x, y, w, h
|
8
|
+
@x = x; @y = y; @w = w; @h = h
|
9
|
+
@mass = 1.0
|
10
|
+
@speed = Vector.new 0, 0
|
11
|
+
@min_speed = Vector.new 0.01, 0.01
|
12
|
+
@max_speed = Vector.new 1000, 1000
|
13
|
+
@stored_forces = Vector.new 0, 0
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class MovementTest < Test::Unit::TestCase
|
18
|
+
def setup
|
19
|
+
@window = GameWindow.new 800, 600, false
|
20
|
+
@obsts = [
|
21
|
+
Block.new(-1, 0, 1, 600, false),
|
22
|
+
Block.new(0, -1, 800, 1, false),
|
23
|
+
Block.new(800, 0, 1, 600, false),
|
24
|
+
Block.new(0, 600, 800, 1, false),
|
25
|
+
Block.new(280, 560, 40, 40, true)
|
26
|
+
]
|
27
|
+
@ramps = [
|
28
|
+
Ramp.new(600, 500, 200, 100, true),
|
29
|
+
Ramp.new(0, 500, 200, 100, false)
|
30
|
+
]
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_fall
|
34
|
+
o = MovingObject.new 480, 280, 40, 40
|
35
|
+
forces = Vector.new 0, 0
|
36
|
+
1000.times { o.move forces, @obsts, @ramps }
|
37
|
+
assert_equal 480, o.x
|
38
|
+
assert_equal 560, o.y
|
39
|
+
assert_equal 0, o.speed.x
|
40
|
+
assert_equal 0, o.speed.y
|
41
|
+
assert_equal @obsts[3], o.bottom
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_multiple_collision
|
45
|
+
o = MovingObject.new 750, 10, 40, 40
|
46
|
+
forces = Vector.new 50, -60
|
47
|
+
o.move forces, @obsts, @ramps
|
48
|
+
assert_equal 760, o.x
|
49
|
+
assert_equal 0, o.y
|
50
|
+
assert_equal 0, o.speed.x
|
51
|
+
assert_equal 0, o.speed.y
|
52
|
+
assert_equal @obsts[1], o.top
|
53
|
+
assert_equal @obsts[2], o.right
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_passable
|
57
|
+
o = MovingObject.new 480, 560, 40, 40
|
58
|
+
forces = Vector.new -250, 0
|
59
|
+
o.move forces, @obsts, @ramps
|
60
|
+
assert(o.x < @obsts[4].x)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_left_ramp
|
64
|
+
o = MovingObject.new 380, 560, 40, 40
|
65
|
+
forces = Vector.new 10, 0
|
66
|
+
1000.times { o.move forces, @obsts, @ramps }
|
67
|
+
assert_equal 760, o.x
|
68
|
+
assert_equal 460, o.y
|
69
|
+
assert_equal 0, o.speed.x
|
70
|
+
assert_equal 0, o.speed.y
|
71
|
+
assert_equal @obsts[2], o.right
|
72
|
+
assert_equal @ramps[0], o.bottom
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_right_ramp
|
76
|
+
o = MovingObject.new 380, 560, 40, 40
|
77
|
+
forces = Vector.new -10, 0
|
78
|
+
1000.times { o.move forces, @obsts, @ramps }
|
79
|
+
assert_equal 0, o.x
|
80
|
+
assert_equal 460, o.y
|
81
|
+
assert_equal 0, o.speed.x
|
82
|
+
assert_equal 0, o.speed.y
|
83
|
+
assert_equal @obsts[0], o.left
|
84
|
+
assert_equal @ramps[1], o.bottom
|
85
|
+
end
|
86
|
+
end
|
data/test/res_tests.rb
CHANGED
@@ -1,45 +1,45 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require_relative '../lib/minigl'
|
3
|
-
include MiniGL
|
4
|
-
|
5
|
-
class ResTest < Test::Unit::TestCase
|
6
|
-
def setup
|
7
|
-
@window = GameWindow.new 800, 600, false
|
8
|
-
Res.prefix = File.expand_path(File.dirname(__FILE__)) + '/data'
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_tileset
|
12
|
-
t1 = Res.tileset :tileset1
|
13
|
-
assert_equal 9, t1.length
|
14
|
-
assert_equal 32, t1[0].width
|
15
|
-
assert_equal 32, t1[0].width
|
16
|
-
Res.clear
|
17
|
-
t1 = Res.tileset :tileset1, 48, 48
|
18
|
-
assert_equal 4, t1.length
|
19
|
-
assert_equal 48, t1[0].width
|
20
|
-
assert_equal 48, t1[0].width
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_dirs_and_separator
|
24
|
-
assert_nothing_raised do
|
25
|
-
img1 = Res.img :img1
|
26
|
-
end
|
27
|
-
|
28
|
-
Res.img_dir = 'img/sub'
|
29
|
-
assert_nothing_raised do
|
30
|
-
img2 = Res.img :image
|
31
|
-
end
|
32
|
-
|
33
|
-
Res.img_dir = 'img'
|
34
|
-
Res.separator = '~'
|
35
|
-
assert_nothing_raised do
|
36
|
-
img3 = Res.img 'sub~image'
|
37
|
-
end
|
38
|
-
|
39
|
-
Res.prefix = File.expand_path(File.dirname(__FILE__))
|
40
|
-
Res.img_dir = ''
|
41
|
-
assert_nothing_raised do
|
42
|
-
img4 = Res.img :test
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
1
|
+
require 'test/unit'
|
2
|
+
require_relative '../lib/minigl'
|
3
|
+
include MiniGL
|
4
|
+
|
5
|
+
class ResTest < Test::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
@window = GameWindow.new 800, 600, false
|
8
|
+
Res.prefix = File.expand_path(File.dirname(__FILE__)) + '/data'
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_tileset
|
12
|
+
t1 = Res.tileset :tileset1
|
13
|
+
assert_equal 9, t1.length
|
14
|
+
assert_equal 32, t1[0].width
|
15
|
+
assert_equal 32, t1[0].width
|
16
|
+
Res.clear
|
17
|
+
t1 = Res.tileset :tileset1, 48, 48
|
18
|
+
assert_equal 4, t1.length
|
19
|
+
assert_equal 48, t1[0].width
|
20
|
+
assert_equal 48, t1[0].width
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_dirs_and_separator
|
24
|
+
assert_nothing_raised do
|
25
|
+
img1 = Res.img :img1
|
26
|
+
end
|
27
|
+
|
28
|
+
Res.img_dir = 'img/sub'
|
29
|
+
assert_nothing_raised do
|
30
|
+
img2 = Res.img :image
|
31
|
+
end
|
32
|
+
|
33
|
+
Res.img_dir = 'img'
|
34
|
+
Res.separator = '~'
|
35
|
+
assert_nothing_raised do
|
36
|
+
img3 = Res.img 'sub~image'
|
37
|
+
end
|
38
|
+
|
39
|
+
Res.prefix = File.expand_path(File.dirname(__FILE__))
|
40
|
+
Res.img_dir = ''
|
41
|
+
assert_nothing_raised do
|
42
|
+
img4 = Res.img :test
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/test/vector_tests.rb
CHANGED
@@ -1,56 +1,56 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require_relative '../lib/minigl'
|
3
|
-
include MiniGL
|
4
|
-
|
5
|
-
class VectorTest < Test::Unit::TestCase
|
6
|
-
def test_vector_comparison
|
7
|
-
v1 = Vector.new 1, 2
|
8
|
-
v2 = v1.clone
|
9
|
-
assert v1 == v2
|
10
|
-
assert !(v1 != v2)
|
11
|
-
|
12
|
-
v1 = Vector.new 1.37, 4.56
|
13
|
-
v2 = Vector.new 1.373, 4.562
|
14
|
-
assert v1.==(v2, 2)
|
15
|
-
assert v1.!=(v2, 3)
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_vector_operations
|
19
|
-
v1 = Vector.new 1, 1
|
20
|
-
v2 = Vector.new 2, 3
|
21
|
-
|
22
|
-
v3 = v1 + v2
|
23
|
-
assert_equal 3, v3.x
|
24
|
-
assert_equal 4, v3.y
|
25
|
-
|
26
|
-
v3 = v1 - v2
|
27
|
-
assert_equal -1, v3.x
|
28
|
-
assert_equal -2, v3.y
|
29
|
-
|
30
|
-
v3 = v2 * 3
|
31
|
-
assert_equal 6, v3.x
|
32
|
-
assert_equal 9, v3.y
|
33
|
-
|
34
|
-
v3 = v2 / 2
|
35
|
-
assert_equal 1, v3.x
|
36
|
-
assert_equal 1.5, v3.y
|
37
|
-
|
38
|
-
v3 = Vector.new 0, Math.sqrt(2)
|
39
|
-
assert v1.rotate(Math::PI / 4) == v3
|
40
|
-
|
41
|
-
v1.rotate! Math::PI / 4
|
42
|
-
assert v1 == v3
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_vector_distance
|
46
|
-
v1 = Vector.new 1, 1
|
47
|
-
v2 = Vector.new 2, 3
|
48
|
-
d = v1.distance v2
|
49
|
-
assert_equal Math.sqrt(5), d
|
50
|
-
|
51
|
-
v1 = Vector.new 0, 3
|
52
|
-
v2 = Vector.new 4, 0
|
53
|
-
d = v1.distance v2
|
54
|
-
assert_equal 5, d
|
55
|
-
end
|
1
|
+
require 'test/unit'
|
2
|
+
require_relative '../lib/minigl'
|
3
|
+
include MiniGL
|
4
|
+
|
5
|
+
class VectorTest < Test::Unit::TestCase
|
6
|
+
def test_vector_comparison
|
7
|
+
v1 = Vector.new 1, 2
|
8
|
+
v2 = v1.clone
|
9
|
+
assert v1 == v2
|
10
|
+
assert !(v1 != v2)
|
11
|
+
|
12
|
+
v1 = Vector.new 1.37, 4.56
|
13
|
+
v2 = Vector.new 1.373, 4.562
|
14
|
+
assert v1.==(v2, 2)
|
15
|
+
assert v1.!=(v2, 3)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_vector_operations
|
19
|
+
v1 = Vector.new 1, 1
|
20
|
+
v2 = Vector.new 2, 3
|
21
|
+
|
22
|
+
v3 = v1 + v2
|
23
|
+
assert_equal 3, v3.x
|
24
|
+
assert_equal 4, v3.y
|
25
|
+
|
26
|
+
v3 = v1 - v2
|
27
|
+
assert_equal -1, v3.x
|
28
|
+
assert_equal -2, v3.y
|
29
|
+
|
30
|
+
v3 = v2 * 3
|
31
|
+
assert_equal 6, v3.x
|
32
|
+
assert_equal 9, v3.y
|
33
|
+
|
34
|
+
v3 = v2 / 2
|
35
|
+
assert_equal 1, v3.x
|
36
|
+
assert_equal 1.5, v3.y
|
37
|
+
|
38
|
+
v3 = Vector.new 0, Math.sqrt(2)
|
39
|
+
assert v1.rotate(Math::PI / 4) == v3
|
40
|
+
|
41
|
+
v1.rotate! Math::PI / 4
|
42
|
+
assert v1 == v3
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_vector_distance
|
46
|
+
v1 = Vector.new 1, 1
|
47
|
+
v2 = Vector.new 2, 3
|
48
|
+
d = v1.distance v2
|
49
|
+
assert_equal Math.sqrt(5), d
|
50
|
+
|
51
|
+
v1 = Vector.new 0, 3
|
52
|
+
v2 = Vector.new 4, 0
|
53
|
+
d = v1.distance v2
|
54
|
+
assert_equal 5, d
|
55
|
+
end
|
56
56
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minigl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor David Santos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gosu
|
@@ -94,42 +94,42 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
94
|
version: '0'
|
95
95
|
requirements: []
|
96
96
|
rubyforge_project:
|
97
|
-
rubygems_version: 2.7.
|
97
|
+
rubygems_version: 2.7.6
|
98
98
|
signing_key:
|
99
99
|
specification_version: 4
|
100
100
|
summary: MiniGL
|
101
101
|
test_files:
|
102
|
-
- test/res_tests.rb
|
103
|
-
- test/iso_game.rb
|
104
|
-
- test/mov_game.rb
|
105
|
-
- test/map_tests.rb
|
106
102
|
- test/game.rb
|
107
103
|
- test/game_object_tests.rb
|
108
|
-
- test/
|
104
|
+
- test/iso_game.rb
|
105
|
+
- test/map_tests.rb
|
109
106
|
- test/movement_tests.rb
|
107
|
+
- test/mov_game.rb
|
108
|
+
- test/res_tests.rb
|
109
|
+
- test/vector_tests.rb
|
110
110
|
- test/test.png
|
111
111
|
- test/data/font/font1.ttf
|
112
|
-
- test/data/img/square.svg
|
113
112
|
- test/data/img/barbg.png
|
114
|
-
- test/data/img/
|
115
|
-
- test/data/img/tile1.png
|
116
|
-
- test/data/img/tile2b.png
|
117
|
-
- test/data/img/text.png
|
118
|
-
- test/data/img/btn.png
|
119
|
-
- test/data/img/square2.svg
|
120
|
-
- test/data/img/square2.png
|
113
|
+
- test/data/img/barbg.svg
|
121
114
|
- test/data/img/barfg.png
|
122
|
-
- test/data/img/
|
123
|
-
- test/data/img/
|
115
|
+
- test/data/img/barfg.svg
|
116
|
+
- test/data/img/btn.png
|
124
117
|
- test/data/img/check.png
|
125
|
-
- test/data/img/
|
118
|
+
- test/data/img/image.png
|
119
|
+
- test/data/img/img1.png
|
120
|
+
- test/data/img/square.png
|
121
|
+
- test/data/img/square.svg
|
122
|
+
- test/data/img/square2.png
|
123
|
+
- test/data/img/square2.svg
|
126
124
|
- test/data/img/square3.png
|
127
125
|
- test/data/img/square3.svg
|
128
|
-
- test/data/img/
|
126
|
+
- test/data/img/text.png
|
127
|
+
- test/data/img/tile1.png
|
129
128
|
- test/data/img/tile1.svg
|
130
|
-
- test/data/img/
|
131
|
-
- test/data/img/
|
132
|
-
- test/data/img/
|
133
|
-
- test/data/
|
129
|
+
- test/data/img/tile1b.png
|
130
|
+
- test/data/img/tile2.png
|
131
|
+
- test/data/img/tile2.svg
|
132
|
+
- test/data/img/tile2b.png
|
134
133
|
- test/data/sound/1.wav
|
134
|
+
- test/data/tileset/tileset1.png
|
135
135
|
- test/data/img/sub/image.png
|