minigl 2.0.5 → 2.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 59a470da63cb5c4c17b9d980b5dd01523813c0f1
4
- data.tar.gz: 09b1aa58f421e06a697208b872a103663ff8f0f5
3
+ metadata.gz: ba735bed35dcb47ec7023231533a5f02abde38fe
4
+ data.tar.gz: 3fa15e9e6eed7895295f3e610a7319e8094276e9
5
5
  SHA512:
6
- metadata.gz: 3d006bec2dd92ea67a2b21f6509c9f7a104ca7055592862f2f0173124f59edaeb03e2ca8efc1dadc6801758a9cdabb5ece287c1c50754f7a34a88be82c2b0fc4
7
- data.tar.gz: 5664c64facfa2d3b3f670e1542ae380734fafab5d6b0f0d3b4e76a6b66da81a97859cd21e812ed17e6fc60880de360af0e86a2e23006526e9d4f05d44efb37b9
6
+ metadata.gz: 7e95d7e26cb0b7d1594a874f62de328c34364186bc30615091d811386e40143bcd47329b3dcb831faf475ef5f45567f975294b52505745f9a006302c1ce2e1fd
7
+ data.tar.gz: 38ea70665e7bf11dc36dc1c1ba4bc21808280382fc9a04a1510946cf3b2fc01cac88a8810f328046533d7f8fdc636cd90897fe5aaeb4ebd60d0177a99bb028ec
data/README.md CHANGED
@@ -21,22 +21,16 @@ compiling extensions. Visit
21
21
  [this page](https://github.com/jlnr/gosu/wiki/Getting-Started-on-Linux) for
22
22
  details.
23
23
 
24
- After installing the gosu dependencies, you can just `gem install minigl`.
24
+ After installing the Gosu dependencies, you can just `gem install minigl`.
25
25
 
26
- Please note:
26
+ ## Documentation
27
27
 
28
- * The test package is not complete! Most of the functionality
29
- provided by the gem is difficult to test automatically, but you can check the
30
- examples provided with the gem.
31
- * The library is 100% RDoc-documented.
32
- * An auxiliary, tutorial-like documentation is under construction
33
- [here](https://github.com/victords/minigl/wiki/How-To).
28
+ * The library is 100% RDoc-documented [here](http://www.rubydoc.info/gems/minigl/2.0.5).
29
+ * The [wiki](https://github.com/victords/minigl/wiki) is a work in progress with tutorials and examples.
30
+ * Test package and examples aren't complete!
34
31
 
35
- ## Version 2.0.5
32
+ ## Version 2.0.6
36
33
 
37
- * Further refined the ramp physics.
38
- * Flexibilized the `move_free` method with the possibility of passing an angle
39
- as argument, instead of a point.
40
- * Added `on_changed` event for the `DropDownList` control.
41
- * Adjusted `draw` in `Sprite` and `GameObject` so that, when drawing objects
42
- rotated or not rotated, the origin of the image is consistent.
34
+ * Fixed the `draw` method of `GameObject` when using both scale and flip.
35
+ * Flexibilized the `move_carrying` method from `Movement` with the possibility
36
+ of specifying a forces vector instead of an aim and fixed speed.
@@ -215,13 +215,13 @@ module MiniGL
215
215
 
216
216
  color = (alpha << 24) | color
217
217
  if angle
218
- @img[@img_index].draw_rot @x + (flip == :horiz ? -1 : 1) * @img_gap.x - (map ? map.cam.x : 0) + @img[0].width * scale_x * 0.5,
219
- @y + (flip == :vert ? -1 : 1) * @img_gap.y - (map ? map.cam.y : 0) + @img[0].height * scale_y * 0.5,
218
+ @img[@img_index].draw_rot @x + (flip == :horiz ? -1 : 1) * @img_gap.x - (map ? map.cam.x : 0) + @w * 0.5,
219
+ @y + (flip == :vert ? -1 : 1) * @img_gap.y - (map ? map.cam.y : 0) + @h * 0.5,
220
220
  z_index, angle, 0.5, 0.5, (flip == :horiz ? -scale_x : scale_x),
221
221
  (flip == :vert ? -scale_y : scale_y), color
222
222
  else
223
- @img[@img_index].draw @x + (flip == :horiz ? -1 : 1) * @img_gap.x - (map ? map.cam.x : 0) + (flip == :horiz ? scale_x * @w : 0),
224
- @y + (flip == :vert ? -1 : 1) * @img_gap.y - (map ? map.cam.y : 0) + (flip == :vert ? scale_y * @h : 0),
223
+ @img[@img_index].draw @x + (flip == :horiz ? -1 : 1) * @img_gap.x - (map ? map.cam.x : 0) + (flip == :horiz ? @w : 0),
224
+ @y + (flip == :vert ? -1 : 1) * @img_gap.y - (map ? map.cam.y : 0) + (flip == :vert ? @h : 0),
225
225
  z_index, (flip == :horiz ? -scale_x : scale_x),
226
226
  (flip == :vert ? -scale_y : scale_y), color
227
227
  end
@@ -342,12 +342,14 @@ module MiniGL
342
342
  end
343
343
 
344
344
  # Moves this object as an elevator (i.e., potentially carrying other
345
- # objects) towards a given point.
345
+ # objects) with the specified forces or towards a given point.
346
346
  #
347
347
  # Parameters:
348
- # [aim] A Vector specifying where the object will move to.
349
- # [speed] The constant speed at which the object will move. This must be
350
- # provided as a scalar, not a vector.
348
+ # [arg] A Vector specifying either the forces acting on this object or a
349
+ # point towards the object should move.
350
+ # [speed] If the first argument is a forces vector, then this should be
351
+ # +nil+. If it is a point, then this is the constant speed at which
352
+ # the object will move (provided as a scalar, not a vector).
351
353
  # [obstacles] An array of obstacles to be considered in the collision
352
354
  # checking, and carried along when colliding from above.
353
355
  # Obstacles must be instances of Block (or derived classes),
@@ -358,17 +360,26 @@ module MiniGL
358
360
  # of the objects being carried.
359
361
  # [obst_ramps] Ramps to consider when moving objects from the +obstacles+
360
362
  # array, as described for +obst_obstacles+.
361
- def move_carrying(aim, speed, obstacles, obst_obstacles, obst_ramps)
362
- x_d = aim.x - @x; y_d = aim.y - @y
363
- distance = Math.sqrt(x_d**2 + y_d**2)
363
+ def move_carrying(arg, speed, obstacles, obst_obstacles, obst_ramps)
364
+ if speed
365
+ x_d = arg.x - @x; y_d = arg.y - @y
366
+ distance = Math.sqrt(x_d**2 + y_d**2)
364
367
 
365
- if distance == 0
366
- @speed.x = @speed.y = 0
367
- return
368
- end
368
+ if distance == 0
369
+ @speed.x = @speed.y = 0
370
+ return
371
+ end
369
372
 
370
- @speed.x = 1.0 * x_d * speed / distance
371
- @speed.y = 1.0 * y_d * speed / distance
373
+ @speed.x = 1.0 * x_d * speed / distance
374
+ @speed.y = 1.0 * y_d * speed / distance
375
+ else
376
+ arg += G.gravity
377
+ @speed.x += arg.x / @mass; @speed.y += arg.y / @mass
378
+ @speed.x = 0 if @speed.x.abs < G.min_speed.x
379
+ @speed.y = 0 if @speed.y.abs < G.min_speed.y
380
+ @speed.x = (@speed.x <=> 0) * @max_speed.x if @speed.x.abs > @max_speed.x
381
+ @speed.y = (@speed.y <=> 0) * @max_speed.y if @speed.y.abs > @max_speed.y
382
+ end
372
383
 
373
384
  x_aim = @x + @speed.x; y_aim = @y + @speed.y
374
385
  passengers = []
@@ -382,15 +393,19 @@ module MiniGL
382
393
  end
383
394
 
384
395
  prev_x = @x; prev_y = @y
385
- if @speed.x > 0 && x_aim >= aim.x || @speed.x < 0 && x_aim <= aim.x
386
- @x = aim.x; @speed.x = 0
387
- else
388
- @x = x_aim
389
- end
390
- if @speed.y > 0 && y_aim >= aim.y || @speed.y < 0 && y_aim <= aim.y
391
- @y = aim.y; @speed.y = 0
396
+ if speed
397
+ if @speed.x > 0 && x_aim >= arg.x || @speed.x < 0 && x_aim <= arg.x
398
+ @x = arg.x; @speed.x = 0
399
+ else
400
+ @x = x_aim
401
+ end
402
+ if @speed.y > 0 && y_aim >= arg.y || @speed.y < 0 && y_aim <= arg.y
403
+ @y = arg.y; @speed.y = 0
404
+ else
405
+ @y = y_aim
406
+ end
392
407
  else
393
- @y = y_aim
408
+ @x = x_aim; @y = y_aim
394
409
  end
395
410
 
396
411
  forces = Vector.new @x - prev_x, @y - prev_y
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.5
4
+ version: 2.0.6
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-10-14 00:00:00.000000000 Z
11
+ date: 2016-04-19 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.4.6
93
+ rubygems_version: 2.4.8
94
94
  signing_key:
95
95
  specification_version: 4
96
96
  summary: MiniGL
97
97
  test_files:
98
- - test/map_tests.rb
99
- - test/movement_tests.rb
100
- - test/iso_game.rb
98
+ - test/mov_game.rb
101
99
  - test/game_object_tests.rb
102
100
  - test/game.rb
101
+ - test/iso_game.rb
103
102
  - test/vector_tests.rb
104
- - test/mov_game.rb
103
+ - test/map_tests.rb
104
+ - test/movement_tests.rb
105
105
  - test/res_tests.rb
106
106
  - test/test.png
107
- - test/data/img/image.png
108
- - test/data/img/barfg.svg
109
- - test/data/img/img1.png
107
+ - test/data/tileset/tileset1.png
108
+ - test/data/font/font1.ttf
109
+ - test/data/sound/1.wav
110
+ - test/data/img/check.png
110
111
  - test/data/img/tile2.png
111
- - test/data/img/square.png
112
+ - test/data/img/image.png
113
+ - test/data/img/tile1.png
112
114
  - test/data/img/tile1b.png
115
+ - test/data/img/barbg.svg
116
+ - test/data/img/text.png
113
117
  - test/data/img/btn.png
118
+ - test/data/img/barfg.svg
119
+ - test/data/img/square.png
120
+ - test/data/img/tile1.svg
121
+ - test/data/img/barbg.png
122
+ - test/data/img/img1.png
114
123
  - test/data/img/barfg.png
115
- - test/data/img/square.svg
116
124
  - test/data/img/tile2.svg
117
- - test/data/img/check.png
125
+ - test/data/img/square.svg
118
126
  - test/data/img/tile2b.png
119
- - test/data/img/barbg.svg
120
- - test/data/img/barbg.png
121
- - test/data/img/tile1.png
122
- - test/data/img/text.png
123
- - test/data/img/tile1.svg
124
- - test/data/font/font1.ttf
125
- - test/data/tileset/tileset1.png
126
- - test/data/sound/1.wav
127
127
  - test/data/img/sub/image.png