fantasy 0.1.11 → 0.1.17

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.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +22 -1
  3. data/.yardopts +4 -0
  4. data/CHANGELOG.md +6 -0
  5. data/Gemfile +1 -1
  6. data/Gemfile.lock +55 -0
  7. data/README.md +36 -13
  8. data/docs/Actor.html +2737 -0
  9. data/docs/Background.html +961 -0
  10. data/docs/Camera.html +791 -0
  11. data/docs/Clock.html +753 -0
  12. data/docs/Color.html +776 -0
  13. data/docs/Coordinates.html +730 -0
  14. data/docs/Cursor.html +752 -0
  15. data/docs/Disk.html +236 -0
  16. data/docs/Draggable.html +198 -0
  17. data/docs/Fantasy.html +121 -0
  18. data/docs/Game.html +904 -0
  19. data/docs/Global.html +2791 -0
  20. data/docs/Gravitier.html +179 -0
  21. data/docs/HudImage.html +979 -0
  22. data/docs/HudText.html +1151 -0
  23. data/docs/Image.html +506 -0
  24. data/docs/Jumper.html +189 -0
  25. data/docs/Mouse.html +226 -0
  26. data/docs/MoveByCursor.html +374 -0
  27. data/docs/MoveByDirection.html +179 -0
  28. data/docs/Mover.html +305 -0
  29. data/docs/Music.html +524 -0
  30. data/docs/Shape.html +1057 -0
  31. data/docs/Sound.html +374 -0
  32. data/docs/Tilemap.html +491 -0
  33. data/docs/Tween.html +186 -0
  34. data/docs/UserInputs.html +879 -0
  35. data/docs/Utils.html +345 -0
  36. data/docs/_index.html +346 -0
  37. data/docs/class_list.html +51 -0
  38. data/docs/css/common.css +1 -0
  39. data/docs/css/full_list.css +58 -0
  40. data/docs/css/style.css +497 -0
  41. data/docs/file.CHANGELOG.html +121 -0
  42. data/docs/file.README.html +599 -0
  43. data/docs/file_list.html +61 -0
  44. data/docs/frames.html +17 -0
  45. data/docs/index.html +599 -0
  46. data/docs/js/app.js +314 -0
  47. data/docs/js/full_list.js +216 -0
  48. data/docs/js/jquery.js +4 -0
  49. data/docs/method_list.html +1931 -0
  50. data/docs/top-level-namespace.html +978 -0
  51. data/lib/fantasy/actor.rb +455 -112
  52. data/lib/fantasy/background.rb +109 -13
  53. data/lib/fantasy/base.rb +113 -1
  54. data/lib/fantasy/camera.rb +95 -11
  55. data/lib/fantasy/clock.rb +4 -2
  56. data/lib/fantasy/color.rb +158 -153
  57. data/lib/fantasy/coordinates.rb +5 -9
  58. data/lib/fantasy/cursor.rb +22 -0
  59. data/lib/fantasy/disk.rb +35 -0
  60. data/lib/fantasy/draggable.rb +22 -1
  61. data/lib/fantasy/global.rb +59 -31
  62. data/lib/fantasy/hud_image.rb +5 -3
  63. data/lib/fantasy/hud_text.rb +9 -3
  64. data/lib/fantasy/image.rb +12 -4
  65. data/lib/fantasy/includes/gravitier.rb +2 -0
  66. data/lib/fantasy/includes/jumper.rb +3 -2
  67. data/lib/fantasy/includes/log.rb +12 -0
  68. data/lib/fantasy/includes/move_by_cursors.rb +24 -15
  69. data/lib/fantasy/includes/move_by_direction.rb +2 -0
  70. data/lib/fantasy/includes/mover.rb +7 -0
  71. data/lib/fantasy/includes/user_inputs.rb +6 -0
  72. data/lib/fantasy/loop.rb +41 -44
  73. data/lib/fantasy/mouse.rb +2 -0
  74. data/lib/fantasy/music.rb +7 -3
  75. data/lib/fantasy/shape.rb +11 -2
  76. data/lib/fantasy/sound.rb +5 -3
  77. data/lib/fantasy/tilemap.rb +19 -13
  78. data/lib/fantasy/tween.rb +3 -1
  79. data/lib/fantasy/utils.rb +7 -13
  80. data/lib/fantasy/version.rb +1 -1
  81. data/lib/fantasy.rb +3 -0
  82. metadata +91 -4
  83. data/fantasy.gemspec +0 -40
  84. data/fonts/VT323-Regular.ttf +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fb68d8561352d746b2ccdbec94196c568436a0164619f325f0762c200d9d4a71
