minigl 2.0.3 → 2.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fda5e695d12ea20cd3a5a85554b55f8fd1bb29e7
4
- data.tar.gz: f864987fbf4fe1a042a4a48191ac2b12625e4602
3
+ metadata.gz: 7634ee7a54cf6f5d281f87adc9b3de17d482a1a3
4
+ data.tar.gz: aaf44d14e4b36c3819fc3b4f942408458cda8ce9
5
5
  SHA512:
6
- metadata.gz: c8850221370b6f6a77412059b6743a341adefbc5f91bbcffff09b24ce351eaa1782c3f1f440d2aba17cf1ed326710ea906a1cac6cac5ed81da79ec5cef188348
7
- data.tar.gz: 2629a2fe8113011548014bfb651afb2b408e921d188a6ab2abd03c352a867000cf39f4f723a52d8cc24cbcf5d98c44c186b51e99b295bc67b19850d05bbfba6c
6
+ metadata.gz: 4bd3a5e2eab16ceba4f5e2123ff78a9b41a819f4e9982318b3ef8642c97a0b0e1605cb38d80ebff2ba78fa8b3933154b9240c64d63f5195376ca54f871320d9a
7
+ data.tar.gz: a07592a6a9b7ccc542dda21cdf2403d36ac46f2c045409f6b9ed3fd6467f36d3d4805ce68d5aad794c018fd7b2f8ce9c9c8021a9225220819a766da0c46b8cc3
data/README.md CHANGED
@@ -32,29 +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.3
36
-
37
- * Flexibilization of various methods and constructors with named parameters.
38
- Please note I haven't used the "official" Ruby syntax for named parameters, but
39
- the "first parameter as hash" technique (in order to keep the positional call
40
- available), so you will need to be careful to include all the mandatory
41
- parameters in your hash, or you could face some strange errors (you can find out
42
- the mandatory parameters in the documentation). Here is the list of flexibilized
43
- methods:
44
- * `GameWindow::new`
45
- * `Sprite#draw`
46
- * `GameObject#draw`
47
- * `TextHelper#write_line`
48
- * `Button::new`
49
- * `ToggleButton::new`
50
- * `TextField::new`
51
- * `ProgressBar::new`
52
- * `DropDownList::new`
53
- * Flexibilization of `Mouse::over?` with the possibility of passing a single
54
- parameter (a `Rectangle` object) instead of four coordinates.
55
- * Passing of the `set_animation` method from `GameObject` to `Sprite`, so the
56
- sprites also support it (`GameObject` still supports because it inherits from
57
- `Sprite`).
58
- * Change of the parameter order in `TextHelper#write_line`, so that `alpha`
59
- comes right after `color`, and not after all the `effect_...` parameters. **This
60
- could generate incompatibility.**
35
+ ## Version 2.0.4
36
+
37
+ * Adjustment in the ramp physics.
38
+ * Adjustment in the `move_carrying` method (from `Movement`) to perform
39
+ collision checking for the carried objects (and corresponding adjustment in the
40
+ `cycle` method).
@@ -235,7 +235,7 @@ module MiniGL
235
235
 
236
236
  if @bottom.is_a? Ramp
237
237
  if @bottom.ratio >= G.ramp_slip_threshold
238
- forces.x = (@bottom.left ? -1 : 1) * G.ramp_slip_force
238
+ forces.x += (@bottom.left ? -1 : 1) * G.ramp_slip_force
239
239
  elsif forces.x > 0 && @bottom.left || forces.x < 0 && !@bottom.left
240
240
  forces.x *= @bottom.factor
241
241
  end
@@ -352,7 +352,13 @@ module MiniGL
352
352
  # checking, and carried along when colliding from above.
353
353
  # Obstacles must be instances of Block (or derived classes),
354
354
  # or objects that <code>include Movement</code>.
355
- def move_carrying(aim, speed, obstacles)
355
+ # [obst_obstacles] Obstacles that should be considered when moving objects
356
+ # from the +obstacles+ array, i.e., these obstacles won't
357
+ # interfere in the elevator's movement, but in the movement
358
+ # of the objects being carried.
359
+ # [obst_ramps] Ramps to consider when moving objects from the +obstacles+
360
+ # array, as described for +obst_obstacles+.
361
+ def move_carrying(aim, speed, obstacles, obst_obstacles, obst_ramps)
356
362
  x_d = aim.x - @x; y_d = aim.y - @y
357
363
  distance = Math.sqrt(x_d**2 + y_d**2)
358
364
 
@@ -375,11 +381,10 @@ module MiniGL
375
381
  end
376
382
  end
377
383
 
