minigl 1.3.7 → 1.3.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,55 +3,55 @@ require_relative '../lib/minigl'
3
3
  include AGL
4
4
 
5
5
  class MapTest < Test::Unit::TestCase
6
- def test_map_attributes
7
- m = Map.new 16, 16, 300, 200
8
- assert_equal 16, m.tile_size.x
9
- assert_equal 16, m.tile_size.y
10
- assert_equal 300, m.size.x
11
- assert_equal 200, m.size.y
12
- assert_equal 0, m.cam.x
13
- assert_equal 0, m.cam.y
14
- m = Map.new 25, 17, 49, 133
15
- assert_equal 25, m.tile_size.x
16
- assert_equal 17, m.tile_size.y
17
- assert_equal 49, m.size.x
18
- assert_equal 133, m.size.y
19
- assert_equal 0, m.cam.x
20
- assert_equal 0, m.cam.y
21
- end
22
-
23
- def test_absolute_size
24
- m = Map.new 16, 16, 300, 200
25
- v = m.get_absolute_size
26
- assert_equal 300 * 16, v.x
27
- assert_equal 200 * 16, v.y
28
- end
29
-
30
- def test_center
31
- m = Map.new 16, 16, 300, 200
32
- v = m.get_center
33
- assert_equal 300 * 16 / 2, v.x
34
- assert_equal 200 * 16 / 2, v.y
35
- end
36
-
37
- def test_screen_pos
38
- m = Map.new 16, 16, 300, 200
39
- v = m.get_screen_pos 8, 5
40
- assert_equal 8 * 16, v.x
41
- assert_equal 5 * 16, v.y
42
- end
43
-
44
- def test_map_pos
45
- m = Map.new 16, 16, 300, 200
46
- v = m.get_map_pos 410, 300
47
- assert_equal 25, v.x
48
- assert_equal 18, v.y
49
- end
50
-
51
- def test_in_map
52
- m = Map.new 16, 16, 300, 200
53
- assert m.is_in_map(Vector.new 30, 20)
54
- assert m.is_in_map(Vector.new 299, 199)
55
- assert !m.is_in_map(Vector.new 300, 200)
56
- end
6
+ def test_map_attributes
7
+ m = Map.new 16, 16, 300, 200
8
+ assert_equal 16, m.tile_size.x
9
+ assert_equal 16, m.tile_size.y
10
+ assert_equal 300, m.size.x
11
+ assert_equal 200, m.size.y
12
+ assert_equal 0, m.cam.x
13
+ assert_equal 0, m.cam.y
14
+ m = Map.new 25, 17, 49, 133
15
+ assert_equal 25, m.tile_size.x
16
+ assert_equal 17, m.tile_size.y
17
+ assert_equal 49, m.size.x
18
+ assert_equal 133, m.size.y
19
+ assert_equal 0, m.cam.x
20
+ assert_equal 0, m.cam.y
21
+ end
22
+
23
+ def test_absolute_size
24
+ m = Map.new 16, 16, 300, 200
25
+ v = m.get_absolute_size
26
+ assert_equal 300 * 16, v.x
27
+ assert_equal 200 * 16, v.y
28
+ end
29
+
30
+ def test_center
31
+ m = Map.new 16, 16, 300, 200
32
+ v = m.get_center
33
+ assert_equal 300 * 16 / 2, v.x
34
+ assert_equal 200 * 16 / 2, v.y
35
+ end
36
+
37
+ def test_screen_pos
38
+ m = Map.new 16, 16, 300, 200
39
+ v = m.get_screen_pos 8, 5
40
+ assert_equal 8 * 16, v.x
41
+ assert_equal 5 * 16, v.y
42
+ end
43
+
44
+ def test_map_pos
45
+ m = Map.new 16, 16, 300, 200
46
+ v = m.get_map_pos 410, 300
47
+ assert_equal 25, v.x
48
+ assert_equal 18, v.y
49
+ end
50
+
51
+ def test_in_map
52
+ m = Map.new 16, 16, 300, 200
53
+ assert m.is_in_map(Vector.new 30, 20)
54
+ assert m.is_in_map(Vector.new 299, 199)
55
+ assert !m.is_in_map(Vector.new 300, 200)
56
+ end
57
57
  end