4
- data.tar.gz: a11a5b19442edc60fc11d3c803ec40df543c9f1a176f7f7d6a3b11ad4dcf2eed
3
+ metadata.gz: 0d18d89b226d845f1a7f3a85ec0eb26efd18ad3d4820e35079b5d93bf2844fad
4
+ data.tar.gz: 60bf1ff81ec6fcec9a4225e0550dc110d6d0686742f4ac6e6611f8f1b7e43158
5
5
  SHA512:
6
- metadata.gz: e705ad65f134cf775e3bf2ef847643bbd8a2efcc49630837f555f57df019573c9356190db394cddb647ed95420441ea0ce8d42099ba43f006c89e05b63452fa9
7
- data.tar.gz: c6e6506581053c11940b0fd3bed2205ae4b003a2efd35016a84e04640cc75ad9300a8276ff8562ec8f33eba229b3017c7ba4f38306d165271d637e7c0e51b66a
6
+ metadata.gz: d2876e85b3def3d90aeb0ad7792a1cc56b6ef8a59c5a967827d5271a6fa13fcd053fa1d2008a2abc7cbd85e477c89ad224a5fac4640abb47ee0447de1d5349bd
7
+ data.tar.gz: 9c39646cebbfc0588b760604c89367022c5feb5c7d2836f1b68aa2c957790d5fce125b97f0ab3a49191234323bbccb3a0d638e6b359c45261f89bf2295e6b7cf
data/.rubocop.yml CHANGED
@@ -10,4 +10,25 @@ Style/StringLiteralsInInterpolation:
10
10
  EnforcedStyle: double_quotes
11
11
 
12
12
  Layout/LineLength:
13
- Max: 120
13
+ Max: 180
14
+
15
+ Style/IfUnlessModifier:
16
+ Enabled: false
17
+
18
+ Naming/MethodParameterName:
19
+ AllowedNames: ["x", "y", "to", "r", "g", "b", "a", "up"]
20
+
21
+ Naming/VariableNumber:
22
+ EnforcedStyle: snake_case
23
+
24
+ Metrics/MethodLength:
25
+ Max: 15
26
+
27
+ Style/AccessorGrouping:
28
+ Enabled: false
29
+
30
+ Metrics/ModuleLength:
31
+ Max: 180
32
+
33
+ Metrics/ClassLength:
34
+ Max: 180
data/.yardopts ADDED
@@ -0,0 +1,4 @@
1
+ --no-private - README.md CHANGELOG.md
2
+ --markup markdown
3
+ --markup-provider redcarpet
4
+ --output-dir docs
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## [0.1.13] - 2022-04-01
2
+
3
+ - Data Persistance: Disk module
4
+ - Sound and Music support for volume configuration
5
+
6
+
1
7
  ## [0.1.11] - 2022-03-26
2
8
 
3
9
  - Better jumping and gravity physics
data/Gemfile CHANGED
@@ -7,6 +7,6 @@ ruby ">= 3.0.0"
7
7
  # Specify your gem's dependencies in fantasy.gemspec
8
8
  gemspec
9
9
 
10
- gem "rake", "~> 13.0"
11
10
  gem "minitest", "~> 5.0"
11
+ gem "rake", "~> 13.0"
12
12
  gem "rubocop", "~> 1.21"
data/Gemfile.lock ADDED
@@ -0,0 +1,55 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ fantasy (0.1.13)
5
+ gosu (~> 1.4.1)
6
+ vector2d (~> 2.2.3)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ ast (2.4.2)
12
+ contracts (0.9)
13
+ gosu (1.4.3)
14
+ minitest (5.15.0)
15
+ parallel (1.22.1)
16
+ parser (3.1.1.0)
17
+ ast (~> 2.4.1)
18
+ rainbow (3.1.1)
19
+ rake (13.0.6)
20
+ regexp_parser (2.2.1)
21
+ rexml (3.2.5)
22
+ rubocop (1.26.1)
23
+ parallel (~> 1.10)
24
+ parser (>= 3.1.0.0)
25
+ rainbow (>= 2.2.2, < 4.0)
26
+ regexp_parser (>= 1.8, < 3.0)
27
+ rexml
28
+ rubocop-ast (>= 1.16.0, < 2.0)
29
+ ruby-progressbar (~> 1.7)
30
+ unicode-display_width (>= 1.4.0, < 3.0)
31
+ rubocop-ast (1.16.0)
32
+ parser (>= 3.1.1.0)
33
+ ruby-progressbar (1.11.0)
34
+ unicode-display_width (2.1.0)
35
+ vector2d (2.2.3)
36
+ contracts (~> 0.9.0)
37
+ webrick (1.7.0)
38
+ yard (0.9.27)
39
+ webrick (~> 1.7.0)
40
+
41
+ PLATFORMS
42
+ x86_64-darwin-19
43
+
44
+ DEPENDENCIES
45
+ fantasy!
46
+ minitest (~> 5.0)
47
+ rake (~> 13.0)
48
+ rubocop (~> 1.21)
49
+ yard
50
+
51
+ RUBY VERSION
52
+ ruby 3.0.2p107
53
+
54
+ BUNDLED WITH
55
+ 2.2.32
data/README.md CHANGED
@@ -96,7 +96,7 @@ Or install it yourself as:
96
96
 