384
+ prev_x = @x; prev_y = @y
378
385
  if @speed.x > 0 && x_aim >= aim.x || @speed.x < 0 && x_aim <= aim.x
379
- passengers.each do |p| p.x += aim.x - @x end
380
386
  @x = aim.x; @speed.x = 0
381
387
  else
382
- passengers.each do |p| p.x += @speed.x end
383
388
  @x = x_aim
384
389
  end
385
390
  if @speed.y > 0 && y_aim >= aim.y || @speed.y < 0 && y_aim <= aim.y
@@ -388,7 +393,24 @@ module MiniGL
388
393
  @y = y_aim
389
394
  end
390
395
 
391
- passengers.each do |p| p.y = @y - p.h end
396
+ forces = Vector.new @x - prev_x, @y - prev_y
397
+ prev_g = G.gravity.clone
398
+ G.gravity.x = G.gravity.y = 0
399
+ passengers.each do |p|
400
+ prev_speed = p.speed.clone
401
+ prev_forces = p.stored_forces.clone
402
+ prev_bottom = p.bottom
403
+ p.speed.x = p.speed.y = 0
404
+ p.stored_forces.x = p.stored_forces.y = 0
405
+ p.instance_exec { @bottom = nil }
406
+ p.move forces * p.mass, obst_obstacles, obst_ramps
407
+ p.speed.x = prev_speed.x
408
+ p.speed.y = prev_speed.y
409
+ p.stored_forces.x = prev_forces.x
410
+ p.stored_forces.y = prev_forces.y
411
+ p.instance_exec(prev_bottom) { |b| @bottom = b }
412
+ end
413
+ G.gravity = prev_g
392
414
  end
393
415
 
394
416
  # Moves this object, without performing any collision checking, towards
@@ -440,10 +462,16 @@ module MiniGL
440
462
  # checking, and carried along when colliding from above.
441
463
  # Obstacles must be instances of Block (or derived classes),
442
464
  # or objects that <code>include Movement</code>.
443
- def cycle(points, speed, obstacles = nil)
465
+ # [obst_obstacles] Obstacles that should be considered when moving objects
466
+ # from the +obstacles+ array, i.e., these obstacles won't
467
+ # interfere in the elevator's movement, but in the movement
468
+ # of the objects being carried.
469
+ # [obst_ramps] Ramps to consider when moving objects from the +obstacles+
470
+ # array, as described for +obst_obstacles+.
471
+ def cycle(points, speed, obstacles = nil, obst_obstacles = nil, obst_ramps = nil)
444
472
  @cur_point = 0 if @cur_point.nil?
445
473
  if obstacles
446
- move_carrying points[@cur_point], speed, obstacles
474
+ move_carrying points[@cur_point], speed, obstacles, obst_obstacles, obst_ramps
447
475
  else
448
476
  move_free points[@cur_point], speed
449
477
  end
@@ -1,10 +1,9 @@
1
1
  require_relative '../lib/minigl'
2
2
  include MiniGL
3
3
 
4
- class MyGame < Gosu::Window
4
+ class MyGame < GameWindow
5
5
  def initialize
6
6
  super 800, 600, false
7
- GameWindow.initialize self
8
7
 
9
8
  @tile1 = Res.img :tile2
10
9
  @tile2 = Res.img :tile2b
@@ -31,7 +30,7 @@ class MyGame < Gosu::Window
31
30
 
32
31
  def draw
33
32
  @map.foreach do |i, j, x, y|
34
- if i == @p.x and j == @p.y; @tile2.draw x, y, 0
33
+ if (i - @p.x).abs <= 1 and (j - @p.y).abs <= 1; @tile2.draw x, y, 0
35
34
  else; @tile1.draw x, y, 0; end
36
35
  end
37
36
  end
@@ -12,22 +12,25 @@ class MyGame < GameWindow
12
12
  Block.new(0, 600, 800, 1, false),
13
13
  Block.new(-1, 0, 1, 600, false),
14
14
  Block.new(800, 0, 1, 600, false),
15
+ Block.new(300, 430, 50, 50),
15
16
  # Block.new(375, 550, 50, 50, true),
16
17
  # Block.new(150, 200, 20, 300, false),
17
18
  # Block.new(220, 300, 100, 20, true),
18
19
  # Block.new(485, 490, 127, 10, false),
19
20
  ]
