minigl 2.0.0 → 2.0.1
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 +5 -12
- data/lib/minigl/forms.rb +1 -1
- data/lib/minigl/global.rb +14 -7
- data/lib/minigl/movement.rb +9 -4
- data/test/data/img/sub/image.png +0 -0
- data/test/mov_game.rb +3 -2
- data/test/res_tests.rb +8 -0
- data/test/test.png +0 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73063e68c52aec583e98389abe3d1334e8a33858
|
4
|
+
data.tar.gz: 511d49a8cf23a537c0abf4ca2b35f5e290b11bc7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28646ae5580a7df1b0a7488e2c227068c20c692614a385903040a16573451ebe891e1e222a5292db9fddac2a342a3bf398c10efb687584ef21781214953a95c4
|
7
|
+
data.tar.gz: 8183695054e721eca9f52ccc4962348983a9e0964cafb430cffe3c2303377216ccc81383a43c035d76b70a70ac59bd48aa18b97a11c10af2e727ab4ce75beed5
|
data/README.md
CHANGED
@@ -32,16 +32,9 @@ examples provided with the gem.
|
|
32
32
|
* An auxiliary, tutorial-like documentation is under construction
|
33
33
|
[here](https://github.com/victords/minigl/wiki/How-To).
|
34
34
|
|
35
|
-
**Version 2.0.
|
35
|
+
**Version 2.0.1**
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
[the changelog](https://github.com/victords/minigl/wiki/Changelog-(2.0.0)).
|
42
|
-
|
43
|
-
As the semantic versioning implies, **this version is incompatible with the 1.x
|
44
|
-
series**, so you'll need to adjust your code a little if you wish to upgrade.
|
45
|
-
|
46
|
-
A new tutorial has to be built, because there have been some changes even in the
|
47
|
-
basics of the usage. So please be patient while it doesn't come out!
|
37
|
+
* Adjustment in the ramp slip system. Parameterized the force applied by steep
|
38
|
+
ramps (`G.ramp_slip_force`).
|
39
|
+
* Adjustment in the methods that change the prefix and directories used by
|
40
|
+
`Res`, allowing empty prefixes/directory names.
|
data/lib/minigl/forms.rb
CHANGED
@@ -813,7 +813,7 @@ module MiniGL
|
|
813
813
|
@fg_color = fg
|
814
814
|
else # String or Symbol
|
815
815
|
@fg = Res.img fg
|
816
|
-
@fg_path = "#{Res.prefix}
|
816
|
+
@fg_path = "#{Res.prefix}#{Res.img_dir}#{fg.to_s.gsub(Res.separator, '/')}.png"
|
817
817
|
puts @fg_path
|
818
818
|
end
|
819
819
|
@fg_margin_x = fg_margin_x
|
data/lib/minigl/global.rb
CHANGED
@@ -142,6 +142,10 @@ module MiniGL
|
|
142
142
|
# <code>GameWindow#initialize</code> for details.
|
143
143
|
attr_accessor :ramp_slip_threshold
|
144
144
|
|
145
|
+
# Gets or sets the value of ramp_slip_force. See
|
146
|
+
# <code>GameWindow#initialize</code> for details.
|
147
|
+
attr_accessor :ramp_slip_force
|
148
|
+
|
145
149
|
# Gets or sets the value of kb_held_delay. See
|
146
150
|
# <code>GameWindow#initialize</code> for details.
|
147
151
|
attr_accessor :kb_held_delay
|
@@ -178,6 +182,8 @@ module MiniGL
|
|
178
182
|
# [ramp_slip_threshold] The maximum ratio between height and width of a ramp
|
179
183
|
# above which the objects will always slip down when
|
180
184
|
# trying to 'climb' that ramp.
|
185
|
+
# [ramp_slip_force] The force that will be applied in the horizontal
|
186
|
+
# direction when the object is slipping from a steep ramp.
|
181
187
|
# [kb_held_delay] The number of frames a key must be held by the user
|
182
188
|
# before the "held" event (that can be checked with
|
183
189
|
# <code>KB.key_held?</code>) starts to trigger.
|
@@ -189,7 +195,7 @@ module MiniGL
|
|
189
195
|
# (checked with <code>Mouse.double_click?</code>).
|
190
196
|
def initialize(scr_w, scr_h, fullscreen = true,
|
191
197
|
gravity = Vector.new(0, 1), min_speed = Vector.new(0.01, 0.01),
|
192
|
-
ramp_contact_threshold =
|
198
|
+
ramp_contact_threshold = 4, ramp_slip_threshold = 1.2, ramp_slip_force = 0.1,
|
193
199
|
kb_held_delay = 40, kb_held_interval = 5, double_click_delay = 8)
|
194
200
|
super scr_w, scr_h, fullscreen
|
195
201
|
G.window = self
|
@@ -197,6 +203,7 @@ module MiniGL
|
|
197
203
|
G.min_speed = min_speed
|
198
204
|
G.ramp_contact_threshold = ramp_contact_threshold
|
199
205
|
G.ramp_slip_threshold = ramp_slip_threshold
|
206
|
+
G.ramp_slip_force = ramp_slip_force
|
200
207
|
G.kb_held_delay = kb_held_delay
|
201
208
|
G.kb_held_interval = kb_held_interval
|
202
209
|
G.double_click_delay = double_click_delay
|
@@ -501,37 +508,37 @@ module MiniGL
|
|
501
508
|
# directory of the game script. The prefix is the directory under which
|
502
509
|
# 'img', 'sound', 'song', etc. folders are located.
|
503
510
|
def prefix=(value)
|
504
|
-
value += '/' if value[-1] != '/'
|
511
|
+
value += '/' if value != '' and value[-1] != '/'
|
505
512
|
@prefix = value
|
506
513
|
end
|
507
514
|
|
508
515
|
# Sets the path to image files (under +prefix+). Default is 'img'.
|
509
516
|
def img_dir=(value)
|
510
|
-
value += '/' if value[-1] != '/'
|
517
|
+
value += '/' if value != '' and value[-1] != '/'
|
511
518
|
@img_dir = value
|
512
519
|
end
|
513
520
|
|
514
521
|
# Sets the path to tilset files (under +prefix+). Default is 'tileset'.
|
515
522
|
def tileset_dir=(value)
|
516
|
-
value += '/' if value[-1] != '/'
|
523
|
+
value += '/' if value != '' and value[-1] != '/'
|
517
524
|
@tileset_dir = value
|
518
525
|
end
|
519
526
|
|
520
527
|
# Sets the path to sound files (under +prefix+). Default is 'sound'.
|
521
528
|
def sound_dir=(value)
|
522
|
-
value += '/' if value[-1] != '/'
|
529
|
+
value += '/' if value != '' and value[-1] != '/'
|
523
530
|
@sound_dir = value
|
524
531
|
end
|
525
532
|
|
526
533
|
# Sets the path to song files (under +prefix+). Default is 'song'.
|
527
534
|
def song_dir=(value)
|
528
|
-
value += '/' if value[-1] != '/'
|
535
|
+
value += '/' if value != '' and value[-1] != '/'
|
529
536
|
@song_dir = value
|
530
537
|
end
|
531
538
|
|
532
539
|
# Sets the path to font files (under +prefix+). Default is 'font'.
|
533
540
|
def font_dir=(value)
|
534
|
-
value += '/' if value[-1] != '/'
|
541
|
+
value += '/' if value != '' and value[-1] != '/'
|
535
542
|
@font_dir = value
|
536
543
|
end
|
537
544
|
|
data/lib/minigl/movement.rb
CHANGED
@@ -67,6 +67,7 @@ module MiniGL
|
|
67
67
|
attr_reader :left
|
68
68
|
|
69
69
|
attr_reader :ratio # :nodoc:
|
70
|
+
attr_reader :factor # :nodoc:
|
70
71
|
|
71
72
|
# Creates a new ramp.
|
72
73
|
#
|
@@ -91,7 +92,7 @@ module MiniGL
|
|
91
92
|
@h = h
|
92
93
|
@left = left
|
93
94
|
@ratio = @h.to_f / @w
|
94
|
-
@factor =
|
95
|
+
@factor = @w / Math.sqrt(@w**2 + @h**2)
|
95
96
|
end
|
96
97
|
|
97
98
|
# Checks if an object is in contact with this ramp (standing over it).
|
@@ -129,7 +130,7 @@ module MiniGL
|
|
129
130
|
obj.x += dx
|
130
131
|
end
|
131
132
|
obj.y = get_y obj
|
132
|
-
if counter
|
133
|
+
if counter && obj.bottom != self
|
133
134
|
obj.speed.x *= @factor
|
134
135
|
end
|
135
136
|
obj.speed.y = 0
|
@@ -232,8 +233,12 @@ module MiniGL
|
|
232
233
|
forces.x = 0 if (forces.x < 0 and @left) or (forces.x > 0 and @right)
|
233
234
|
forces.y = 0 if (forces.y < 0 and @top) or (forces.y > 0 and @bottom)
|
234
235
|
|
235
|
-
if @bottom.is_a? Ramp
|
236
|
-
|
236
|
+
if @bottom.is_a? Ramp
|
237
|
+
if @bottom.ratio >= G.ramp_slip_threshold
|
238
|
+
forces.x = (@bottom.left ? -1 : 1) * G.ramp_slip_force
|
239
|
+
elsif forces.x > 0 && @bottom.left || forces.x < 0 && !@bottom.left
|
240
|
+
forces.x *= @bottom.factor
|
241
|
+
end
|
237
242
|
end
|
238
243
|
|
239
244
|
@speed.x += forces.x / @mass; @speed.y += forces.y / @mass
|
Binary file
|
data/test/mov_game.rb
CHANGED
@@ -18,11 +18,12 @@ class MyGame < GameWindow
|
|
18
18
|
# Block.new(485, 490, 127, 10, false),
|
19
19
|
]
|
20
20
|
@ramps = [
|
21
|
-
|
22
|
-
Ramp.new(0,
|
21
|
+
Ramp.new(200, 550, 200, 50, true),
|
22
|
+
Ramp.new(0, 200, 150, 300, false),
|
23
23
|
Ramp.new(150, 500, 150, 100, false),
|
24
24
|
Ramp.new(500, 500, 150, 100, true),
|
25
25
|
Ramp.new(650, 300, 150, 200, true),
|
26
|
+
# Ramp.new(650, 500, 150, 100, true),
|
26
27
|
]
|
27
28
|
|
28
29
|
@cyc_obj = GameObject.new(0, 0, 50, 50, :square)
|
data/test/res_tests.rb
CHANGED
@@ -24,14 +24,22 @@ class ResTest < Test::Unit::TestCase
|
|
24
24
|
assert_nothing_raised do
|
25
25
|
img1 = Res.img :img1
|
26
26
|
end
|
27
|
+
|
27
28
|
Res.img_dir = 'img/sub'
|
28
29
|
assert_nothing_raised do
|
29
30
|
img2 = Res.img :image
|
30
31
|
end
|
32
|
+
|
31
33
|
Res.img_dir = 'img'
|
32
34
|
Res.separator = '~'
|
33
35
|
assert_nothing_raised do
|
34
36
|
img3 = Res.img 'sub~image'
|
35
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
|
36
44
|
end
|
37
45
|
end
|
data/test/test.png
ADDED
Binary file
|
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.1
|
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: 2015-
|
11
|
+
date: 2015-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gosu
|
@@ -55,6 +55,7 @@ files:
|
|
55
55
|
- test/data/img/img1.png
|
56
56
|
- test/data/img/square.png
|
57
57
|
- test/data/img/square.svg
|
58
|
+
- test/data/img/sub/image.png
|
58
59
|
- test/data/img/text.png
|
59
60
|
- test/data/img/tile1.png
|
60
61
|
- test/data/img/tile1.svg
|
@@ -71,6 +72,7 @@ files:
|
|
71
72
|
- test/mov_game.rb
|
72
73
|
- test/movement_tests.rb
|
73
74
|
- test/res_tests.rb
|
75
|
+
- test/test.png
|
74
76
|
- test/vector_tests.rb
|
75
77
|
homepage: https://github.com/victords/minigl
|
76
78
|
licenses:
|
@@ -105,6 +107,7 @@ test_files:
|
|
105
107
|
- test/res_tests.rb
|
106
108
|
- test/game_object_tests.rb
|
107
109
|
- test/mov_game.rb
|
110
|
+
- test/test.png
|
108
111
|
- test/data/tileset/tileset1.png
|
109
112
|
- test/data/img/barfg.png
|
110
113
|
- test/data/img/tile2b.png
|
@@ -129,3 +132,4 @@ test_files:
|
|
129
132
|
- test/data/img/tile2.png
|
130
133
|
- test/data/sound/1.wav
|
131
134
|
- test/data/font/font1.ttf
|
135
|
+
- test/data/img/sub/image.png
|