game_cargo
Clone
https://git.tahinli.com/Tahinli/game_cargo.git
0 watching0 forksRust201.2 KiB5226b95Tahinli1 month ago1 commit
| 1 | //! Opening tutorial that teaches by pointing. Arrows and pulsing rings are drawn on the map |
| 2 | //! with a short caption each, and the player's own drags move the tutorial along. |
| 3 | //! |
| 4 | //! The steps are: send Ammo, Food and Troops into the Centre Sector by dragging from a source |
| 5 | //! node to it, then supply the North and South Sectors for a few seconds. The tutorial is |
| 6 | //! skipped in the scenario and demo runs. |
| 7 | |
| 8 | use TAU; |
| 9 | |
| 10 | use SystemParam; |
| 11 | use *; |
| 12 | use ; |
| 13 | |
| 14 | use crateWorldText; |
| 15 | use crateMenu; |
| 16 | use crate; |
| 17 | |
| 18 | const INK: Color = srgb; |
| 19 | const RUST: Color = srgb; |
| 20 | |
| 21 | /// Glyph size of the captions, in world units. |
| 22 | const CAPTION_SIZE: f32 = 30.0; |
| 23 | /// Average advance of the caption font in ems, to estimate its width before layout. |
| 24 | const CAPTION_CHAR_EM: f32 = 0.6; |
| 25 | /// Gap between the target node centre and the caption's right edge, clear of the node icon |
| 26 | /// and the arrow head. |
| 27 | const CAPTION_NODE_GAP: f32 = 40.0; |
| 28 | /// How far below the target a step's caption sits. Keeps it off the node name label above |
| 29 | /// the node and off the arrow shaft coming in from the left. |
| 30 | const CAPTION_DROP: f32 = 20.0; |
| 31 | /// Caption centres are kept this far inside the map frame, in world units. The frame is |
| 32 | /// 1280 by 720, so the x limit leaves a margin at each side. |
| 33 | const CAPTION_X_LIMIT: f32 = 560.0; |
| 34 | const CAPTION_Y_LIMIT: f32 = 340.0; |
| 35 | /// Radius of the pulsing ring around a node, at rest. |
| 36 | const RING_RADIUS: f32 = 26.0; |
| 37 | /// Seconds per pulse of the rings. |
| 38 | const PULSE_PERIOD: f32 = 1.2; |
| 39 | /// Distance from the source centre where the arrow starts, clear of its ring. |
| 40 | const ARROW_START_GAP: f32 = 32.0; |
| 41 | /// Distance from the target centre where the arrow tip sits, clear of the node icon. |
| 42 | const ARROW_TIP_GAP: f32 = 26.0; |
| 43 | /// Length of the arrowhead. |
| 44 | const ARROW_HEAD_LEN: f32 = 18.0; |
| 45 | /// Half the width of the arrowhead base. |
| 46 | const ARROW_HEAD_HALF_W: f32 = 9.0; |
| 47 | /// Spacing between the parallel lines that make the shaft thick. |
| 48 | const SHAFT_LINE_STEP: f32 = 1.2; |
| 49 | /// Number of parallel lines on each side of the shaft centre line. |
| 50 | const SHAFT_LINES: i32 = 2; |
| 51 | /// World units per real second the dashes and chevrons travel. |
| 52 | const FLOW_SPEED: f32 = 42.0; |
| 53 | /// Length of a dash and the gap after it. |
| 54 | const DASH_ON: f32 = 14.0; |
| 55 | const DASH_PERIOD: f32 = 22.0; |
| 56 | /// Distance between chevrons along the shaft. |
| 57 | const CHEVRON_PERIOD: f32 = 66.0; |
| 58 | /// Size of a chevron's arms. |
| 59 | const CHEVRON_ARM: f32 = 6.0; |
| 60 | /// Real seconds the supply step lasts. |
| 61 | const SUPPLY_SECONDS: f32 = 8.0; |
| 62 | |
| 63 | /// One arrow step: drag from `from` to `to` to send what `from` makes. |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | const LESSONS: = |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | ; |
| 87 | |
| 88 | const SUPPLY_NODES: = ; |
| 89 | const SUPPLY_CAPTION: &str = "Now supply these"; |
| 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 | /// Marker for the caption text of the current step. |
| 136 | |
| 137 | ; |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 | /// Centre for a caption placed to the left of `target`, `drop` below its height. The result |
| 152 | /// is clamped so the whole caption stays inside the map frame. |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 | |
| 160 | |
| 161 | |
| 162 | |
| 163 | |
| 164 | |
| 165 | |
| 166 | |
| 167 | |
| 168 | |
| 169 | /// True when some train's route visits both nodes. |
| 170 | |
| 171 | |
| 172 | |
| 173 | |
| 174 | |
| 175 | |
| 176 | /// What to draw for a stage, or `None` when its nodes are not on the map. |
| 177 | |
| 178 | |
| 179 | |
| 180 | |
| 181 | |
| 182 | |
| 183 | |
| 184 | |
| 185 | |
| 186 | |
| 187 | |
| 188 | |
| 189 | |
| 190 | |
| 191 | |
| 192 | |
| 193 | |
| 194 | |
| 195 | |
| 196 | |
| 197 | |
| 198 | |
| 199 | |
| 200 | |
| 201 | |
| 202 | |
| 203 | |
| 204 | |
| 205 | |
| 206 | |
| 207 | |
| 208 | |
| 209 | |
| 210 | |
| 211 | |
| 212 | |
| 213 | /// What the tutorial reads and draws, grouped to keep the system signature short. |
| 214 | |
| 215 | |
| 216 | |
| 217 | |
| 218 | |
| 219 | |
| 220 | |
| 221 | |
| 222 | |
| 223 | |
| 224 | |
| 225 | |
| 226 | |
| 227 | |
| 228 | |
| 229 | |
| 230 | |
| 231 | |
| 232 | |
| 233 | |
| 234 | |
| 235 | |
| 236 | |
| 237 | |
| 238 | |
| 239 | |
| 240 | |
| 241 | |
| 242 | |
| 243 | |
| 244 | |
| 245 | |
| 246 | |
| 247 | |
| 248 | |
| 249 | |
| 250 | |
| 251 | |
| 252 | |
| 253 | |
| 254 | |
| 255 | |
| 256 | |
| 257 | |
| 258 | |
| 259 | |
| 260 | |
| 261 | |
| 262 | |
| 263 | |
| 264 | |
| 265 | |
| 266 | |
| 267 | |
| 268 | |
| 269 | |
| 270 | |
| 271 | |
| 272 | |
| 273 | |
| 274 | |
| 275 | |
| 276 | |
| 277 | |
| 278 | |
| 279 | |
| 280 | |
| 281 | |
| 282 | |
| 283 | |
| 284 | |
| 285 | |
| 286 | |
| 287 | |
| 288 | |
| 289 | |
| 290 | |
| 291 | |
| 292 | |
| 293 | |
| 294 | |
| 295 | |
| 296 | |
| 297 | |
| 298 | |
| 299 | |
| 300 | |
| 301 | |
| 302 | |
| 303 | |
| 304 | |
| 305 | |
| 306 | |
| 307 | |
| 308 | |
| 309 | |
| 310 | |
| 311 | |
| 312 | /// Pulsing ring that marks where to grab or where to supply. |
| 313 | |
| 314 | |
| 315 | |
| 316 | |
| 317 | |
| 318 | |
| 319 | |
| 320 | |
| 321 | /// Thick dashed shaft with chevrons flowing from `from` to `to`, and a filled head at `to`. |
| 322 | |
| 323 | |
| 324 | |
| 325 | |
| 326 | |
| 327 | |
| 328 | |
| 329 | |
| 330 | |
| 331 | |
| 332 | |
| 333 | |
| 334 | |
| 335 | |
| 336 | |
| 337 | |
| 338 | |
| 339 | |
| 340 | |
| 341 | |
| 342 | |
| 343 | |
| 344 | |
| 345 | |
| 346 | |
| 347 | |
| 348 | |
| 349 | |
| 350 | |
| 351 | |
| 352 | |
| 353 | |
| 354 | |
| 355 | |
| 356 | |
| 357 | |
| 358 | |
| 359 | |
| 360 | |
| 361 | |
| 362 | |
| 363 | |
| 364 | |
| 365 | |
| 366 |