20
21
  @ramps = [
21
- Ramp.new(200, 550, 200, 50, true),
22
- Ramp.new(0, 200, 150, 300, false),
23
- Ramp.new(150, 500, 150, 100, false),
24
- Ramp.new(500, 500, 150, 100, true),
25
- Ramp.new(650, 300, 150, 200, true),
22
+ # Ramp.new(200, 550, 200, 50, true),
23
+ # Ramp.new(0, 200, 150, 300, false),
24
+ # Ramp.new(150, 500, 150, 100, false),
25
+ # Ramp.new(500, 500, 150, 100, true),
26
+ # Ramp.new(650, 300, 150, 200, true),
26
27
  # Ramp.new(650, 500, 150, 100, true),
27
28
  ]
28
29
 
29
- @cyc_obj = GameObject.new(0, 0, 50, 50, :square)
30
- @cycle = [Vector.new(0, 0), Vector.new(430, 107), Vector.new(265, 324)]
30
+ @cycle = [Vector.new(100, 530), Vector.new(650, 500)]
31
+ @cyc_obj = GameObject.new(@cycle[0].x, @cycle[0].y, 50, 50, :square)
32
+ @cyc_obj.instance_eval('@passable = true')
33
+ @obsts.push @cyc_obj
31
34
  end
32
35
 
33
36
  def update
@@ -49,7 +52,7 @@ class MyGame < GameWindow
49
52
  end
50
53
  @obj.move(forces, @obsts, @ramps)
51
54
  # puts @obj.x
52
- @cyc_obj.cycle(@cycle, 5, [@obj])
55
+ @cyc_obj.cycle(@cycle, 5, [@obj], @obsts, @ramps)
53
56
  # puts @obj.bottom
54
57
  end
55
58
 
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minigl
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.0.4
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-03-10 00:00:00.000000000 Z
11
+ date: 2015-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gosu
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0.7'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.7'
27
27
  description: A minimal 2D Game Library built on top of the Gosu gem.
@@ -84,52 +84,52 @@ require_paths:
84
84
  - lib
85
85
  required_ruby_version: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: '2.0'
90
90
  required_rubygems_version: !ruby/object:Gem::Requirement
91
91
  requirements:
92
- - - '>='
92
+ - - ">="
93
93
  - !ruby/object:Gem::Version
94
94
  version: '0'
95
95
  requirements: []
96
96
  rubyforge_project:
97
- rubygems_version: 2.2.2
97
+ rubygems_version: 2.4.6
98
98
  signing_key:
99
99
  specification_version: 4
100
100
  summary: MiniGL
101
101
  test_files:
102
- - test/vector_tests.rb
103
- - test/movement_tests.rb
104
102
  - test/map_tests.rb
105
- - test/game.rb
103
+ - test/movement_tests.rb
106
104
  - test/iso_game.rb
107
- - test/res_tests.rb
108
105
  - test/game_object_tests.rb
106
+ - test/game.rb
107
+ - test/vector_tests.rb
109
108
  - test/mov_game.rb
109
+ - test/res_tests.rb
110
110
  - test/test.png
111
- - test/data/tileset/tileset1.png
112
- - test/data/img/barfg.png
113
- - test/data/img/tile2b.png
114
- - test/data/img/barfgr.svg
111
+ - test/data/img/image.png
112
+ - test/data/img/barfg.svg
113
+ - test/data/img/img1.png
114
+ - test/data/img/tile2.png
115
115
  - test/data/img/barfgl.svg
116
- - test/data/img/tile1.png
117
- - test/data/img/barfgl.png
118
- - test/data/img/btn.png
119
- - test/data/img/barfgr.png
120
116
  - test/data/img/square.png
121
117
  - test/data/img/tile1b.png
122
- - test/data/img/text.png
123
- - test/data/img/img1.png
118
+ - test/data/img/btn.png
119
+ - test/data/img/barfg.png
124
120
  - test/data/img/square.svg
125
- - test/data/img/barbg.svg
126
- - test/data/img/tile1.svg
127
- - test/data/img/image.png
128
- - test/data/img/check.png
129
121
  - test/data/img/tile2.svg
130
- - test/data/img/barfg.svg
122
+ - test/data/img/check.png
123
+ - test/data/img/tile2b.png
124
+ - test/data/img/barbg.svg
131
125
  - test/data/img/barbg.png
132
- - test/data/img/tile2.png
133
- - test/data/sound/1.wav
126
+ - test/data/img/tile1.png
127
+ - test/data/img/barfgr.png
128
+ - test/data/img/barfgl.png
129
+ - test/data/img/barfgr.svg
130
+ - test/data/img/text.png
131
+ - test/data/img/tile1.svg
134
132
  - test/data/font/font1.ttf
133
+ - test/data/tileset/tileset1.png
134
+ - test/data/sound/1.wav
135
135
  - test/data/img/sub/image.png