minigl 2.0.6 → 2.0.7
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 +4 -4
- data/README.md +3 -4
- data/lib/minigl/game_object.rb +39 -0
- data/lib/minigl/map.rb +2 -2
- data/test/game_object_tests.rb +15 -0
- metadata +18 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a008a59987965b59eb3079c99aa5a2b60f82fbd
|
4
|
+
data.tar.gz: 4e3e3eca4a1f661d932a3cabc06c1af59d91bf05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 300cfcd662ddaa79cfcd52adb847412acdfd4adcca706d1803dd566b7ce73f9ce2b05fe11eeb73a3d7ba04ea23fddfac41bf71e811424e1d23746ae297b32d4d
|
7
|
+
data.tar.gz: 97f6e31b2896c911599f676c16700ad8300e9aacef9602dcbfc2617c03537dd2895316a4e0e813aa70acd2d7599783fc02088b3c3b8c4fc38da95c8c7e92f850
|
data/README.md
CHANGED
@@ -29,8 +29,7 @@ After installing the Gosu dependencies, you can just `gem install minigl`.
|
|
29
29
|
* The [wiki](https://github.com/victords/minigl/wiki) is a work in progress with tutorials and examples.
|
30
30
|
* Test package and examples aren't complete!
|
31
31
|
|
32
|
-
## Version 2.0.
|
32
|
+
## Version 2.0.7
|
33
33
|
|
34
|
-
* Fixed the
|
35
|
-
*
|
36
|
-
of specifying a forces vector instead of an aim and fixed speed.
|
34
|
+
* Fixed the camera position for maps smaller than the screen.
|
35
|
+
* Added `animate_once` method to `Sprite`.
|
data/lib/minigl/game_object.rb
CHANGED
@@ -43,6 +43,7 @@ module MiniGL
|
|
43
43
|
@anim_counter = 0
|
44
44
|
@img_index = 0
|
45
45
|
@index_index = 0
|
46
|
+
@animate_once_control = 0
|
46
47
|
end
|
47
48
|
|
48
49
|
# Performs time checking to update the image index according to the
|
@@ -57,6 +58,8 @@ module MiniGL
|
|
57
58
|
# A frame will usually represent 1/60 second (roughly 17
|
58
59
|
# milliseconds).
|
59
60
|
def animate(indices, interval)
|
61
|
+
@animate_once_control = 0 if @animate_once_control != 0
|
62
|
+
|
60
63
|
@anim_counter += 1
|
61
64
|
if @anim_counter >= interval
|
62
65
|
@index_index += 1
|
@@ -66,6 +69,41 @@ module MiniGL
|
|
66
69
|
end
|
67
70
|
end
|
68
71
|
|
72
|
+
# Causes the sprite to animate through the +indices+ array exactly once,
|
73
|
+
# so that the animation stops once it reaches the last index in the array.
|
74
|
+
# Subsequent calls with the same parameters will have no effect, but if
|
75
|
+
# the index or interval changes, or if +set_animation+ is called, then a
|
76
|
+
# new animation cycle will begin.
|
77
|
+
#
|
78
|
+
# Parameters:
|
79
|
+
# [indices] The sequence of image indices used in the animation. See
|
80
|
+
# +animate+ for details.
|
81
|
+
# [interval] The amount of frames between each change in the image index.
|
82
|
+
# See +animate+ for details.
|
83
|
+
def animate_once(indices, interval)
|
84
|
+
if @animate_once_control == 2
|
85
|
+
return if indices == @animate_once_indices && interval == @animate_once_interval
|
86
|
+
@animate_once_control = 0
|
87
|
+
end
|
88
|
+
|
89
|
+
unless @animate_once_control == 1
|
90
|
+
@anim_counter = 0
|
91
|
+
@img_index = indices[0]
|
92
|
+
@index_index = 0
|
93
|
+
@animate_once_indices = indices
|
94
|
+
@animate_once_interval = interval
|
95
|
+
@animate_once_control = 1
|
96
|
+
return
|
97
|
+
end
|
98
|
+
|
99
|
+
@anim_counter += 1
|
100
|
+
return unless @anim_counter >= interval
|
101
|
+
|
102
|
+
@index_index += 1
|
103
|
+
@img_index = indices[@index_index]
|
104
|
+
@animate_once_control = 2 if @index_index == indices.length - 1
|
105
|
+
end
|
106
|
+
|
69
107
|
# Resets the animation timer and immediately changes the image index to
|
70
108
|
# the specified value.
|
71
109
|
#
|
@@ -75,6 +113,7 @@ module MiniGL
|
|
75
113
|
@anim_counter = 0
|
76
114
|
@img_index = index
|
77
115
|
@index_index = 0
|
116
|
+
@animate_once_control = 0
|
78
117
|
end
|
79
118
|
|
80
119
|
# Draws the sprite in the screen
|
data/lib/minigl/map.rb
CHANGED
@@ -181,10 +181,10 @@ module MiniGL
|
|
181
181
|
v4.y = @iso_abs_size.y + @max_offset
|
182
182
|
end
|
183
183
|
else
|
184
|
-
@cam.x = 0 if @cam.x < 0
|
185
184
|
@cam.x = @max_x if @cam.x > @max_x
|
186
|
-
@cam.
|
185
|
+
@cam.x = 0 if @cam.x < 0
|
187
186
|
@cam.y = @max_y if @cam.y > @max_y
|
187
|
+
@cam.y = 0 if @cam.y < 0
|
188
188
|
end
|
189
189
|
end
|
190
190
|
|
data/test/game_object_tests.rb
CHANGED
@@ -25,6 +25,21 @@ class SpriteTest < Test::Unit::TestCase
|
|
25
25
|
assert_equal 0, s.img_index
|
26
26
|
5.times { s.animate indices, interval }
|
27
27
|
assert_equal 2, s.img_index
|
28
|
+
|
29
|
+
10.times { s.animate_once indices, interval }
|
30
|
+
assert_equal 2, s.img_index
|
31
|
+
s.animate_once indices, interval
|
32
|
+
assert_equal 2, s.img_index
|
33
|
+
|
34
|
+
indices2 = [0, 1, 2, 3]
|
35
|
+
s.animate_once indices2, 1
|
36
|
+
assert_equal 0, s.img_index
|
37
|
+
10.times { s.animate_once indices2, interval }
|
38
|
+
assert_equal 3, s.img_index
|
39
|
+
|
40
|
+
s.set_animation 0
|
41
|
+
2.times { s.animate_once indices2, 1 }
|
42
|
+
assert_equal 1, s.img_index
|
28
43
|
end
|
29
44
|
|
30
45
|
def test_sprite_visibility
|
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.0.
|
4
|
+
version: 2.0.7
|
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: 2016-
|
11
|
+
date: 2016-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gosu
|
@@ -90,38 +90,38 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
90
|
version: '0'
|
91
91
|
requirements: []
|
92
92
|
rubyforge_project:
|
93
|
-
rubygems_version: 2.
|
93
|
+
rubygems_version: 2.5.1
|
94
94
|
signing_key:
|
95
95
|
specification_version: 4
|
96
96
|
summary: MiniGL
|
97
97
|
test_files:
|
98
|
+
- test/iso_game.rb
|
99
|
+
- test/game.rb
|
98
100
|
- test/mov_game.rb
|
99
101
|
- test/game_object_tests.rb
|
100
|
-
- test/
|
101
|
-
- test/
|
102
|
+
- test/res_tests.rb
|
103
|
+
- test/movement_tests.rb
|
102
104
|
- test/vector_tests.rb
|
103
105
|
- test/map_tests.rb
|
104
|
-
- test/movement_tests.rb
|
105
|
-
- test/res_tests.rb
|
106
106
|
- test/test.png
|
107
|
-
- test/data/tileset/tileset1.png
|
108
107
|
- test/data/font/font1.ttf
|
109
108
|
- test/data/sound/1.wav
|
109
|
+
- test/data/tileset/tileset1.png
|
110
110
|
- test/data/img/check.png
|
111
|
-
- test/data/img/tile2.png
|
112
111
|
- test/data/img/image.png
|
113
|
-
- test/data/img/
|
114
|
-
- test/data/img/
|
115
|
-
- test/data/img/barbg.svg
|
112
|
+
- test/data/img/square.svg
|
113
|
+
- test/data/img/tile2b.png
|
116
114
|
- test/data/img/text.png
|
117
|
-
- test/data/img/
|
115
|
+
- test/data/img/img1.png
|
118
116
|
- test/data/img/barfg.svg
|
117
|
+
- test/data/img/barbg.svg
|
118
|
+
- test/data/img/tile2.png
|
119
|
+
- test/data/img/tile2.svg
|
119
120
|
- test/data/img/square.png
|
120
|
-
- test/data/img/tile1.svg
|
121
121
|
- test/data/img/barbg.png
|
122
|
-
- test/data/img/
|
122
|
+
- test/data/img/tile1b.png
|
123
|
+
- test/data/img/btn.png
|
123
124
|
- test/data/img/barfg.png
|
124
|
-
- test/data/img/
|
125
|
-
- test/data/img/
|
126
|
-
- test/data/img/tile2b.png
|
125
|
+
- test/data/img/tile1.svg
|
126
|
+
- test/data/img/tile1.png
|
127
127
|
- test/data/img/sub/image.png
|