minigl 2.2.8 → 2.2.9
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/lib/minigl/movement.rb +30 -33
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79bd9440a172b26f147083ef8bd486af9adcaded814bf84473535c24704f2ded
|
4
|
+
data.tar.gz: 667b535e408b7d3302e45c4b3d02fe5fa20d85c4e31b8af68eaa4f1023851a68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a26a33090716a53212cf084158ed623cb9d54e28407a990e8238f2784ca679a08d42908a03c23266836e830943afde4f5176f4d8946ba7302530f895d5b347a
|
7
|
+
data.tar.gz: e60f740c8eec1033d01adb79af11d2960e709bd5a0df1165949622a6ba43ce49e9dc8fcb8d7f6c0ba93bd550fad1382dbf2ed73187038162561489b01f206399
|
data/lib/minigl/movement.rb
CHANGED
@@ -360,17 +360,16 @@ module MiniGL
|
|
360
360
|
# [speed] If the first argument is a forces vector, then this should be
|
361
361
|
# +nil+. If it is a point, then this is the constant speed at which
|
362
362
|
# the object will move (provided as a scalar, not a vector).
|
363
|
-
# [
|
364
|
-
#
|
365
|
-
#
|
366
|
-
#
|
367
|
-
#
|
368
|
-
#
|
369
|
-
#
|
370
|
-
#
|
371
|
-
#
|
372
|
-
|
373
|
-
def move_carrying(arg, speed, obstacles, obst_obstacles, obst_ramps)
|
363
|
+
# [carried_objs] An array of objects that can potentially be carried by
|
364
|
+
# this object while it moves. The objects must respond to
|
365
|
+
# +x+, +y+, +w+ and +h+.
|
366
|
+
# [obstacles] Obstacles that should be considered for collision checking
|
367
|
+
# with the carried objects, if they include the +Movement+
|
368
|
+
# module, and with this object too, if moving with forces.
|
369
|
+
# [ramps] Ramps that should be considered for the carried objects, if they
|
370
|
+
# include the +Movement+ module, and for this object too, if moving
|
371
|
+
# with forces.
|
372
|
+
def move_carrying(arg, speed, carried_objs, obstacles, ramps)
|
374
373
|
if speed
|
375
374
|
x_d = arg.x - @x; y_d = arg.y - @y
|
376
375
|
distance = Math.sqrt(x_d**2 + y_d**2)
|
@@ -382,18 +381,11 @@ module MiniGL
|
|
382
381
|
|
383
382
|
@speed.x = 1.0 * x_d * speed / distance
|
384
383
|
@speed.y = 1.0 * y_d * speed / distance
|
385
|
-
|
386
|
-
arg += G.gravity
|
387
|
-
@speed.x += arg.x / @mass; @speed.y += arg.y / @mass
|
388
|
-
@speed.x = 0 if @speed.x.abs < G.min_speed.x
|
389
|
-
@speed.y = 0 if @speed.y.abs < G.min_speed.y
|
390
|
-
@speed.x = (@speed.x <=> 0) * @max_speed.x if @speed.x.abs > @max_speed.x
|
391
|
-
@speed.y = (@speed.y <=> 0) * @max_speed.y if @speed.y.abs > @max_speed.y
|
384
|
+
x_aim = @x + @speed.x; y_aim = @y + @speed.y
|
392
385
|
end
|
393
386
|
|
394
|
-
x_aim = @x + @speed.x; y_aim = @y + @speed.y
|
395
387
|
passengers = []
|
396
|
-
|
388
|
+
carried_objs.each do |o|
|
397
389
|
if @x + @w > o.x && o.x + o.w > @x
|
398
390
|
foot = o.y + o.h
|
399
391
|
if foot.round(6) == @y.round(6) || @speed.y < 0 && foot < @y && foot > y_aim
|
@@ -415,25 +407,30 @@ module MiniGL
|
|
415
407
|
@y = y_aim
|
416
408
|
end
|
417
409
|
else
|
418
|
-
|
410
|
+
move(arg, obstacles, ramps)
|
419
411
|
end
|
420
412
|
|
421
413
|
forces = Vector.new @x - prev_x, @y - prev_y
|
422
414
|
prev_g = G.gravity.clone
|
423
415
|
G.gravity.x = G.gravity.y = 0
|
424
416
|
passengers.each do |p|
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
417
|
+
if p.class.included_modules.include?(Movement)
|
418
|
+
prev_speed = p.speed.clone
|
419
|
+
prev_forces = p.stored_forces.clone
|
420
|
+
prev_bottom = p.bottom
|
421
|
+
p.speed.x = p.speed.y = 0
|
422
|
+
p.stored_forces.x = p.stored_forces.y = 0
|
423
|
+
p.instance_exec { @bottom = nil }
|
424
|
+
p.move(forces * p.mass, obstacles, ramps)
|
425
|
+
p.speed.x = prev_speed.x
|
426
|
+
p.speed.y = prev_speed.y
|
427
|
+
p.stored_forces.x = prev_forces.x
|
428
|
+
p.stored_forces.y = prev_forces.y
|
429
|
+
p.instance_exec(prev_bottom) { |b| @bottom = b }
|
430
|
+
else
|
431
|
+
p.x += forces.x
|
432
|
+
p.y += forces.y
|
433
|
+
end
|
437
434
|
end
|
438
435
|
G.gravity = prev_g
|
439
436
|
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.9
|
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: 2020-
|
11
|
+
date: 2020-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gosu
|