@@ -3,85 +3,85 @@ require_relative '../lib/minigl'
3
3
  include AGL
4
4
 
5
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
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
15
  end
16
16
 
17
17
  class MovementTest < Test::Unit::TestCase
18
- def setup
19
- @window = Gosu::Window.new 800, 600, false
20
- Game.initialize @window
21
- @obsts = [
22
- Block.new(-1, 0, 1, 600, false),
23
- Block.new(0, -1, 800, 1, false),
24
- Block.new(800, 0, 1, 600, false),
25
- Block.new(0, 600, 800, 1, false),
26
- Block.new(280, 560, 40, 40, true)
27
- ]
28
- @ramps = [
29
- Ramp.new(600, 500, 200, 100, true),
30
- Ramp.new(0, 500, 200, 100, false)
31
- ]
32
- end
33
-
34
- def test_fall
35
- o = MovingObject.new 480, 280, 40, 40
36
- forces = Vector.new 0, 0
37
- 1000.times { o.move forces, @obsts, @ramps }
38
- assert_equal 480, o.x
39
- assert_equal 560, o.y
40
- assert_equal 0, o.speed.x
41
- assert_equal 0, o.speed.y
42
- assert_equal @obsts[3], o.bottom
43
- end
44
-
45
- def test_multiple_collision
46
- o = MovingObject.new 750, 10, 40, 40
47
- forces = Vector.new 50, -60
48
- o.move forces, @obsts, @ramps
49
- assert_equal 760, o.x
50
- assert_equal 0, o.y
51
- assert_equal 0, o.speed.x
52
- assert_equal 0, o.speed.y
53
- assert_equal @obsts[1], o.top
54
- assert_equal @obsts[2], o.right
55
- end
56
-
57
- def test_passable
58
- o = MovingObject.new 480, 560, 40, 40
59
- forces = Vector.new -250, 0
60
- o.move forces, @obsts, @ramps
61
- assert(o.x < @obsts[4].x)
62
- end
63
-
64
- def test_left_ramp
65
- o = MovingObject.new 380, 560, 40, 40
66
- forces = Vector.new 10, 0
67
- 1000.times { o.move forces, @obsts, @ramps }
68
- assert_equal 760, o.x
69
- assert_equal 460, o.y
70
- assert_equal 0, o.speed.x
71
- assert_equal 0, o.speed.y
72
- assert_equal @obsts[2], o.right
73
- assert_equal @ramps[0], o.bottom
74
- end
75
-
76
- def test_right_ramp
77
- o = MovingObject.new 380, 560, 40, 40
78
- forces = Vector.new -10, 0
79
- 1000.times { o.move forces, @obsts, @ramps }
80
- assert_equal 0, o.x
81
- assert_equal 460, o.y
82
- assert_equal 0, o.speed.x
83
- assert_equal 0, o.speed.y
84
- assert_equal @obsts[0], o.left
85
- assert_equal @ramps[1], o.bottom
86
- end
18
+ def setup
19
+ @window = Gosu::Window.new 800, 600, false
20
+ Game.initialize @window
21
+ @obsts = [
22
+ Block.new(-1, 0, 1, 600, false),
23
+ Block.new(0, -1, 800, 1, false),
24
+ Block.new(800, 0, 1, 600, false),
25
+ Block.new(0, 600, 800, 1, false),
26
+ Block.new(280, 560, 40, 40, true)
27
+ ]
28
+ @ramps = [
29
+ Ramp.new(600, 500, 200, 100, true),
30
+ Ramp.new(0, 500, 200, 100, false)
31
+ ]
32
+ end
33
+
34
+ def test_fall
35
+ o = MovingObject.new 480, 280, 40, 40
36
+ forces = Vector.new 0, 0
37
+ 1000.times { o.move forces, @obsts, @ramps }
38
+ assert_equal 480, o.x
39
+ assert_equal 560, o.y
40
+ assert_equal 0, o.speed.x
41
+ assert_equal 0, o.speed.y
42
+ assert_equal @obsts[3], o.bottom
43
+ end
44
+
45
+ def test_multiple_collision
46
+ o = MovingObject.new 750, 10, 40, 40
47
+ forces = Vector.new 50, -60
48
+ o.move forces, @obsts, @ramps
49
+ assert_equal 760, o.x
50
+ assert_equal 0, o.y
51
+ assert_equal 0, o.speed.x
52
+ assert_equal 0, o.speed.y
53
+ assert_equal @obsts[1], o.top
54
+ assert_equal @obsts[2], o.right
55
+ end
56
+
57
+ def test_passable
58
+ o = MovingObject.new 480, 560, 40, 40
59
+ forces = Vector.new -250, 0
60
+ o.move forces, @obsts, @ramps
61
+ assert(o.x < @obsts[4].x)
62
+ end
63
+
64
+ def test_left_ramp
65
+ o = MovingObject.new 380, 560, 40, 40
66
+ forces = Vector.new 10, 0
67
+ 1000.times { o.move forces, @obsts, @ramps }
68
+ assert_equal 760, o.x
69
+ assert_equal 460, o.y
70
+ assert_equal 0, o.speed.x
71
+ assert_equal 0, o.speed.y
72
+ assert_equal @obsts[2], o.right
73
+ assert_equal @ramps[0], o.bottom
74
+ end
75
+
76
+ def test_right_ramp
77
+ o = MovingObject.new 380, 560, 40, 40
78
+ forces = Vector.new -10, 0
79
+ 1000.times { o.move forces, @obsts, @ramps }
80
+ assert_equal 0, o.x
81
+ assert_equal 460, o.y
82
+ assert_equal 0, o.speed.x
83
+ assert_equal 0, o.speed.y
84
+ assert_equal @obsts[0], o.left
85
+ assert_equal @ramps[1], o.bottom
86
+ end
87
87
  end