97
97
  ## Features
98
98
 
99
- ### Game Scene transitions
99
+ ### Game Scenes
100
100
 
101
101
  Easy to configure 3 basic game states:
102
102
 
@@ -209,7 +209,7 @@ Simple way to set up:
209
209
  - Image background
210
210
  - Repeatable image background
211
211
 
212
- ### Data Persistance (TODO)
212
+ ### Data Persistance
213
213
 
214
214
  Simple mechanism to save data in disk. For user preferences, game progress, high scores and others
215
215
 
@@ -234,9 +234,13 @@ For easy creation of:
234
234
 
235
235
  Multiple movement animation effects like in [DoTween](http://dotween.demigiant.com/documentation.php) (TODO)
236
236
 
237
+ ### Externalized Variables (TODO)
238
+
239
+ Values that can be changed while the game is running. They can be in a Variables file. The game "watch" this file and update the variable in real time.
240
+
237
241
  ## API
238
242
 
239
- ### Game Scene transitions
243
+ ### Game Scenes
240
244
 
241
245
  Configure your game elements on each Scene:
242
246
 
@@ -314,8 +318,8 @@ player.on_collision do |other|
314
318
  end
315
319
 
316
320
  player.on_after_move do
317
- if player.position.x > SCREEN_WIDTH
318
- player.position.x = SCREEN_WIDTH
321
+ if player.position.x > Global.screen_width
322
+ player.position.x = Global.screen_width
319
323
  end
320
324
 
321
325
  if player.position.x < 0
@@ -339,13 +343,13 @@ class Player < Actor
339
343
  move_with_cursors
340
344
  end
341
345
 
342
- on_collision do |other|
346
+ def on_collision_do(other)
343
347
  if other.name == "enemy"
344
348
  destroy
345
349
  end
346
350
  end
347
351
 
348
- on_after_move do
352
+ def on_after_move_do
349
353
  if @position.x > SCREEN_WIDTH
350
354
  @position.x = SCREEN_WIDTH
351
355
  end
@@ -401,7 +405,7 @@ on_presentation do
401
405
  end
402
406
 
403
407
  # Replicable (by default) Image
404
- # position is relative to Global.camera
408
+ # position is relative to Camera.main
405
409
  on_game do
406
410
  background = Background.new(image_name: "beach")
407
411
  # background.replicable = false # if you don't want the image to replicate
@@ -409,13 +413,28 @@ on_game do
409
413
  end
410
414
  ```
411
415
 
416
+ ### Data Persistance
417
+
418
+ ```ruby
419
+ Disk.data.records = [120_000, 11_000, 678]
420
+ Disk.data.last_level = 3
421
+ Disk.data.sound_volume = 12
422
+ Disk.save # data stored in ./disk/data.json
423
+
424
+ # ... in another session
425
+
426
+ Disk.data.records # => [120_000, 11_000, 678]
427
+ Disk.data.last_level # => 3
428
+ Disk.data.sound_volume # => 12
429
+ ```
430
+
412
431
  ### Camera
413
432
 
414
433
  ```ruby
415
434
  on_game do
416
435
  on_loop do
417
436
  # Camera follows player
418
- Global.camera.position.y = player.position.y - (SCREEN_HEIGHT / 2)
437
+ Camera.main.position.y = player.position.y - (SCREEN_HEIGHT / 2)
419
438
  end
420
439
  end
421
440
  ```
@@ -440,10 +459,10 @@ Music.stop
440
459
 
441
460
  ```ruby
442
461
  # ./maps/sky.txt
443
- #0 0 0
444
- # 1 0
445
- #
446
- #0 0 0
462
+ # 0 0
463
+ # 0 1
464
+ # 0 0
465
+ # 0 01
447
466
 
448
467
  planet = Actor.new("planet")
449
468
  star = Actor.new("star")
@@ -486,6 +505,10 @@ Clock.new { icon.visible = !icon.visible }.repeat(seconds: 1)
486
505
  - Tests are missing
487
506
  - Allow Ruby 2.5+
488
507
 
508
+ ## Assets
509
+
510
+ - Images for the test fixtures: https://kenney.nl/
511
+
489
512
  ## Development
490
513
 
491
514
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.