minigl 2.0.7 → 2.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -3
- data/lib/minigl/movement.rb +24 -15
- data/test/data/img/square2.png +0 -0
- data/test/data/img/square2.svg +66 -0
- data/test/mov_game.rb +12 -11
- 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: f2d491becfcc152fa203005e847196c2e8478b16
|
4
|
+
data.tar.gz: a24b621bb5ba72fcfed720ef25b80bdce7df9e24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d176e2cdc27315f39b357ba35eaaaaef109891d8187b961b30b73f13dc8b5c14e40619b3f5af470ae07ff49e4eb3f59df9ab16b396f7804611fe9141e2cc273
|
7
|
+
data.tar.gz: c9e3862fd8dc80b0541f2cddf9db7d83c10d9e17bbd329dd3c56cb14c0dd9d7c80fad90a30fb73f2505709276db950f4cd4429664bf3aa737e241cde35cc7173
|
data/README.md
CHANGED
@@ -29,7 +29,6 @@ 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.8
|
33
33
|
|
34
|
-
*
|
35
|
-
* Added `animate_once` method to `Sprite`.
|
34
|
+
* Added the `set_speed` option to `Movement#move`.
|
data/lib/minigl/movement.rb
CHANGED
@@ -225,28 +225,37 @@ module MiniGL
|
|
225
225
|
# objects that <code>include Movement</code>.
|
226
226
|
# [ramps] An array of ramps to be considered in the collision checking.
|
227
227
|
# Ramps must be instances of Ramp (or derived classes).
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
228
|
+
# [set_speed] Set this flag to +true+ to cause the +forces+ vector to be
|
229
|
+
# treated as a speed vector, i.e., the object's speed will be
|
230
|
+
# directly set to the given values. The force of gravity will
|
231
|
+
# also be ignored in this case.
|
232
|
+
def move(forces, obst, ramps, set_speed = false)
|
233
|
+
if set_speed
|
234
|
+
@speed.x = forces.x
|
235
|
+
@speed.y = forces.y
|
236
|
+
else
|
237
|
+
forces.x += G.gravity.x; forces.y += G.gravity.y
|
238
|
+
forces.x += @stored_forces.x; forces.y += @stored_forces.y
|
239
|
+
@stored_forces.x = @stored_forces.y = 0
|
240
|
+
|
241
|
+
forces.x = 0 if (forces.x < 0 and @left) or (forces.x > 0 and @right)
|
242
|
+
forces.y = 0 if (forces.y < 0 and @top) or (forces.y > 0 and @bottom)
|
243
|
+
|
244
|
+
if @bottom.is_a? Ramp
|
245
|
+
if @bottom.ratio > G.ramp_slip_threshold
|
246
|
+
forces.x += (@bottom.left ? -1 : 1) * (@bottom.ratio - G.ramp_slip_threshold) * G.ramp_slip_force / G.ramp_slip_threshold
|
247
|
+
elsif forces.x > 0 && @bottom.left || forces.x < 0 && !@bottom.left
|
248
|
+
forces.x *= @bottom.factor
|
249
|
+
end
|
241
250
|
end
|
251
|
+
|
252
|
+
@speed.x += forces.x / @mass; @speed.y += forces.y / @mass
|
242
253
|
end
|
243
254
|
|
244
|
-
@speed.x += forces.x / @mass; @speed.y += forces.y / @mass
|
245
255
|
@speed.x = 0 if @speed.x.abs < G.min_speed.x
|
246
256
|
@speed.y = 0 if @speed.y.abs < G.min_speed.y
|
247
257
|
@speed.x = (@speed.x <=> 0) * @max_speed.x if @speed.x.abs > @max_speed.x
|
248
258
|
@speed.y = (@speed.y <=> 0) * @max_speed.y if @speed.y.abs > @max_speed.y
|
249
|
-
|
250
259
|
@prev_speed = @speed.clone
|
251
260
|
|
252
261
|
x = @speed.x < 0 ? @x + @speed.x : @x
|
Binary file
|
@@ -0,0 +1,66 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
+
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
3
|
+
|
4
|
+
<svg
|
5
|
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
6
|
+
xmlns:cc="http://creativecommons.org/ns#"
|
7
|
+
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
8
|
+
xmlns:svg="http://www.w3.org/2000/svg"
|
9
|
+
xmlns="http://www.w3.org/2000/svg"
|
10
|
+
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
11
|
+
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
12
|
+
width="50"
|
13
|
+
height="50"
|
14
|
+
id="svg2"
|
15
|
+
version="1.1"
|
16
|
+
inkscape:version="0.91 r13725"
|
17
|
+
sodipodi:docname="square2.svg"
|
18
|
+
inkscape:export-filename="/home/victor/aleva/minigl/test/data/img/square2.png"
|
19
|
+
inkscape:export-xdpi="90"
|
20
|
+
inkscape:export-ydpi="90">
|
21
|
+
<defs
|
22
|
+
id="defs4" />
|
23
|
+
<sodipodi:namedview
|
24
|
+
id="base"
|
25
|
+
pagecolor="#ffffff"
|
26
|
+
bordercolor="#666666"
|
27
|
+
borderopacity="1.0"
|
28
|
+
inkscape:pageopacity="0.0"
|
29
|
+
inkscape:pageshadow="2"
|
30
|
+
inkscape:zoom="11.68"
|
31
|
+
inkscape:cx="11.429795"
|
32
|
+
inkscape:cy="25"
|
33
|
+
inkscape:document-units="px"
|
34
|
+
inkscape:current-layer="layer1"
|
35
|
+
showgrid="false"
|
36
|
+
inkscape:window-width="1920"
|
37
|
+
inkscape:window-height="1026"
|
38
|
+
inkscape:window-x="0"
|
39
|
+
inkscape:window-y="0"
|
40
|
+
inkscape:window-maximized="1" />
|
41
|
+
<metadata
|
42
|
+
id="metadata7">
|
43
|
+
<rdf:RDF>
|
44
|
+
<cc:Work
|
45
|
+
rdf:about="">
|
46
|
+
<dc:format>image/svg+xml</dc:format>
|
47
|
+
<dc:type
|
48
|
+
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
49
|
+
<dc:title></dc:title>
|
50
|
+
</cc:Work>
|
51
|
+
</rdf:RDF>
|
52
|
+
</metadata>
|
53
|
+
<g
|
54
|
+
inkscape:label="Layer 1"
|
55
|
+
inkscape:groupmode="layer"
|
56
|
+
id="layer1"
|
57
|
+
transform="translate(0,-1002.3622)">
|
58
|
+
<rect
|
59
|
+
style="fill:#99ffff;fill-opacity:1;stroke:none"
|
60
|
+
id="rect3753"
|
61
|
+
width="50"
|
62
|
+
height="50"
|
63
|
+
x="0"
|
64
|
+
y="1002.3622" />
|
65
|
+
</g>
|
66
|
+
</svg>
|
data/test/mov_game.rb
CHANGED
@@ -7,7 +7,8 @@ class MyGame < GameWindow
|
|
7
7
|
super 800, 600, false
|
8
8
|
|
9
9
|
@obj = GameObject.new(0, 0, 50, 50, :square)
|
10
|
-
|
10
|
+
@obj2 = GameObject.new(100, 0, 50, 50, :square2)
|
11
|
+
|
11
12
|
@obsts = [
|
12
13
|
Block.new(0, 600, 800, 1, false),
|
13
14
|
Block.new(-1, 0, 1, 600, false),
|
@@ -39,26 +40,26 @@ class MyGame < GameWindow
|
|
39
40
|
forces = Vector.new(0, 0)
|
40
41
|
if @obj.bottom
|
41
42
|
forces.y -= 15 if KB.key_pressed?(Gosu::KbSpace)
|
42
|
-
if KB.key_down?(Gosu::KbLeft)
|
43
|
-
|
44
|
-
end
|
45
|
-
if KB.key_down?(Gosu::KbRight)
|
46
|
-
forces.x += 0.5
|
47
|
-
end
|
43
|
+
forces.x -= 0.5 if KB.key_down?(Gosu::KbLeft)
|
44
|
+
forces.x += 0.5 if KB.key_down?(Gosu::KbRight)
|
48
45
|
forces.x -= @obj.speed.x * 0.1
|
49
46
|
else
|
50
47
|
forces.x -= 0.2 if KB.key_down?(Gosu::KbLeft)
|
51
48
|
forces.x += 0.2 if KB.key_down?(Gosu::KbRight)
|
52
49
|
end
|
53
50
|
@obj.move(forces, @obsts, @ramps)
|
54
|
-
|
55
|
-
|
56
|
-
|
51
|
+
|
52
|
+
speed = Vector.new(0, 0)
|
53
|
+
speed.y -= 3 if KB.key_down? Gosu::KbW
|
54
|
+
speed.y += 3 if KB.key_down? Gosu::KbS
|
55
|
+
speed.x -= 3 if KB.key_down? Gosu::KbA
|
56
|
+
speed.x += 3 if KB.key_down? Gosu::KbD
|
57
|
+
@obj2.move(speed, @obsts, @ramps, true)
|
57
58
|
end
|
58
59
|
|
59
60
|
def draw
|
60
61
|
@obj.draw
|
61
|
-
|
62
|
+
@obj2.draw
|
62
63
|
@obsts.each do |o|
|
63
64
|
draw_quad o.x, o.y, 0xffffffff,
|
64
65
|
o.x + o.w, o.y, 0xffffffff,
|
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.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:
|
11
|
+
date: 2017-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gosu
|
@@ -51,6 +51,8 @@ files:
|
|
51
51
|
- test/data/img/img1.png
|
52
52
|
- test/data/img/square.png
|
53
53
|
- test/data/img/square.svg
|
54
|
+
- test/data/img/square2.png
|
55
|
+
- test/data/img/square2.svg
|
54
56
|
- test/data/img/sub/image.png
|
55
57
|
- test/data/img/text.png
|
56
58
|
- test/data/img/tile1.png
|
@@ -116,6 +118,8 @@ test_files:
|
|
116
118
|
- test/data/img/barfg.svg
|
117
119
|
- test/data/img/barbg.svg
|
118
120
|
- test/data/img/tile2.png
|
121
|
+
- test/data/img/square2.svg
|
122
|
+
- test/data/img/square2.png
|
119
123
|
- test/data/img/tile2.svg
|
120
124
|
- test/data/img/square.png
|
121
125
|
- test/data/img/barbg.png
|