@@ -3,21 +3,21 @@ require_relative '../lib/minigl'
3
3
  include AGL
4
4
 
5
5
  class ResTest < Test::Unit::TestCase
6
- def setup
7
- @window = Gosu::Window.new 800, 600, false
8
- Game.initialize @window
6
+ def setup
7
+ @window = Gosu::Window.new 800, 600, false
8
+ Game.initialize @window
9
9
  Res.prefix = File.expand_path(File.dirname(__FILE__)) + '/data'
10
- end
10
+ end
11
11
 
12
- def test_tileset
13
- t1 = Res.tileset :tileset1
14
- assert_equal 9, t1.length
15
- assert_equal 32, t1[0].width
16
- assert_equal 32, t1[0].width
17
- Res.clear
18
- t1 = Res.tileset :tileset1, 48, 48
19
- assert_equal 4, t1.length
20
- assert_equal 48, t1[0].width
21
- assert_equal 48, t1[0].width
22
- end
12
+ def test_tileset
13
+ t1 = Res.tileset :tileset1
14
+ assert_equal 9, t1.length
15
+ assert_equal 32, t1[0].width
16
+ assert_equal 32, t1[0].width
17
+ Res.clear
18
+ t1 = Res.tileset :tileset1, 48, 48
19
+ assert_equal 4, t1.length
20
+ assert_equal 48, t1[0].width
21
+ assert_equal 48, t1[0].width
22
+ end
23
23
  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: 1.3.7
4
+ version: 1.3.8
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: 2014-10-25 00:00:00.000000000 Z
11
+ date: 2014-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gosu