fantasy 0.1.13 → 0.1.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +22 -1
- data/.yardopts +4 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +55 -0
- data/README.md +14 -6
- data/docs/Actor.html +2737 -0
- data/docs/Background.html +961 -0
- data/docs/Camera.html +791 -0
- data/docs/Clock.html +753 -0
- data/docs/Color.html +776 -0
- data/docs/Coordinates.html +730 -0
- data/docs/Cursor.html +752 -0
- data/docs/Disk.html +236 -0
- data/docs/Draggable.html +198 -0
- data/docs/Fantasy.html +121 -0
- data/docs/Game.html +904 -0
- data/docs/Global.html +2791 -0
- data/docs/Gravitier.html +179 -0
- data/docs/HudImage.html +979 -0
- data/docs/HudText.html +1151 -0
- data/docs/Image.html +506 -0
- data/docs/Jumper.html +189 -0
- data/docs/Mouse.html +226 -0
- data/docs/MoveByCursor.html +374 -0
- data/docs/MoveByDirection.html +179 -0
- data/docs/Mover.html +305 -0
- data/docs/Music.html +524 -0
- data/docs/Shape.html +1057 -0
- data/docs/Sound.html +374 -0
- data/docs/Tilemap.html +491 -0
- data/docs/Tween.html +186 -0
- data/docs/UserInputs.html +879 -0
- data/docs/Utils.html +345 -0
- data/docs/_index.html +346 -0
- data/docs/class_list.html +51 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +58 -0
- data/docs/css/style.css +497 -0
- data/docs/file.CHANGELOG.html +121 -0
- data/docs/file.README.html +599 -0
- data/docs/file_list.html +61 -0
- data/docs/frames.html +17 -0
- data/docs/index.html +599 -0
- data/docs/js/app.js +314 -0
- data/docs/js/full_list.js +216 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +1931 -0
- data/docs/top-level-namespace.html +978 -0
- data/lib/fantasy/actor.rb +455 -123
- data/lib/fantasy/background.rb +109 -13
- data/lib/fantasy/base.rb +113 -1
- data/lib/fantasy/camera.rb +95 -11
- data/lib/fantasy/clock.rb +4 -2
- data/lib/fantasy/color.rb +158 -153
- data/lib/fantasy/coordinates.rb +5 -9
- data/lib/fantasy/cursor.rb +2 -1
- data/lib/fantasy/disk.rb +12 -8
- data/lib/fantasy/draggable.rb +22 -1
- data/lib/fantasy/global.rb +59 -31
- data/lib/fantasy/hud_image.rb +5 -3
- data/lib/fantasy/hud_text.rb +6 -2
- data/lib/fantasy/image.rb +12 -4
- data/lib/fantasy/includes/gravitier.rb +2 -0
- data/lib/fantasy/includes/jumper.rb +3 -2
- data/lib/fantasy/includes/log.rb +12 -0
- data/lib/fantasy/includes/move_by_cursors.rb +24 -15
- data/lib/fantasy/includes/move_by_direction.rb +2 -0
- data/lib/fantasy/includes/mover.rb +3 -0
- data/lib/fantasy/includes/user_inputs.rb +6 -0
- data/lib/fantasy/loop.rb +41 -44
- data/lib/fantasy/mouse.rb +2 -0
- data/lib/fantasy/music.rb +4 -2
- data/lib/fantasy/shape.rb +11 -2
- data/lib/fantasy/sound.rb +3 -1
- data/lib/fantasy/tilemap.rb +19 -13
- data/lib/fantasy/tween.rb +3 -1
- data/lib/fantasy/utils.rb +7 -13
- data/lib/fantasy/version.rb +1 -1
- data/lib/fantasy.rb +2 -0
- metadata +90 -4
- data/fantasy.gemspec +0 -40
- data/fonts/VT323-Regular.ttf +0 -0
data/lib/fantasy/color.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "ostruct"
|
2
4
|
|
3
5
|
class Color < Gosu::Color
|
@@ -30,157 +32,160 @@ class Color < Gosu::Color
|
|
30
32
|
attr_reader :palette
|
31
33
|
end
|
32
34
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
35
|
+
# rubocop:disable Layout/FirstHashElementIndentation
|
36
|
+
@palette =
|
37
|
+
OpenStruct.new({
|
38
|
+
"orange" => Color.new(r: 255, g: 165, b: 0, a: 255, name: "orange"),
|
39
|
+
"red" => Color.new(r: 255, g: 0, b: 0, a: 255, name: "red"),
|
40
|
+
"orange_red" => Color.new(r: 255, g: 69, b: 0, a: 255, name: "orange_red"),
|
41
|
+
"tomato" => Color.new(r: 255, g: 99, b: 71, a: 255, name: "tomato"),
|
42
|
+
"dark_red" => Color.new(r: 139, g: 0, b: 0, a: 255, name: "dark_red"),
|
43
|
+
"fire_brick" => Color.new(r: 178, g: 34, b: 34, a: 255, name: "fire_brick"),
|
44
|
+
"crimson" => Color.new(r: 220, g: 20, b: 60, a: 255, name: "crimson"),
|
45
|
+
"deep_pink" => Color.new(r: 255, g: 20, b: 147, a: 255, name: "deep_pink"),
|
46
|
+
"maroon" => Color.new(r: 176, g: 48, b: 96, a: 255, name: "maroon"),
|
47
|
+
"indian_red" => Color.new(r: 205, g: 92, b: 92, a: 255, name: "indian_red"),
|
48
|
+
"medium_violet_red" => Color.new(r: 199, g: 21, b: 133, a: 255, name: "medium_violet_red"),
|
49
|
+
"violet_red" => Color.new(r: 208, g: 32, b: 144, a: 255, name: "violet_red"),
|
50
|
+
"light_coral" => Color.new(r: 240, g: 128, b: 128, a: 255, name: "light_coral"),
|
51
|
+
"hot_pink" => Color.new(r: 255, g: 105, b: 180, a: 255, name: "hot_pink"),
|
52
|
+
"pale_violet_red" => Color.new(r: 219, g: 112, b: 147, a: 255, name: "pale_violet_red"),
|
53
|
+
"light_pink" => Color.new(r: 255, g: 182, b: 193, a: 255, name: "light_pink"),
|
54
|
+
"rosy_brown" => Color.new(r: 188, g: 143, b: 143, a: 255, name: "rosy_brown"),
|
55
|
+
"pink" => Color.new(r: 255, g: 192, b: 203, a: 255, name: "pink"),
|
56
|
+
"orchid" => Color.new(r: 218, g: 112, b: 214, a: 255, name: "orchid"),
|
57
|
+
"lavender_blush" => Color.new(r: 255, g: 240, b: 245, a: 255, name: "lavender_blush"),
|
58
|
+
"snow" => Color.new(r: 255, g: 250, b: 250, a: 255, name: "snow"),
|
59
|
+
"chocolate" => Color.new(r: 210, g: 105, b: 30, a: 255, name: "chocolate"),
|
60
|
+
"saddle_brown" => Color.new(r: 139, g: 69, b: 19, a: 255, name: "saddle_brown"),
|
61
|
+
"brown" => Color.new(r: 132, g: 60, b: 36, a: 255, name: "brown"),
|
62
|
+
"dark_orange" => Color.new(r: 255, g: 140, b: 0, a: 255, name: "dark_orange"),
|
63
|
+
"coral" => Color.new(r: 255, g: 127, b: 80, a: 255, name: "coral"),
|
64
|
+
"sienna" => Color.new(r: 160, g: 82, b: 45, a: 255, name: "sienna"),
|
65
|
+
"salmon" => Color.new(r: 250, g: 128, b: 114, a: 255, name: "salmon"),
|
66
|
+
"peru" => Color.new(r: 205, g: 133, b: 63, a: 255, name: "peru"),
|
67
|
+
"dark_goldenrod" => Color.new(r: 184, g: 134, b: 11, a: 255, name: "dark_goldenrod"),
|
68
|
+
"goldenrod" => Color.new(r: 218, g: 165, b: 32, a: 255, name: "goldenrod"),
|
69
|
+
"sandy_brown" => Color.new(r: 244, g: 164, b: 96, a: 255, name: "sandy_brown"),
|
70
|
+
"light_salmon" => Color.new(r: 255, g: 160, b: 122, a: 255, name: "light_salmon"),
|
71
|
+
"dark_salmon" => Color.new(r: 233, g: 150, b: 122, a: 255, name: "dark_salmon"),
|
72
|
+
"gold" => Color.new(r: 255, g: 215, b: 0, a: 255, name: "gold"),
|
73
|
+
"yellow" => Color.new(r: 255, g: 255, b: 0, a: 255, name: "yellow"),
|
74
|
+
"olive" => Color.new(r: 128, g: 128, b: 0, a: 255, name: "olive"),
|
75
|
+
"burlywood" => Color.new(r: 222, g: 184, b: 135, a: 255, name: "burlywood"),
|
76
|
+
"tan" => Color.new(r: 210, g: 180, b: 140, a: 255, name: "tan"),
|
77
|
+
"navajo_white" => Color.new(r: 255, g: 222, b: 173, a: 255, name: "navajo_white"),
|
78
|
+
"peach_puff" => Color.new(r: 255, g: 218, b: 185, a: 255, name: "peach_puff"),
|
79
|
+
"khaki" => Color.new(r: 240, g: 230, b: 140, a: 255, name: "khaki"),
|
80
|
+
"dark_khaki" => Color.new(r: 189, g: 183, b: 107, a: 255, name: "dark_khaki"),
|
81
|
+
"moccasin" => Color.new(r: 255, g: 228, b: 181, a: 255, name: "moccasin"),
|
82
|
+
"wheat" => Color.new(r: 245, g: 222, b: 179, a: 255, name: "wheat"),
|
83
|
+
"bisque" => Color.new(r: 255, g: 228, b: 196, a: 255, name: "bisque"),
|
84
|
+
"pale_goldenrod" => Color.new(r: 238, g: 232, b: 170, a: 255, name: "pale_goldenrod"),
|
85
|
+
"blanched_almond" => Color.new(r: 255, g: 235, b: 205, a: 255, name: "blanched_almond"),
|
86
|
+
"medium_goldenrod" => Color.new(r: 234, g: 234, b: 173, a: 255, name: "medium_goldenrod"),
|
87
|
+
"papaya_whip" => Color.new(r: 255, g: 239, b: 213, a: 255, name: "papaya_whip"),
|
88
|
+
"misty_rose" => Color.new(r: 255, g: 228, b: 225, a: 255, name: "misty_rose"),
|
89
|
+
"lemon_chiffon" => Color.new(r: 255, g: 250, b: 205, a: 255, name: "lemon_chiffon"),
|
90
|
+
"antique_white" => Color.new(r: 250, g: 235, b: 215, a: 255, name: "antique_white"),
|
91
|
+
"cornsilk" => Color.new(r: 255, g: 248, b: 220, a: 255, name: "cornsilk"),
|
92
|
+
"light_goldenrod_yellow" => Color.new(r: 250, g: 250, b: 210, a: 255, name: "light_goldenrod_yellow"),
|
93
|
+
"old_lace" => Color.new(r: 253, g: 245, b: 230, a: 255, name: "old_lace"),
|
94
|
+
"linen" => Color.new(r: 250, g: 240, b: 230, a: 255, name: "linen"),
|
95
|
+
"light_yellow" => Color.new(r: 255, g: 255, b: 224, a: 255, name: "light_yellow"),
|
96
|
+
"seashell" => Color.new(r: 255, g: 245, b: 238, a: 255, name: "seashell"),
|
97
|
+
"beige" => Color.new(r: 245, g: 245, b: 220, a: 255, name: "beige"),
|
98
|
+
"floral_white" => Color.new(r: 255, g: 250, b: 240, a: 255, name: "floral_white"),
|
99
|
+
"ivory" => Color.new(r: 255, g: 255, b: 240, a: 255, name: "ivory"),
|
100
|
+
"green" => Color.new(r: 0, g: 255, b: 0, a: 255, name: "green"),
|
101
|
+
"lawn_green" => Color.new(r: 124, g: 252, b: 0, a: 255, name: "lawn_green"),
|
102
|
+
"chartreuse" => Color.new(r: 127, g: 255, b: 0, a: 255, name: "chartreuse"),
|
103
|
+
"green_yellow" => Color.new(r: 173, g: 255, b: 47, a: 255, name: "green_yellow"),
|
104
|
+
"yellow_green" => Color.new(r: 154, g: 205, b: 50, a: 255, name: "yellow_green"),
|
105
|
+
"medium_forest_green" => Color.new(r: 107, g: 142, b: 35, a: 255, name: "medium_forest_green"),
|
106
|
+
"olive_drab" => Color.new(r: 107, g: 142, b: 35, a: 255, name: "olive_drab"),
|
107
|
+
"dark_olive_green" => Color.new(r: 85, g: 107, b: 47, a: 255, name: "dark_olive_green"),
|
108
|
+
"dark_sea_green" => Color.new(r: 143, g: 188, b: 139, a: 255, name: "dark_sea_green"),
|
109
|
+
"lime" => Color.new(r: 0, g: 255, b: 0, a: 255, name: "lime"),
|
110
|
+
"dark_green" => Color.new(r: 0, g: 100, b: 0, a: 255, name: "dark_green"),
|
111
|
+
"lime_green" => Color.new(r: 50, g: 205, b: 50, a: 255, name: "lime_green"),
|
112
|
+
"forest_green" => Color.new(r: 34, g: 139, b: 34, a: 255, name: "forest_green"),
|
113
|
+
"spring_green" => Color.new(r: 0, g: 255, b: 127, a: 255, name: "spring_green"),
|
114
|
+
"medium_spring_green" => Color.new(r: 0, g: 250, b: 154, a: 255, name: "medium_spring_green"),
|
115
|
+
"sea_green" => Color.new(r: 46, g: 139, b: 87, a: 255, name: "sea_green"),
|
116
|
+
"medium_sea_green" => Color.new(r: 60, g: 179, b: 113, a: 255, name: "medium_sea_green"),
|
117
|
+
"aquamarine" => Color.new(r: 112, g: 216, b: 144, a: 255, name: "aquamarine"),
|
118
|
+
"light_green" => Color.new(r: 144, g: 238, b: 144, a: 255, name: "light_green"),
|
119
|
+
"pale_green" => Color.new(r: 152, g: 251, b: 152, a: 255, name: "pale_green"),
|
120
|
+
"medium_aquamarine" => Color.new(r: 102, g: 205, b: 170, a: 255, name: "medium_aquamarine"),
|
121
|
+
"turquoise" => Color.new(r: 64, g: 224, b: 208, a: 255, name: "turquoise"),
|
122
|
+
"light_sea_green" => Color.new(r: 32, g: 178, b: 170, a: 255, name: "light_sea_green"),
|
123
|
+
"medium_turquoise" => Color.new(r: 72, g: 209, b: 204, a: 255, name: "medium_turquoise"),
|
124
|
+
"honeydew" => Color.new(r: 240, g: 255, b: 240, a: 255, name: "honeydew"),
|
125
|
+
"mint_cream" => Color.new(r: 245, g: 255, b: 250, a: 255, name: "mint_cream"),
|
126
|
+
"royal_blue" => Color.new(r: 65, g: 105, b: 225, a: 255, name: "royal_blue"),
|
127
|
+
"dodger_blue" => Color.new(r: 30, g: 144, b: 255, a: 255, name: "dodger_blue"),
|
128
|
+
"deep_sky_blue" => Color.new(r: 0, g: 191, b: 255, a: 255, name: "deep_sky_blue"),
|
129
|
+
"cornflower_blue" => Color.new(r: 100, g: 149, b: 237, a: 255, name: "cornflower_blue"),
|
130
|
+
"steel_blue" => Color.new(r: 70, g: 130, b: 180, a: 255, name: "steel_blue"),
|
131
|
+
"light_sky_blue" => Color.new(r: 135, g: 206, b: 250, a: 255, name: "light_sky_blue"),
|
132
|
+
"dark_turquoise" => Color.new(r: 0, g: 206, b: 209, a: 255, name: "dark_turquoise"),
|
133
|
+
"cyan" => Color.new(r: 0, g: 255, b: 255, a: 255, name: "cyan"),
|
134
|
+
"aqua" => Color.new(r: 0, g: 255, b: 255, a: 255, name: "aqua"),
|
135
|
+
"dark_cyan" => Color.new(r: 0, g: 139, b: 139, a: 255, name: "dark_cyan"),
|
136
|
+
"teal" => Color.new(r: 0, g: 128, b: 128, a: 255, name: "teal"),
|
137
|
+
"sky_blue" => Color.new(r: 135, g: 206, b: 235, a: 255, name: "sky_blue"),
|
138
|
+
"cadet_blue" => Color.new(r: 95, g: 158, b: 160, a: 255, name: "cadet_blue"),
|
139
|
+
"dark_slate_gray" => Color.new(r: 47, g: 79, b: 79, a: 255, name: "dark_slate_gray"),
|
140
|
+
"dark_slate_grey" => Color.new(r: 47, g: 79, b: 79, a: 255, name: "dark_slate_grey"),
|
141
|
+
"light_slate_gray" => Color.new(r: 119, g: 136, b: 153, a: 255, name: "light_slate_gray"),
|
142
|
+
"light_slate_grey" => Color.new(r: 119, g: 136, b: 153, a: 255, name: "light_slate_grey"),
|
143
|
+
"slate_gray" => Color.new(r: 112, g: 128, b: 144, a: 255, name: "slate_gray"),
|
144
|
+
"slate_grey" => Color.new(r: 112, g: 128, b: 144, a: 255, name: "slate_grey"),
|
145
|
+
"light_steel_blue" => Color.new(r: 176, g: 196, b: 222, a: 255, name: "light_steel_blue"),
|
146
|
+
"light_blue" => Color.new(r: 173, g: 216, b: 230, a: 255, name: "light_blue"),
|
147
|
+
"powder_blue" => Color.new(r: 176, g: 224, b: 230, a: 255, name: "powder_blue"),
|
148
|
+
"pale_turquoise" => Color.new(r: 175, g: 238, b: 238, a: 255, name: "pale_turquoise"),
|
149
|
+
"light_cyan" => Color.new(r: 224, g: 255, b: 255, a: 255, name: "light_cyan"),
|
150
|
+
"alice_blue" => Color.new(r: 240, g: 248, b: 255, a: 255, name: "alice_blue"),
|
151
|
+
"azure" => Color.new(r: 240, g: 255, b: 255, a: 255, name: "azure"),
|
152
|
+
"medium_blue" => Color.new(r: 0, g: 0, b: 205, a: 255, name: "medium_blue"),
|
153
|
+
"dark_blue" => Color.new(r: 0, g: 0, b: 139, a: 255, name: "dark_blue"),
|
154
|
+
"midnight_blue" => Color.new(r: 25, g: 25, b: 112, a: 255, name: "midnight_blue"),
|
155
|
+
"navy" => Color.new(r: 36, g: 36, b: 140, a: 255, name: "navy"),
|
156
|
+
"blue" => Color.new(r: 0, g: 0, b: 255, a: 255, name: "blue"),
|
157
|
+
"indigo" => Color.new(r: 75, g: 0, b: 130, a: 255, name: "indigo"),
|
158
|
+
"blue_violet" => Color.new(r: 138, g: 43, b: 226, a: 255, name: "blue_violet"),
|
159
|
+
"medium_slate_blue" => Color.new(r: 123, g: 104, b: 238, a: 255, name: "medium_slate_blue"),
|
160
|
+
"slate_blue" => Color.new(r: 106, g: 90, b: 205, a: 255, name: "slate_blue"),
|
161
|
+
"purple" => Color.new(r: 160, g: 32, b: 240, a: 255, name: "purple"),
|
162
|
+
"dark_slate_blue" => Color.new(r: 72, g: 61, b: 139, a: 255, name: "dark_slate_blue"),
|
163
|
+
"dark_violet" => Color.new(r: 148, g: 0, b: 211, a: 255, name: "dark_violet"),
|
164
|
+
"dark_orchid" => Color.new(r: 153, g: 50, b: 204, a: 255, name: "dark_orchid"),
|
165
|
+
"medium_purple" => Color.new(r: 147, g: 112, b: 219, a: 255, name: "medium_purple"),
|
166
|
+
"medium_orchid" => Color.new(r: 186, g: 85, b: 211, a: 255, name: "medium_orchid"),
|
167
|
+
"magenta" => Color.new(r: 255, g: 0, b: 255, a: 255, name: "magenta"),
|
168
|
+
"fuchsia" => Color.new(r: 255, g: 0, b: 255, a: 255, name: "fuchsia"),
|
169
|
+
"dark_magenta" => Color.new(r: 139, g: 0, b: 139, a: 255, name: "dark_magenta"),
|
170
|
+
"violet" => Color.new(r: 238, g: 130, b: 238, a: 255, name: "violet"),
|
171
|
+
"plum" => Color.new(r: 221, g: 160, b: 221, a: 255, name: "plum"),
|
172
|
+
"lavender" => Color.new(r: 230, g: 230, b: 250, a: 255, name: "lavender"),
|
173
|
+
"thistle" => Color.new(r: 216, g: 191, b: 216, a: 255, name: "thistle"),
|
174
|
+
"ghost_white" => Color.new(r: 248, g: 248, b: 255, a: 255, name: "ghost_white"),
|
175
|
+
"white" => Color.new(r: 255, g: 255, b: 255, a: 255, name: "white"),
|
176
|
+
"white_smoke" => Color.new(r: 245, g: 245, b: 245, a: 255, name: "white_smoke"),
|
177
|
+
"gainsboro" => Color.new(r: 220, g: 220, b: 220, a: 255, name: "gainsboro"),
|
178
|
+
"light_gray" => Color.new(r: 211, g: 211, b: 211, a: 255, name: "light_gray"),
|
179
|
+
"light_grey" => Color.new(r: 211, g: 211, b: 211, a: 255, name: "light_grey"),
|
180
|
+
"silver" => Color.new(r: 192, g: 192, b: 192, a: 255, name: "silver"),
|
181
|
+
"gray" => Color.new(r: 190, g: 190, b: 190, a: 255, name: "gray"),
|
182
|
+
"grey" => Color.new(r: 190, g: 190, b: 190, a: 255, name: "grey"),
|
183
|
+
"dark_gray" => Color.new(r: 169, g: 169, b: 169, a: 255, name: "dark_gray"),
|
184
|
+
"dark_grey" => Color.new(r: 169, g: 169, b: 169, a: 255, name: "dark_grey"),
|
185
|
+
"dim_gray" => Color.new(r: 105, g: 105, b: 105, a: 255, name: "dim_gray"),
|
186
|
+
"dim_grey" => Color.new(r: 105, g: 105, b: 105, a: 255, name: "dim_grey"),
|
187
|
+
"black" => Color.new(r: 0, g: 0, b: 0, a: 255, name: "black"),
|
188
|
+
"transparent" => Color.new(r: 0, g: 0, b: 0, a: 0, name: "transparent")
|
189
|
+
})
|
190
|
+
# rubocop:enable Layout/FirstHashElementIndentation
|
186
191
|
end
|
data/lib/fantasy/coordinates.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "vector2d"
|
2
4
|
|
3
5
|
class Coordinates < Vector2d
|
6
|
+
attr_writer :x, :y
|
7
|
+
|
4
8
|
def self.zero
|
5
9
|
Coordinates.new(0, 0)
|
6
10
|
end
|
@@ -21,19 +25,11 @@ class Coordinates < Vector2d
|
|
21
25
|
Coordinates.new(1, 0)
|
22
26
|
end
|
23
27
|
|
24
|
-
def x=(value)
|
25
|
-
@x = value
|
26
|
-
end
|
27
|
-
|
28
|
-
def y=(value)
|
29
|
-
@y = value
|
30
|
-
end
|
31
|
-
|
32
28
|
def clone
|
33
29
|
Coordinates.new(@x, @y)
|
34
30
|
end
|
35
31
|
|
36
32
|
def zero?
|
37
|
-
@x
|
33
|
+
@x.zero? && @y.zero?
|
38
34
|
end
|
39
35
|
end
|
data/lib/fantasy/cursor.rb
CHANGED
data/lib/fantasy/disk.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "json"
|
2
4
|
require "ostruct"
|
3
5
|
require "fileutils"
|
4
6
|
|
5
7
|
module Disk
|
6
|
-
|
7
|
-
|
8
|
+
@data_path = "#{Dir.pwd}/disk/data.json"
|
9
|
+
@data = nil
|
8
10
|
|
9
11
|
def self.data
|
10
12
|
@@data ||= OpenStruct.new(load)
|
@@ -19,13 +21,15 @@ module Disk
|
|
19
21
|
File.open(@@data_path, "w") { |f| f.write JSON.pretty_generate(@@data.to_h) }
|
20
22
|
end
|
21
23
|
|
22
|
-
|
24
|
+
class << self
|
25
|
+
private
|
23
26
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
27
|
+
def load
|
28
|
+
if File.file?(@@data_path)
|
29
|
+
JSON.parse(File.read(@@data_path))
|
30
|
+
else
|
31
|
+
{}
|
32
|
+
end
|
29
33
|
end
|
30
34
|
end
|
31
35
|
end
|
data/lib/fantasy/draggable.rb
CHANGED
@@ -1,16 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Draggable
|
4
|
+
# rubocop:disable Style/GuardClause
|
2
5
|
def drag
|
3
6
|
mouse_position = Global.mouse_position
|
4
7
|
|
5
|
-
|
8
|
+
start_dragging?
|
9
|
+
stop_dragging?
|
10
|
+
drag?
|
11
|
+
end
|
12
|
+
# rubocop:enable Style/GuardClause
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def start_dragging?
|
17
|
+
if(
|
18
|
+
@draggable_on_debug &&
|
19
|
+
!@dragging &&
|
20
|
+
Gosu.button_down?(Gosu::MS_LEFT) &&
|
21
|
+
Utils.collision_at?(self, mouse_position.x, mouse_position.y)
|
22
|
+
)
|
6
23
|
@dragging = true
|
7
24
|
@dragging_offset = mouse_position - @position
|
8
25
|
end
|
26
|
+
end
|
9
27
|
|
28
|
+
def stop_dragging?
|
10
29
|
if @dragging && !Gosu.button_down?(Gosu::MS_LEFT)
|
11
30
|
@dragging = false
|
12
31
|
end
|
32
|
+
end
|
13
33
|
|
34
|
+
def drag?
|
14
35
|
if @dragging
|
15
36
|
@position = mouse_position - @dragging_offset
|
16
37
|
end
|