fantasy 0.1.7 → 0.1.13
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/CHANGELOG.md +32 -1
- data/COLOR_PALETTE.md +159 -0
- data/README.md +74 -10
- data/lib/fantasy/actor.rb +180 -39
- data/lib/fantasy/background.rb +1 -1
- data/lib/fantasy/color.rb +182 -1
- data/lib/fantasy/coordinates.rb +4 -0
- data/lib/fantasy/cursor.rb +42 -0
- data/lib/fantasy/disk.rb +31 -0
- data/lib/fantasy/global.rb +15 -1
- data/lib/fantasy/hud_image.rb +1 -1
- data/lib/fantasy/hud_text.rb +37 -11
- data/lib/fantasy/image.rb +2 -0
- data/lib/fantasy/includes/gravitier.rb +5 -0
- data/lib/fantasy/includes/jumper.rb +10 -0
- data/lib/fantasy/includes/move_by_cursors.rb +39 -11
- data/lib/fantasy/includes/move_by_direction.rb +5 -0
- data/lib/fantasy/includes/mover.rb +24 -0
- data/lib/fantasy/includes/user_inputs.rb +60 -0
- data/lib/fantasy/loop.rb +58 -8
- data/lib/fantasy/mouse.rb +9 -0
- data/lib/fantasy/music.rb +53 -0
- data/lib/fantasy/shape.rb +55 -0
- data/lib/fantasy/sound.rb +4 -2
- data/lib/fantasy/version.rb +1 -1
- data/lib/fantasy.rb +12 -1
- metadata +13 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0de009c2a3c9785532dd054f8f33cfb67933bb7f136a291638d8d15339919ff4
|
4
|
+
data.tar.gz: 194a34e34ccaf055175067efc1cbc122f334abfe290f8e78e24c75c4d742ef8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9dd083f303373be39e448140f37ef3efa93f307013a111a7e3fde435a1af2f8705e8064a88fd445e1a57613d7983b15ffbcce21aff50f8d04664b33db76b332
|
7
|
+
data.tar.gz: 2bd16fd118df26b580f543686c5828be62e7c725490cf20e8fab3f4102701713bda9d59e5b011c5e62e2052fdca80df59f529561e71704e7acb54425aa7790d0
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,36 @@
|
|
1
|
-
## [
|
1
|
+
## [0.1.11] - 2022-03-26
|
2
|
+
|
3
|
+
- Better jumping and gravity physics
|
4
|
+
- Support Shape.rectangle
|
5
|
+
- Support on_click callback on Shapes and Actors
|
6
|
+
- Support on_cursor_* callbacks on Shapes and Actors
|
7
|
+
- Support Color.palette with 150 colors + transparent
|
8
|
+
|
9
|
+
|
10
|
+
## [0.1.9] - 2022-03-25
|
11
|
+
|
12
|
+
- Adding platformer support
|
13
|
+
- Jump
|
14
|
+
- Gravity
|
15
|
+
- Music background support
|
16
|
+
|
17
|
+
|
18
|
+
## [0.1.7] - 2022-03-17
|
19
|
+
|
20
|
+
- HudText accepts alignment property. Valid values: 'top-left, top-right, center'
|
21
|
+
|
22
|
+
|
23
|
+
## [0.1.5] - 2022-03-16
|
24
|
+
|
25
|
+
- Background color or image
|
26
|
+
- Tilemap
|
27
|
+
- Camera can be controlled by cursors
|
28
|
+
- Background image can be replicable
|
29
|
+
|
2
30
|
|
3
31
|
## [0.1.0] - 2022-03-11
|
4
32
|
|
5
33
|
- Initial release
|
34
|
+
|
35
|
+
|
36
|
+
## [Unreleased]
|
data/COLOR_PALETTE.md
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
# Color.palette
|
2
|
+
|
3
|
+
```ruby
|
4
|
+
Color.palette.orange
|
5
|
+
Color.palette.crimson
|
6
|
+
Color.palette.transparent
|
7
|
+
[...]
|
8
|
+
```
|
9
|
+
|
10
|
+
-  orange
|
11
|
+
-  red
|
12
|
+
-  orange_red
|
13
|
+
-  tomato
|
14
|
+
-  dark_red
|
15
|
+
-  fire_brick
|
16
|
+
-  crimson
|
17
|
+
-  deep_pink
|
18
|
+
-  maroon
|
19
|
+
-  indian_red
|
20
|
+
-  medium_violet_red
|
21
|
+
-  violet_red
|
22
|
+
-  light_coral
|
23
|
+
-  hot_pink
|
24
|
+
-  pale_violet_red
|
25
|
+
-  light_pink
|
26
|
+
-  rosy_brown
|
27
|
+
-  pink
|
28
|
+
-  orchid
|
29
|
+
-  lavender_blush
|
30
|
+
-  snow
|
31
|
+
-  chocolate
|
32
|
+
-  saddle_brown
|
33
|
+
-  brown
|
34
|
+
-  dark_orange
|
35
|
+
-  coral
|
36
|
+
-  sienna
|
37
|
+
-  salmon
|
38
|
+
-  peru
|
39
|
+
-  dark_goldenrod
|
40
|
+
-  goldenrod
|
41
|
+
-  sandy_brown
|
42
|
+
-  light_salmon
|
43
|
+
-  dark_salmon
|
44
|
+
-  gold
|
45
|
+
-  yellow
|
46
|
+
-  olive
|
47
|
+
-  burlywood
|
48
|
+
-  tan
|
49
|
+
-  navajo_white
|
50
|
+
-  peach_puff
|
51
|
+
-  khaki
|
52
|
+
-  dark_khaki
|
53
|
+
-  moccasin
|
54
|
+
-  wheat
|
55
|
+
-  bisque
|
56
|
+
-  pale_goldenrod
|
57
|
+
-  blanched_almond
|
58
|
+
-  medium_goldenrod
|
59
|
+
-  papaya_whip
|
60
|
+
-  misty_rose
|
61
|
+
-  lemon_chiffon
|
62
|
+
-  antique_white
|
63
|
+
-  cornsilk
|
64
|
+
-  light_goldenrod_yellow
|
65
|
+
-  old_lace
|
66
|
+
-  linen
|
67
|
+
-  light_yellow
|
68
|
+
-  seashell
|
69
|
+
-  beige
|
70
|
+
-  floral_white
|
71
|
+
-  ivory
|
72
|
+
-  green
|
73
|
+
-  lawn_green
|
74
|
+
-  chartreuse
|
75
|
+
-  green_yellow
|
76
|
+
-  yellow_green
|
77
|
+
-  medium_forest_green
|
78
|
+
-  olive_drab
|
79
|
+
-  dark_olive_green
|
80
|
+
-  dark_sea_green
|
81
|
+
-  lime
|
82
|
+
-  dark_green
|
83
|
+
-  lime_green
|
84
|
+
-  forest_green
|
85
|
+
-  spring_green
|
86
|
+
-  medium_spring_green
|
87
|
+
-  sea_green
|
88
|
+
-  medium_sea_green
|
89
|
+
-  aquamarine
|
90
|
+
-  light_green
|
91
|
+
-  pale_green
|
92
|
+
-  medium_aquamarine
|
93
|
+
-  turquoise
|
94
|
+
-  light_sea_green
|
95
|
+
-  medium_turquoise
|
96
|
+
-  honeydew
|
97
|
+
-  mint_cream
|
98
|
+
-  royal_blue
|
99
|
+
-  dodger_blue
|
100
|
+
-  deep_sky_blue
|
101
|
+
-  cornflower_blue
|
102
|
+
-  steel_blue
|
103
|
+
-  light_sky_blue
|
104
|
+
-  dark_turquoise
|
105
|
+
-  cyan
|
106
|
+
-  aqua
|
107
|
+
-  dark_cyan
|
108
|
+
-  teal
|
109
|
+
-  sky_blue
|
110
|
+
-  cadet_blue
|
111
|
+
-  dark_slate_gray
|
112
|
+
-  dark_slate_grey
|
113
|
+
-  light_slate_gray
|
114
|
+
-  light_slate_grey
|
115
|
+
-  slate_gray
|
116
|
+
-  slate_grey
|
117
|
+
-  light_steel_blue
|
118
|
+
-  light_blue
|
119
|
+
-  powder_blue
|
120
|
+
-  pale_turquoise
|
121
|
+
-  light_cyan
|
122
|
+
-  alice_blue
|
123
|
+
-  azure
|
124
|
+
-  medium_blue
|
125
|
+
-  dark_blue
|
126
|
+
-  midnight_blue
|
127
|
+
-  navy
|
128
|
+
-  blue
|
129
|
+
-  indigo
|
130
|
+
-  blue_violet
|
131
|
+
-  medium_slate_blue
|
132
|
+
-  slate_blue
|
133
|
+
-  purple
|
134
|
+
-  dark_slate_blue
|
135
|
+
-  dark_violet
|
136
|
+
-  dark_orchid
|
137
|
+
-  medium_purple
|
138
|
+
-  medium_orchid
|
139
|
+
-  magenta
|
140
|
+
-  fuchsia
|
141
|
+
-  dark_magenta
|
142
|
+
-  violet
|
143
|
+
-  plum
|
144
|
+
-  lavender
|
145
|
+
-  thistle
|
146
|
+
-  ghost_white
|
147
|
+
-  white
|
148
|
+
-  white_smoke
|
149
|
+
-  gainsboro
|
150
|
+
-  light_gray
|
151
|
+
-  light_grey
|
152
|
+
-  silver
|
153
|
+
-  gray
|
154
|
+
-  grey
|
155
|
+
-  dark_gray
|
156
|
+
-  dark_grey
|
157
|
+
-  dim_gray
|
158
|
+
-  dim_grey
|
159
|
+
-  black
|
data/README.md
CHANGED
@@ -96,7 +96,7 @@ Or install it yourself as:
|
|
96
96
|
|
97
97
|
## Features
|
98
98
|
|
99
|
-
### Game
|
99
|
+
### Game Scenes
|
100
100
|
|
101
101
|
Easy to configure 3 basic game states:
|
102
102
|
|
@@ -116,12 +116,13 @@ Managing game elements which have (optionally) image, movement and collision
|
|
116
116
|
- Easy to set an `image`
|
117
117
|
- Managing movement through `direction` and `speed`
|
118
118
|
- Built-in movement control through cursors
|
119
|
-
- Collision detection, OnCollision callback
|
120
|
-
- Jump
|
121
|
-
- Gravity
|
119
|
+
- Collision detection, OnCollision callback, Collision matrix
|
120
|
+
- Jump
|
121
|
+
- Gravity
|
122
122
|
- Animations (TODO)
|
123
123
|
- Possibility to extend Actor class or instantiate it directly for simple characters
|
124
124
|
- Allowing magic instance properties (Like in OpenStruct). So programmer can do `actor.stuff = 1` and it is valid (TODO)
|
125
|
+
- Alignment "center" and "top-left" (TODO)
|
125
126
|
|
126
127
|
### Clock
|
127
128
|
|
@@ -181,9 +182,9 @@ Actors in the game will be rendered in the relative position to this camera.
|
|
181
182
|
- Allow camera move
|
182
183
|
- Easy to follow one actor
|
183
184
|
|
184
|
-
### Colors palette
|
185
|
+
### Colors palette
|
185
186
|
|
186
|
-
- Not deal with RGB or anything, just a list of colors (
|
187
|
+
- Not deal with RGB or anything, just a list of colors. See [Color.palette](COLOR_PALETTE.md)
|
187
188
|
|
188
189
|
|
189
190
|
### Pause Game (TODO)
|
@@ -196,7 +197,9 @@ Move the core functions to the top level hierarchy so I don't need to create a `
|
|
196
197
|
|
197
198
|
### Sound
|
198
199
|
|
199
|
-
Direct and easy way to play a sound
|
200
|
+
- Direct and easy way to play a sound
|
201
|
+
- Direct and easy way to play a background music
|
202
|
+
|
200
203
|
|
201
204
|
### Background
|
202
205
|
|
@@ -206,7 +209,7 @@ Simple way to set up:
|
|
206
209
|
- Image background
|
207
210
|
- Repeatable image background
|
208
211
|
|
209
|
-
### Data Persistance
|
212
|
+
### Data Persistance
|
210
213
|
|
211
214
|
Simple mechanism to save data in disk. For user preferences, game progress, high scores and others
|
212
215
|
|
@@ -233,7 +236,7 @@ Multiple movement animation effects like in [DoTween](http://dotween.demigiant.c
|
|
233
236
|
|
234
237
|
## API
|
235
238
|
|
236
|
-
### Game
|
239
|
+
### Game Scenes
|
237
240
|
|
238
241
|
Configure your game elements on each Scene:
|
239
242
|
|
@@ -302,6 +305,7 @@ player.solid = true
|
|
302
305
|
player.speed = 200
|
303
306
|
player.layer = 1
|
304
307
|
player.move_with_cursors
|
308
|
+
player.collision_with = ["enemy", "bullets"] # default "all"
|
305
309
|
|
306
310
|
player.on_collision do |other|
|
307
311
|
if other.name == "enemy"
|
@@ -331,6 +335,7 @@ class Player < Actor
|
|
331
335
|
@speed = 200
|
332
336
|
@layer = 1
|
333
337
|
@direction = Coordinates.zero
|
338
|
+
@collision_with = ["enemy", "bullets"] # default "all"
|
334
339
|
move_with_cursors
|
335
340
|
end
|
336
341
|
|
@@ -352,6 +357,25 @@ class Player < Actor
|
|
352
357
|
end
|
353
358
|
```
|
354
359
|
|
360
|
+
Actor settings for a platformer:
|
361
|
+
|
362
|
+
```ruby
|
363
|
+
player = Actor.new("warrior") # ./images/warrior.png
|
364
|
+
player.solid = true
|
365
|
+
player.jump = 150
|
366
|
+
player.gravity = 200
|
367
|
+
player.move_with_cursors(left: true, right: true, up: false, down: false, jump: true)
|
368
|
+
|
369
|
+
player.on_jumping do
|
370
|
+
Sound.play("jump")
|
371
|
+
player.image = "warrior_jump")
|
372
|
+
end
|
373
|
+
|
374
|
+
player.on_floor do
|
375
|
+
player.image = "warrior")
|
376
|
+
end
|
377
|
+
```
|
378
|
+
|
355
379
|
### Clock
|
356
380
|
|
357
381
|
```ruby
|
@@ -385,6 +409,21 @@ on_game do
|
|
385
409
|
end
|
386
410
|
```
|
387
411
|
|
412
|
+
### Data Persistance
|
413
|
+
|
414
|
+
```ruby
|
415
|
+
Disk.data.records = [120_000, 11_000, 678]
|
416
|
+
Disk.data.last_level = 3
|
417
|
+
Disk.data.sound_volume = 12
|
418
|
+
Disk.save # data stored in ./disk/data.json
|
419
|
+
|
420
|
+
# ... in another session
|
421
|
+
|
422
|
+
Disk.data.records # => [120_000, 11_000, 678]
|
423
|
+
Disk.data.last_level # => 3
|
424
|
+
Disk.data.sound_volume # => 12
|
425
|
+
```
|
426
|
+
|
388
427
|
### Camera
|
389
428
|
|
390
429
|
```ruby
|
@@ -398,18 +437,43 @@ end
|
|
398
437
|
|
399
438
|
### Sound
|
400
439
|
|
440
|
+
Plays only once:
|
441
|
+
|
401
442
|
```ruby
|
402
443
|
Sound.play("shoot") # ./sounds/shoot.wav
|
403
444
|
```
|
404
445
|
|
446
|
+
Plays in loop:
|
447
|
+
|
448
|
+
```ruby
|
449
|
+
Music.play("music") # ./musics/music.mp3
|
450
|
+
Music.volume = 0.5
|
451
|
+
Music.stop
|
452
|
+
```
|
453
|
+
|
454
|
+
### Tilemap
|
455
|
+
|
456
|
+
```ruby
|
457
|
+
# ./maps/sky.txt
|
458
|
+
# 0 0
|
459
|
+
# 0 1
|
460
|
+
# 0 0
|
461
|
+
# 0 01
|
462
|
+
|
463
|
+
planet = Actor.new("planet")
|
464
|
+
star = Actor.new("star")
|
465
|
+
map = Tilemap.new(map_name: "sky", tiles: [planet, star], tile_size: 30)
|
466
|
+
map.spawn
|
467
|
+
```
|
405
468
|
|
406
469
|
### UI
|
407
470
|
|
408
471
|
#### HUD Text
|
409
472
|
|
410
473
|
```ruby
|
411
|
-
timer = HudText.new(position: Coordinates.new(
|
474
|
+
timer = HudText.new(position: Coordinates.new(SCREEN_WIDTH / 2, 10))
|
412
475
|
timer.text = 0
|
476
|
+
timer.alignment = "center"
|
413
477
|
timer.size = "big"
|
414
478
|
|
415
479
|
Clock.new { timer.text += 1 }.repeat(seconds: 1)
|