├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── README.md ├── bin └── assets │ ├── comment1.png │ ├── comment2.png │ ├── digits.png │ └── logo.png ├── rust-2048.png └── src ├── app.rs ├── board.rs ├── main.rs ├── number_renderer.rs ├── settings.rs └── tile.rs /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *~ 3 | *# 4 | *.o 5 | *.so 6 | *.swp 7 | *.dylib 8 | *.dSYM 9 | *.dll 10 | *.rlib 11 | *.dummy 12 | *.exe 13 | *-test 14 | /bin/main 15 | /bin/test-internal 16 | /bin/test-external 17 | /doc/ 18 | /target/ 19 | /build/ 20 | /.rust/ 21 | rusti.sh 22 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "ab_glyph_rasterizer" 7 | version = "0.1.8" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "c71b1793ee61086797f5c80b6efa2b8ffa6d5dd703f118545808a7f2e27f7046" 10 | 11 | [[package]] 12 | name = "adler" 13 | version = "1.0.2" 14 | source = "registry+https://github.com/rust-lang/crates.io-index" 15 | checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" 16 | 17 | [[package]] 18 | name = "andrew" 19 | version = "0.3.1" 20 | source = "registry+https://github.com/rust-lang/crates.io-index" 21 | checksum = "8c4afb09dd642feec8408e33f92f3ffc4052946f6b20f32fb99c1f58cd4fa7cf" 22 | dependencies = [ 23 | "bitflags", 24 | "rusttype", 25 | "walkdir", 26 | "xdg", 27 | "xml-rs", 28 | ] 29 | 30 | [[package]] 31 | name = "android_glue" 32 | version = "0.2.3" 33 | source = "registry+https://github.com/rust-lang/crates.io-index" 34 | checksum = "000444226fcff248f2bc4c7625be32c63caccfecc2723a2b9f78a7487a49c407" 35 | 36 | [[package]] 37 | name = "autocfg" 38 | version = "1.1.0" 39 | source = "registry+https://github.com/rust-lang/crates.io-index" 40 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 41 | 42 | [[package]] 43 | name = "bit_field" 44 | version = "0.10.2" 45 | source = "registry+https://github.com/rust-lang/crates.io-index" 46 | checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61" 47 | 48 | [[package]] 49 | name = "bitflags" 50 | version = "1.3.2" 51 | source = "registry+https://github.com/rust-lang/crates.io-index" 52 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 53 | 54 | [[package]] 55 | name = "block" 56 | version = "0.1.6" 57 | source = "registry+https://github.com/rust-lang/crates.io-index" 58 | checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" 59 | 60 | [[package]] 61 | name = "bumpalo" 62 | version = "3.12.0" 63 | source = "registry+https://github.com/rust-lang/crates.io-index" 64 | checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" 65 | 66 | [[package]] 67 | name = "bytemuck" 68 | version = "1.13.1" 69 | source = "registry+https://github.com/rust-lang/crates.io-index" 70 | checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea" 71 | 72 | [[package]] 73 | name = "byteorder" 74 | version = "1.4.3" 75 | source = "registry+https://github.com/rust-lang/crates.io-index" 76 | checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" 77 | 78 | [[package]] 79 | name = "calloop" 80 | version = "0.6.5" 81 | source = "registry+https://github.com/rust-lang/crates.io-index" 82 | checksum = "0b036167e76041694579972c28cf4877b4f92da222560ddb49008937b6a6727c" 83 | dependencies = [ 84 | "log", 85 | "nix 0.18.0", 86 | ] 87 | 88 | [[package]] 89 | name = "cc" 90 | version = "1.0.79" 91 | source = "registry+https://github.com/rust-lang/crates.io-index" 92 | checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" 93 | 94 | [[package]] 95 | name = "cfg-if" 96 | version = "0.1.10" 97 | source = "registry+https://github.com/rust-lang/crates.io-index" 98 | checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" 99 | 100 | [[package]] 101 | name = "cfg-if" 102 | version = "1.0.0" 103 | source = "registry+https://github.com/rust-lang/crates.io-index" 104 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 105 | 106 | [[package]] 107 | name = "cgl" 108 | version = "0.3.2" 109 | source = "registry+https://github.com/rust-lang/crates.io-index" 110 | checksum = "0ced0551234e87afee12411d535648dd89d2e7f34c78b753395567aff3d447ff" 111 | dependencies = [ 112 | "libc", 113 | ] 114 | 115 | [[package]] 116 | name = "cocoa" 117 | version = "0.23.0" 118 | source = "registry+https://github.com/rust-lang/crates.io-index" 119 | checksum = "c54201c07dcf3a5ca33fececb8042aed767ee4bfd5a0235a8ceabcda956044b2" 120 | dependencies = [ 121 | "bitflags", 122 | "block", 123 | "cocoa-foundation", 124 | "core-foundation 0.9.3", 125 | "core-graphics 0.22.3", 126 | "foreign-types", 127 | "libc", 128 | "objc", 129 | ] 130 | 131 | [[package]] 132 | name = "cocoa" 133 | version = "0.24.1" 134 | source = "registry+https://github.com/rust-lang/crates.io-index" 135 | checksum = "f425db7937052c684daec3bd6375c8abe2d146dca4b8b143d6db777c39138f3a" 136 | dependencies = [ 137 | "bitflags", 138 | "block", 139 | "cocoa-foundation", 140 | "core-foundation 0.9.3", 141 | "core-graphics 0.22.3", 142 | "foreign-types", 143 | "libc", 144 | "objc", 145 | ] 146 | 147 | [[package]] 148 | name = "cocoa-foundation" 149 | version = "0.1.0" 150 | source = "registry+https://github.com/rust-lang/crates.io-index" 151 | checksum = "7ade49b65d560ca58c403a479bb396592b155c0185eada742ee323d1d68d6318" 152 | dependencies = [ 153 | "bitflags", 154 | "block", 155 | "core-foundation 0.9.3", 156 | "core-graphics-types", 157 | "foreign-types", 158 | "libc", 159 | "objc", 160 | ] 161 | 162 | [[package]] 163 | name = "color_quant" 164 | version = "1.1.0" 165 | source = "registry+https://github.com/rust-lang/crates.io-index" 166 | checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" 167 | 168 | [[package]] 169 | name = "core-foundation" 170 | version = "0.7.0" 171 | source = "registry+https://github.com/rust-lang/crates.io-index" 172 | checksum = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171" 173 | dependencies = [ 174 | "core-foundation-sys 0.7.0", 175 | "libc", 176 | ] 177 | 178 | [[package]] 179 | name = "core-foundation" 180 | version = "0.9.3" 181 | source = "registry+https://github.com/rust-lang/crates.io-index" 182 | checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" 183 | dependencies = [ 184 | "core-foundation-sys 0.8.3", 185 | "libc", 186 | ] 187 | 188 | [[package]] 189 | name = "core-foundation-sys" 190 | version = "0.7.0" 191 | source = "registry+https://github.com/rust-lang/crates.io-index" 192 | checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac" 193 | 194 | [[package]] 195 | name = "core-foundation-sys" 196 | version = "0.8.3" 197 | source = "registry+https://github.com/rust-lang/crates.io-index" 198 | checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" 199 | 200 | [[package]] 201 | name = "core-graphics" 202 | version = "0.19.2" 203 | source = "registry+https://github.com/rust-lang/crates.io-index" 204 | checksum = "b3889374e6ea6ab25dba90bb5d96202f61108058361f6dc72e8b03e6f8bbe923" 205 | dependencies = [ 206 | "bitflags", 207 | "core-foundation 0.7.0", 208 | "foreign-types", 209 | "libc", 210 | ] 211 | 212 | [[package]] 213 | name = "core-graphics" 214 | version = "0.22.3" 215 | source = "registry+https://github.com/rust-lang/crates.io-index" 216 | checksum = "2581bbab3b8ffc6fcbd550bf46c355135d16e9ff2a6ea032ad6b9bf1d7efe4fb" 217 | dependencies = [ 218 | "bitflags", 219 | "core-foundation 0.9.3", 220 | "core-graphics-types", 221 | "foreign-types", 222 | "libc", 223 | ] 224 | 225 | [[package]] 226 | name = "core-graphics-types" 227 | version = "0.1.1" 228 | source = "registry+https://github.com/rust-lang/crates.io-index" 229 | checksum = "3a68b68b3446082644c91ac778bf50cd4104bfb002b5a6a7c44cca5a2c70788b" 230 | dependencies = [ 231 | "bitflags", 232 | "core-foundation 0.9.3", 233 | "foreign-types", 234 | "libc", 235 | ] 236 | 237 | [[package]] 238 | name = "core-video-sys" 239 | version = "0.1.4" 240 | source = "registry+https://github.com/rust-lang/crates.io-index" 241 | checksum = "34ecad23610ad9757664d644e369246edde1803fcb43ed72876565098a5d3828" 242 | dependencies = [ 243 | "cfg-if 0.1.10", 244 | "core-foundation-sys 0.7.0", 245 | "core-graphics 0.19.2", 246 | "libc", 247 | "objc", 248 | ] 249 | 250 | [[package]] 251 | name = "crc32fast" 252 | version = "1.3.2" 253 | source = "registry+https://github.com/rust-lang/crates.io-index" 254 | checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" 255 | dependencies = [ 256 | "cfg-if 1.0.0", 257 | ] 258 | 259 | [[package]] 260 | name = "crossbeam-channel" 261 | version = "0.5.7" 262 | source = "registry+https://github.com/rust-lang/crates.io-index" 263 | checksum = "cf2b3e8478797446514c91ef04bafcb59faba183e621ad488df88983cc14128c" 264 | dependencies = [ 265 | "cfg-if 1.0.0", 266 | "crossbeam-utils", 267 | ] 268 | 269 | [[package]] 270 | name = "crossbeam-deque" 271 | version = "0.8.3" 272 | source = "registry+https://github.com/rust-lang/crates.io-index" 273 | checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" 274 | dependencies = [ 275 | "cfg-if 1.0.0", 276 | "crossbeam-epoch", 277 | "crossbeam-utils", 278 | ] 279 | 280 | [[package]] 281 | name = "crossbeam-epoch" 282 | version = "0.9.14" 283 | source = "registry+https://github.com/rust-lang/crates.io-index" 284 | checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695" 285 | dependencies = [ 286 | "autocfg", 287 | "cfg-if 1.0.0", 288 | "crossbeam-utils", 289 | "memoffset", 290 | "scopeguard", 291 | ] 292 | 293 | [[package]] 294 | name = "crossbeam-utils" 295 | version = "0.8.15" 296 | source = "registry+https://github.com/rust-lang/crates.io-index" 297 | checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" 298 | dependencies = [ 299 | "cfg-if 1.0.0", 300 | ] 301 | 302 | [[package]] 303 | name = "crunchy" 304 | version = "0.2.2" 305 | source = "registry+https://github.com/rust-lang/crates.io-index" 306 | checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" 307 | 308 | [[package]] 309 | name = "cty" 310 | version = "0.2.2" 311 | source = "registry+https://github.com/rust-lang/crates.io-index" 312 | checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35" 313 | 314 | [[package]] 315 | name = "darling" 316 | version = "0.10.2" 317 | source = "registry+https://github.com/rust-lang/crates.io-index" 318 | checksum = "0d706e75d87e35569db781a9b5e2416cff1236a47ed380831f959382ccd5f858" 319 | dependencies = [ 320 | "darling_core", 321 | "darling_macro", 322 | ] 323 | 324 | [[package]] 325 | name = "darling_core" 326 | version = "0.10.2" 327 | source = "registry+https://github.com/rust-lang/crates.io-index" 328 | checksum = "f0c960ae2da4de88a91b2d920c2a7233b400bc33cb28453a2987822d8392519b" 329 | dependencies = [ 330 | "fnv", 331 | "ident_case", 332 | "proc-macro2", 333 | "quote", 334 | "strsim", 335 | "syn", 336 | ] 337 | 338 | [[package]] 339 | name = "darling_macro" 340 | version = "0.10.2" 341 | source = "registry+https://github.com/rust-lang/crates.io-index" 342 | checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72" 343 | dependencies = [ 344 | "darling_core", 345 | "quote", 346 | "syn", 347 | ] 348 | 349 | [[package]] 350 | name = "derivative" 351 | version = "2.2.0" 352 | source = "registry+https://github.com/rust-lang/crates.io-index" 353 | checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" 354 | dependencies = [ 355 | "proc-macro2", 356 | "quote", 357 | "syn", 358 | ] 359 | 360 | [[package]] 361 | name = "dirs" 362 | version = "4.0.0" 363 | source = "registry+https://github.com/rust-lang/crates.io-index" 364 | checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" 365 | dependencies = [ 366 | "dirs-sys", 367 | ] 368 | 369 | [[package]] 370 | name = "dirs-sys" 371 | version = "0.3.7" 372 | source = "registry+https://github.com/rust-lang/crates.io-index" 373 | checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" 374 | dependencies = [ 375 | "libc", 376 | "redox_users", 377 | "winapi 0.3.9", 378 | ] 379 | 380 | [[package]] 381 | name = "dispatch" 382 | version = "0.2.0" 383 | source = "registry+https://github.com/rust-lang/crates.io-index" 384 | checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b" 385 | 386 | [[package]] 387 | name = "dlib" 388 | version = "0.4.2" 389 | source = "registry+https://github.com/rust-lang/crates.io-index" 390 | checksum = "b11f15d1e3268f140f68d390637d5e76d849782d971ae7063e0da69fe9709a76" 391 | dependencies = [ 392 | "libloading 0.6.7", 393 | ] 394 | 395 | [[package]] 396 | name = "dlib" 397 | version = "0.5.0" 398 | source = "registry+https://github.com/rust-lang/crates.io-index" 399 | checksum = "ac1b7517328c04c2aa68422fc60a41b92208182142ed04a25879c26c8f878794" 400 | dependencies = [ 401 | "libloading 0.7.4", 402 | ] 403 | 404 | [[package]] 405 | name = "downcast-rs" 406 | version = "1.2.0" 407 | source = "registry+https://github.com/rust-lang/crates.io-index" 408 | checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" 409 | 410 | [[package]] 411 | name = "draw_state" 412 | version = "0.8.0" 413 | source = "registry+https://github.com/rust-lang/crates.io-index" 414 | checksum = "33cf9537e2d06891448799b96d5a8c8083e0e90522a7fdabe6ebf4f41d79d651" 415 | dependencies = [ 416 | "bitflags", 417 | ] 418 | 419 | [[package]] 420 | name = "either" 421 | version = "1.8.1" 422 | source = "registry+https://github.com/rust-lang/crates.io-index" 423 | checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" 424 | 425 | [[package]] 426 | name = "exr" 427 | version = "1.6.3" 428 | source = "registry+https://github.com/rust-lang/crates.io-index" 429 | checksum = "bdd2162b720141a91a054640662d3edce3d50a944a50ffca5313cd951abb35b4" 430 | dependencies = [ 431 | "bit_field", 432 | "flume", 433 | "half", 434 | "lebe", 435 | "miniz_oxide", 436 | "rayon-core", 437 | "smallvec", 438 | "zune-inflate", 439 | ] 440 | 441 | [[package]] 442 | name = "flate2" 443 | version = "1.0.25" 444 | source = "registry+https://github.com/rust-lang/crates.io-index" 445 | checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841" 446 | dependencies = [ 447 | "crc32fast", 448 | "miniz_oxide", 449 | ] 450 | 451 | [[package]] 452 | name = "flume" 453 | version = "0.10.14" 454 | source = "registry+https://github.com/rust-lang/crates.io-index" 455 | checksum = "1657b4441c3403d9f7b3409e47575237dac27b1b5726df654a6ecbf92f0f7577" 456 | dependencies = [ 457 | "futures-core", 458 | "futures-sink", 459 | "nanorand", 460 | "pin-project", 461 | "spin", 462 | ] 463 | 464 | [[package]] 465 | name = "fnv" 466 | version = "1.0.7" 467 | source = "registry+https://github.com/rust-lang/crates.io-index" 468 | checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 469 | 470 | [[package]] 471 | name = "foreign-types" 472 | version = "0.3.2" 473 | source = "registry+https://github.com/rust-lang/crates.io-index" 474 | checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" 475 | dependencies = [ 476 | "foreign-types-shared", 477 | ] 478 | 479 | [[package]] 480 | name = "foreign-types-shared" 481 | version = "0.1.1" 482 | source = "registry+https://github.com/rust-lang/crates.io-index" 483 | checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" 484 | 485 | [[package]] 486 | name = "fuchsia-cprng" 487 | version = "0.1.1" 488 | source = "registry+https://github.com/rust-lang/crates.io-index" 489 | checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" 490 | 491 | [[package]] 492 | name = "fuchsia-zircon" 493 | version = "0.3.3" 494 | source = "registry+https://github.com/rust-lang/crates.io-index" 495 | checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" 496 | dependencies = [ 497 | "bitflags", 498 | "fuchsia-zircon-sys", 499 | ] 500 | 501 | [[package]] 502 | name = "fuchsia-zircon-sys" 503 | version = "0.3.3" 504 | source = "registry+https://github.com/rust-lang/crates.io-index" 505 | checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" 506 | 507 | [[package]] 508 | name = "futures-core" 509 | version = "0.3.27" 510 | source = "registry+https://github.com/rust-lang/crates.io-index" 511 | checksum = "86d7a0c1aa76363dac491de0ee99faf6941128376f1cf96f07db7603b7de69dd" 512 | 513 | [[package]] 514 | name = "futures-sink" 515 | version = "0.3.27" 516 | source = "registry+https://github.com/rust-lang/crates.io-index" 517 | checksum = "ec93083a4aecafb2a80a885c9de1f0ccae9dbd32c2bb54b0c3a65690e0b8d2f2" 518 | 519 | [[package]] 520 | name = "getrandom" 521 | version = "0.2.8" 522 | source = "registry+https://github.com/rust-lang/crates.io-index" 523 | checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" 524 | dependencies = [ 525 | "cfg-if 1.0.0", 526 | "js-sys", 527 | "libc", 528 | "wasi", 529 | "wasm-bindgen", 530 | ] 531 | 532 | [[package]] 533 | name = "gfx" 534 | version = "0.18.3" 535 | source = "registry+https://github.com/rust-lang/crates.io-index" 536 | checksum = "eb754057e8bfb8fdb38a33b9caa213dbeb2cbbef2003fe6b2cb36dff96098e0a" 537 | dependencies = [ 538 | "draw_state", 539 | "gfx_core", 540 | "log", 541 | ] 542 | 543 | [[package]] 544 | name = "gfx_core" 545 | version = "0.9.2" 546 | source = "registry+https://github.com/rust-lang/crates.io-index" 547 | checksum = "75fbddaef2e12b4995900539d7209d947b988a3d87ee8737484d049b526e5441" 548 | dependencies = [ 549 | "bitflags", 550 | "draw_state", 551 | "log", 552 | ] 553 | 554 | [[package]] 555 | name = "gfx_device_gl" 556 | version = "0.16.2" 557 | source = "registry+https://github.com/rust-lang/crates.io-index" 558 | checksum = "109c385fa380c18888633aa27d1e16cbae518469702a2f69dcb5f52d5378bebc" 559 | dependencies = [ 560 | "gfx_core", 561 | "gfx_gl", 562 | "log", 563 | ] 564 | 565 | [[package]] 566 | name = "gfx_gl" 567 | version = "0.6.1" 568 | source = "registry+https://github.com/rust-lang/crates.io-index" 569 | checksum = "f2d38164670920cfb7491bc0cf6f49f0554bd1c44cdbedc6c78d2bf91691ff5e" 570 | dependencies = [ 571 | "gl_generator 0.14.0", 572 | ] 573 | 574 | [[package]] 575 | name = "gif" 576 | version = "0.11.4" 577 | source = "registry+https://github.com/rust-lang/crates.io-index" 578 | checksum = "3edd93c6756b4dfaf2709eafcc345ba2636565295c198a9cfbf75fa5e3e00b06" 579 | dependencies = [ 580 | "color_quant", 581 | "weezl", 582 | ] 583 | 584 | [[package]] 585 | name = "gl" 586 | version = "0.13.0" 587 | source = "registry+https://github.com/rust-lang/crates.io-index" 588 | checksum = "4b411c7e0bfc599e3606412c190e786b5bb48cf00073e1635f9bb6f88fe7d84a" 589 | dependencies = [ 590 | "gl_generator 0.13.1", 591 | ] 592 | 593 | [[package]] 594 | name = "gl_generator" 595 | version = "0.13.1" 596 | source = "registry+https://github.com/rust-lang/crates.io-index" 597 | checksum = "ca98bbde17256e02d17336a6bdb5a50f7d0ccacee502e191d3e3d0ec2f96f84a" 598 | dependencies = [ 599 | "khronos_api 3.1.0", 600 | "log", 601 | "xml-rs", 602 | ] 603 | 604 | [[package]] 605 | name = "gl_generator" 606 | version = "0.14.0" 607 | source = "registry+https://github.com/rust-lang/crates.io-index" 608 | checksum = "1a95dfc23a2b4a9a2f5ab41d194f8bfda3cabec42af4e39f08c339eb2a0c124d" 609 | dependencies = [ 610 | "khronos_api 3.1.0", 611 | "log", 612 | "xml-rs", 613 | ] 614 | 615 | [[package]] 616 | name = "glutin" 617 | version = "0.26.0" 618 | source = "registry+https://github.com/rust-lang/crates.io-index" 619 | checksum = "1ae1cbb9176b9151c4ce03f012e3cd1c6c18c4be79edeaeb3d99f5d8085c5fa3" 620 | dependencies = [ 621 | "android_glue", 622 | "cgl", 623 | "cocoa 0.23.0", 624 | "core-foundation 0.9.3", 625 | "glutin_egl_sys", 626 | "glutin_emscripten_sys", 627 | "glutin_gles2_sys", 628 | "glutin_glx_sys", 629 | "glutin_wgl_sys", 630 | "lazy_static", 631 | "libloading 0.6.7", 632 | "log", 633 | "objc", 634 | "osmesa-sys", 635 | "parking_lot", 636 | "wayland-client", 637 | "wayland-egl", 638 | "winapi 0.3.9", 639 | "winit", 640 | ] 641 | 642 | [[package]] 643 | name = "glutin_egl_sys" 644 | version = "0.1.6" 645 | source = "registry+https://github.com/rust-lang/crates.io-index" 646 | checksum = "68900f84b471f31ea1d1355567eb865a2cf446294f06cef8d653ed7bcf5f013d" 647 | dependencies = [ 648 | "gl_generator 0.14.0", 649 | "winapi 0.3.9", 650 | ] 651 | 652 | [[package]] 653 | name = "glutin_emscripten_sys" 654 | version = "0.1.1" 655 | source = "registry+https://github.com/rust-lang/crates.io-index" 656 | checksum = "80de4146df76e8a6c32b03007bc764ff3249dcaeb4f675d68a06caf1bac363f1" 657 | 658 | [[package]] 659 | name = "glutin_gles2_sys" 660 | version = "0.1.5" 661 | source = "registry+https://github.com/rust-lang/crates.io-index" 662 | checksum = "e8094e708b730a7c8a1954f4f8a31880af00eb8a1c5b5bf85d28a0a3c6d69103" 663 | dependencies = [ 664 | "gl_generator 0.14.0", 665 | "objc", 666 | ] 667 | 668 | [[package]] 669 | name = "glutin_glx_sys" 670 | version = "0.1.8" 671 | source = "registry+https://github.com/rust-lang/crates.io-index" 672 | checksum = "d93d0575865098580c5b3a423188cd959419912ea60b1e48e8b3b526f6d02468" 673 | dependencies = [ 674 | "gl_generator 0.14.0", 675 | "x11-dl", 676 | ] 677 | 678 | [[package]] 679 | name = "glutin_wgl_sys" 680 | version = "0.1.5" 681 | source = "registry+https://github.com/rust-lang/crates.io-index" 682 | checksum = "3da5951a1569dbab865c6f2a863efafff193a93caf05538d193e9e3816d21696" 683 | dependencies = [ 684 | "gl_generator 0.14.0", 685 | ] 686 | 687 | [[package]] 688 | name = "half" 689 | version = "2.2.1" 690 | source = "registry+https://github.com/rust-lang/crates.io-index" 691 | checksum = "02b4af3693f1b705df946e9fe5631932443781d0aabb423b62fcd4d73f6d2fd0" 692 | dependencies = [ 693 | "crunchy", 694 | ] 695 | 696 | [[package]] 697 | name = "hermit-abi" 698 | version = "0.2.6" 699 | source = "registry+https://github.com/rust-lang/crates.io-index" 700 | checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" 701 | dependencies = [ 702 | "libc", 703 | ] 704 | 705 | [[package]] 706 | name = "ident_case" 707 | version = "1.0.1" 708 | source = "registry+https://github.com/rust-lang/crates.io-index" 709 | checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" 710 | 711 | [[package]] 712 | name = "image" 713 | version = "0.24.5" 714 | source = "registry+https://github.com/rust-lang/crates.io-index" 715 | checksum = "69b7ea949b537b0fd0af141fff8c77690f2ce96f4f41f042ccb6c69c6c965945" 716 | dependencies = [ 717 | "bytemuck", 718 | "byteorder", 719 | "color_quant", 720 | "exr", 721 | "gif", 722 | "jpeg-decoder", 723 | "num-rational", 724 | "num-traits", 725 | "png", 726 | "scoped_threadpool", 727 | "tiff", 728 | ] 729 | 730 | [[package]] 731 | name = "instant" 732 | version = "0.1.12" 733 | source = "registry+https://github.com/rust-lang/crates.io-index" 734 | checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" 735 | dependencies = [ 736 | "cfg-if 1.0.0", 737 | ] 738 | 739 | [[package]] 740 | name = "interpolation" 741 | version = "0.2.0" 742 | source = "registry+https://github.com/rust-lang/crates.io-index" 743 | checksum = "d3b7357d2bbc5ee92f8e899ab645233e43d21407573cceb37fed8bc3dede2c02" 744 | 745 | [[package]] 746 | name = "iovec" 747 | version = "0.1.4" 748 | source = "registry+https://github.com/rust-lang/crates.io-index" 749 | checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" 750 | dependencies = [ 751 | "libc", 752 | ] 753 | 754 | [[package]] 755 | name = "jni-sys" 756 | version = "0.3.0" 757 | source = "registry+https://github.com/rust-lang/crates.io-index" 758 | checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" 759 | 760 | [[package]] 761 | name = "jpeg-decoder" 762 | version = "0.3.0" 763 | source = "registry+https://github.com/rust-lang/crates.io-index" 764 | checksum = "bc0000e42512c92e31c2252315bda326620a4e034105e900c98ec492fa077b3e" 765 | dependencies = [ 766 | "rayon", 767 | ] 768 | 769 | [[package]] 770 | name = "js-sys" 771 | version = "0.3.61" 772 | source = "registry+https://github.com/rust-lang/crates.io-index" 773 | checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" 774 | dependencies = [ 775 | "wasm-bindgen", 776 | ] 777 | 778 | [[package]] 779 | name = "kernel32-sys" 780 | version = "0.2.2" 781 | source = "registry+https://github.com/rust-lang/crates.io-index" 782 | checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" 783 | dependencies = [ 784 | "winapi 0.2.8", 785 | "winapi-build", 786 | ] 787 | 788 | [[package]] 789 | name = "khronos_api" 790 | version = "2.2.0" 791 | source = "registry+https://github.com/rust-lang/crates.io-index" 792 | checksum = "037ab472c33f67b5fbd3e9163a2645319e5356fcd355efa6d4eb7fff4bbcb554" 793 | 794 | [[package]] 795 | name = "khronos_api" 796 | version = "3.1.0" 797 | source = "registry+https://github.com/rust-lang/crates.io-index" 798 | checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" 799 | 800 | [[package]] 801 | name = "lazy_static" 802 | version = "1.4.0" 803 | source = "registry+https://github.com/rust-lang/crates.io-index" 804 | checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 805 | 806 | [[package]] 807 | name = "lazycell" 808 | version = "1.3.0" 809 | source = "registry+https://github.com/rust-lang/crates.io-index" 810 | checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" 811 | 812 | [[package]] 813 | name = "lebe" 814 | version = "0.5.2" 815 | source = "registry+https://github.com/rust-lang/crates.io-index" 816 | checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" 817 | 818 | [[package]] 819 | name = "libc" 820 | version = "0.2.140" 821 | source = "registry+https://github.com/rust-lang/crates.io-index" 822 | checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" 823 | 824 | [[package]] 825 | name = "libloading" 826 | version = "0.6.7" 827 | source = "registry+https://github.com/rust-lang/crates.io-index" 828 | checksum = "351a32417a12d5f7e82c368a66781e307834dae04c6ce0cd4456d52989229883" 829 | dependencies = [ 830 | "cfg-if 1.0.0", 831 | "winapi 0.3.9", 832 | ] 833 | 834 | [[package]] 835 | name = "libloading" 836 | version = "0.7.4" 837 | source = "registry+https://github.com/rust-lang/crates.io-index" 838 | checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" 839 | dependencies = [ 840 | "cfg-if 1.0.0", 841 | "winapi 0.3.9", 842 | ] 843 | 844 | [[package]] 845 | name = "lock_api" 846 | version = "0.4.9" 847 | source = "registry+https://github.com/rust-lang/crates.io-index" 848 | checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" 849 | dependencies = [ 850 | "autocfg", 851 | "scopeguard", 852 | ] 853 | 854 | [[package]] 855 | name = "log" 856 | version = "0.4.17" 857 | source = "registry+https://github.com/rust-lang/crates.io-index" 858 | checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" 859 | dependencies = [ 860 | "cfg-if 1.0.0", 861 | ] 862 | 863 | [[package]] 864 | name = "malloc_buf" 865 | version = "0.0.6" 866 | source = "registry+https://github.com/rust-lang/crates.io-index" 867 | checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" 868 | dependencies = [ 869 | "libc", 870 | ] 871 | 872 | [[package]] 873 | name = "memchr" 874 | version = "2.5.0" 875 | source = "registry+https://github.com/rust-lang/crates.io-index" 876 | checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" 877 | 878 | [[package]] 879 | name = "memmap2" 880 | version = "0.1.0" 881 | source = "registry+https://github.com/rust-lang/crates.io-index" 882 | checksum = "d9b70ca2a6103ac8b665dc150b142ef0e4e89df640c9e6cf295d189c3caebe5a" 883 | dependencies = [ 884 | "libc", 885 | ] 886 | 887 | [[package]] 888 | name = "memoffset" 889 | version = "0.8.0" 890 | source = "registry+https://github.com/rust-lang/crates.io-index" 891 | checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" 892 | dependencies = [ 893 | "autocfg", 894 | ] 895 | 896 | [[package]] 897 | name = "minimal-lexical" 898 | version = "0.2.1" 899 | source = "registry+https://github.com/rust-lang/crates.io-index" 900 | checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" 901 | 902 | [[package]] 903 | name = "miniz_oxide" 904 | version = "0.6.2" 905 | source = "registry+https://github.com/rust-lang/crates.io-index" 906 | checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" 907 | dependencies = [ 908 | "adler", 909 | ] 910 | 911 | [[package]] 912 | name = "mio" 913 | version = "0.6.23" 914 | source = "registry+https://github.com/rust-lang/crates.io-index" 915 | checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4" 916 | dependencies = [ 917 | "cfg-if 0.1.10", 918 | "fuchsia-zircon", 919 | "fuchsia-zircon-sys", 920 | "iovec", 921 | "kernel32-sys", 922 | "libc", 923 | "log", 924 | "miow", 925 | "net2", 926 | "slab", 927 | "winapi 0.2.8", 928 | ] 929 | 930 | [[package]] 931 | name = "mio-extras" 932 | version = "2.0.6" 933 | source = "registry+https://github.com/rust-lang/crates.io-index" 934 | checksum = "52403fe290012ce777c4626790c8951324a2b9e3316b3143779c72b029742f19" 935 | dependencies = [ 936 | "lazycell", 937 | "log", 938 | "mio", 939 | "slab", 940 | ] 941 | 942 | [[package]] 943 | name = "miow" 944 | version = "0.2.2" 945 | source = "registry+https://github.com/rust-lang/crates.io-index" 946 | checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" 947 | dependencies = [ 948 | "kernel32-sys", 949 | "net2", 950 | "winapi 0.2.8", 951 | "ws2_32-sys", 952 | ] 953 | 954 | [[package]] 955 | name = "nanorand" 956 | version = "0.7.0" 957 | source = "registry+https://github.com/rust-lang/crates.io-index" 958 | checksum = "6a51313c5820b0b02bd422f4b44776fbf47961755c74ce64afc73bfad10226c3" 959 | dependencies = [ 960 | "getrandom", 961 | ] 962 | 963 | [[package]] 964 | name = "ndk" 965 | version = "0.2.1" 966 | source = "registry+https://github.com/rust-lang/crates.io-index" 967 | checksum = "5eb167c1febed0a496639034d0c76b3b74263636045db5489eee52143c246e73" 968 | dependencies = [ 969 | "jni-sys", 970 | "ndk-sys", 971 | "num_enum", 972 | "thiserror", 973 | ] 974 | 975 | [[package]] 976 | name = "ndk-glue" 977 | version = "0.2.1" 978 | source = "registry+https://github.com/rust-lang/crates.io-index" 979 | checksum = "bdf399b8b7a39c6fb153c4ec32c72fd5fe789df24a647f229c239aa7adb15241" 980 | dependencies = [ 981 | "lazy_static", 982 | "libc", 983 | "log", 984 | "ndk", 985 | "ndk-macro", 986 | "ndk-sys", 987 | ] 988 | 989 | [[package]] 990 | name = "ndk-macro" 991 | version = "0.2.0" 992 | source = "registry+https://github.com/rust-lang/crates.io-index" 993 | checksum = "05d1c6307dc424d0f65b9b06e94f88248e6305726b14729fd67a5e47b2dc481d" 994 | dependencies = [ 995 | "darling", 996 | "proc-macro-crate", 997 | "proc-macro2", 998 | "quote", 999 | "syn", 1000 | ] 1001 | 1002 | [[package]] 1003 | name = "ndk-sys" 1004 | version = "0.2.2" 1005 | source = "registry+https://github.com/rust-lang/crates.io-index" 1006 | checksum = "e1bcdd74c20ad5d95aacd60ef9ba40fdf77f767051040541df557b7a9b2a2121" 1007 | 1008 | [[package]] 1009 | name = "net2" 1010 | version = "0.2.38" 1011 | source = "registry+https://github.com/rust-lang/crates.io-index" 1012 | checksum = "74d0df99cfcd2530b2e694f6e17e7f37b8e26bb23983ac530c0c97408837c631" 1013 | dependencies = [ 1014 | "cfg-if 0.1.10", 1015 | "libc", 1016 | "winapi 0.3.9", 1017 | ] 1018 | 1019 | [[package]] 1020 | name = "nix" 1021 | version = "0.18.0" 1022 | source = "registry+https://github.com/rust-lang/crates.io-index" 1023 | checksum = "83450fe6a6142ddd95fb064b746083fc4ef1705fe81f64a64e1d4b39f54a1055" 1024 | dependencies = [ 1025 | "bitflags", 1026 | "cc", 1027 | "cfg-if 0.1.10", 1028 | "libc", 1029 | ] 1030 | 1031 | [[package]] 1032 | name = "nix" 1033 | version = "0.20.0" 1034 | source = "registry+https://github.com/rust-lang/crates.io-index" 1035 | checksum = "fa9b4819da1bc61c0ea48b63b7bc8604064dd43013e7cc325df098d49cd7c18a" 1036 | dependencies = [ 1037 | "bitflags", 1038 | "cc", 1039 | "cfg-if 1.0.0", 1040 | "libc", 1041 | ] 1042 | 1043 | [[package]] 1044 | name = "nom" 1045 | version = "7.1.3" 1046 | source = "registry+https://github.com/rust-lang/crates.io-index" 1047 | checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" 1048 | dependencies = [ 1049 | "memchr", 1050 | "minimal-lexical", 1051 | ] 1052 | 1053 | [[package]] 1054 | name = "num-integer" 1055 | version = "0.1.45" 1056 | source = "registry+https://github.com/rust-lang/crates.io-index" 1057 | checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" 1058 | dependencies = [ 1059 | "autocfg", 1060 | "num-traits", 1061 | ] 1062 | 1063 | [[package]] 1064 | name = "num-rational" 1065 | version = "0.4.1" 1066 | source = "registry+https://github.com/rust-lang/crates.io-index" 1067 | checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" 1068 | dependencies = [ 1069 | "autocfg", 1070 | "num-integer", 1071 | "num-traits", 1072 | ] 1073 | 1074 | [[package]] 1075 | name = "num-traits" 1076 | version = "0.2.15" 1077 | source = "registry+https://github.com/rust-lang/crates.io-index" 1078 | checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" 1079 | dependencies = [ 1080 | "autocfg", 1081 | ] 1082 | 1083 | [[package]] 1084 | name = "num_cpus" 1085 | version = "1.15.0" 1086 | source = "registry+https://github.com/rust-lang/crates.io-index" 1087 | checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" 1088 | dependencies = [ 1089 | "hermit-abi", 1090 | "libc", 1091 | ] 1092 | 1093 | [[package]] 1094 | name = "num_enum" 1095 | version = "0.4.3" 1096 | source = "registry+https://github.com/rust-lang/crates.io-index" 1097 | checksum = "ca565a7df06f3d4b485494f25ba05da1435950f4dc263440eda7a6fa9b8e36e4" 1098 | dependencies = [ 1099 | "derivative", 1100 | "num_enum_derive", 1101 | ] 1102 | 1103 | [[package]] 1104 | name = "num_enum_derive" 1105 | version = "0.4.3" 1106 | source = "registry+https://github.com/rust-lang/crates.io-index" 1107 | checksum = "ffa5a33ddddfee04c0283a7653987d634e880347e96b5b2ed64de07efb59db9d" 1108 | dependencies = [ 1109 | "proc-macro-crate", 1110 | "proc-macro2", 1111 | "quote", 1112 | "syn", 1113 | ] 1114 | 1115 | [[package]] 1116 | name = "objc" 1117 | version = "0.2.7" 1118 | source = "registry+https://github.com/rust-lang/crates.io-index" 1119 | checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" 1120 | dependencies = [ 1121 | "malloc_buf", 1122 | ] 1123 | 1124 | [[package]] 1125 | name = "once_cell" 1126 | version = "1.17.1" 1127 | source = "registry+https://github.com/rust-lang/crates.io-index" 1128 | checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" 1129 | 1130 | [[package]] 1131 | name = "osmesa-sys" 1132 | version = "0.1.2" 1133 | source = "registry+https://github.com/rust-lang/crates.io-index" 1134 | checksum = "88cfece6e95d2e717e0872a7f53a8684712ad13822a7979bc760b9c77ec0013b" 1135 | dependencies = [ 1136 | "shared_library", 1137 | ] 1138 | 1139 | [[package]] 1140 | name = "owned_ttf_parser" 1141 | version = "0.15.2" 1142 | source = "registry+https://github.com/rust-lang/crates.io-index" 1143 | checksum = "05e6affeb1632d6ff6a23d2cd40ffed138e82f1532571a26f527c8a284bb2fbb" 1144 | dependencies = [ 1145 | "ttf-parser", 1146 | ] 1147 | 1148 | [[package]] 1149 | name = "parking_lot" 1150 | version = "0.11.2" 1151 | source = "registry+https://github.com/rust-lang/crates.io-index" 1152 | checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" 1153 | dependencies = [ 1154 | "instant", 1155 | "lock_api", 1156 | "parking_lot_core", 1157 | ] 1158 | 1159 | [[package]] 1160 | name = "parking_lot_core" 1161 | version = "0.8.6" 1162 | source = "registry+https://github.com/rust-lang/crates.io-index" 1163 | checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" 1164 | dependencies = [ 1165 | "cfg-if 1.0.0", 1166 | "instant", 1167 | "libc", 1168 | "redox_syscall", 1169 | "smallvec", 1170 | "winapi 0.3.9", 1171 | ] 1172 | 1173 | [[package]] 1174 | name = "percent-encoding" 1175 | version = "2.2.0" 1176 | source = "registry+https://github.com/rust-lang/crates.io-index" 1177 | checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" 1178 | 1179 | [[package]] 1180 | name = "pin-project" 1181 | version = "1.0.12" 1182 | source = "registry+https://github.com/rust-lang/crates.io-index" 1183 | checksum = "ad29a609b6bcd67fee905812e544992d216af9d755757c05ed2d0e15a74c6ecc" 1184 | dependencies = [ 1185 | "pin-project-internal", 1186 | ] 1187 | 1188 | [[package]] 1189 | name = "pin-project-internal" 1190 | version = "1.0.12" 1191 | source = "registry+https://github.com/rust-lang/crates.io-index" 1192 | checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55" 1193 | dependencies = [ 1194 | "proc-macro2", 1195 | "quote", 1196 | "syn", 1197 | ] 1198 | 1199 | [[package]] 1200 | name = "piston" 1201 | version = "0.53.2" 1202 | source = "registry+https://github.com/rust-lang/crates.io-index" 1203 | checksum = "6e465487e1063ebe4103bc0fb65bc3dd604b635b2012a41530d3a5f77106e526" 1204 | dependencies = [ 1205 | "pistoncore-event_loop", 1206 | "pistoncore-input", 1207 | "pistoncore-window", 1208 | ] 1209 | 1210 | [[package]] 1211 | name = "piston-float" 1212 | version = "1.0.1" 1213 | source = "registry+https://github.com/rust-lang/crates.io-index" 1214 | checksum = "ad78bf43dcf80e8f950c92b84f938a0fc7590b7f6866fbcbeca781609c115590" 1215 | 1216 | [[package]] 1217 | name = "piston-gfx_texture" 1218 | version = "0.44.0" 1219 | source = "registry+https://github.com/rust-lang/crates.io-index" 1220 | checksum = "2101faab6046f8514e4697701afc9084fb5175f5cc3ee6469be3ac29fe6b84ac" 1221 | dependencies = [ 1222 | "gfx", 1223 | "gfx_core", 1224 | "image", 1225 | "piston-texture", 1226 | ] 1227 | 1228 | [[package]] 1229 | name = "piston-graphics_api_version" 1230 | version = "1.0.1" 1231 | source = "registry+https://github.com/rust-lang/crates.io-index" 1232 | checksum = "3b06401e3ea38467d8d85b394557408107e3e56d827f0d00c9b47e902cbd1bed" 1233 | 1234 | [[package]] 1235 | name = "piston-shaders_graphics2d" 1236 | version = "0.4.0" 1237 | source = "registry+https://github.com/rust-lang/crates.io-index" 1238 | checksum = "3a35f4d08d2b6fd7ff02baab63346d4b7d2fdd5ac3f2e091a5128c22c77a489a" 1239 | 1240 | [[package]] 1241 | name = "piston-texture" 1242 | version = "0.9.0" 1243 | source = "registry+https://github.com/rust-lang/crates.io-index" 1244 | checksum = "a5d84ca2ca1ea94fb003a85223f98c0705fe32abefa52dd58b57ed253dc908ce" 1245 | 1246 | [[package]] 1247 | name = "piston-viewport" 1248 | version = "1.0.2" 1249 | source = "registry+https://github.com/rust-lang/crates.io-index" 1250 | checksum = "61ecaf8ae0d71dd9cdbbd8662b47659621c09430ff3cb880d154858d3b8ac001" 1251 | dependencies = [ 1252 | "piston-float", 1253 | ] 1254 | 1255 | [[package]] 1256 | name = "piston2d-gfx_graphics" 1257 | version = "0.79.0" 1258 | source = "registry+https://github.com/rust-lang/crates.io-index" 1259 | checksum = "1beefd3079c590302eb6d8d4d1e416e25f078f6e6adf9f77be9c53a96e68c533" 1260 | dependencies = [ 1261 | "draw_state", 1262 | "gfx", 1263 | "piston-gfx_texture", 1264 | "piston-shaders_graphics2d", 1265 | "piston2d-graphics", 1266 | "shader_version", 1267 | ] 1268 | 1269 | [[package]] 1270 | name = "piston2d-graphics" 1271 | version = "0.43.0" 1272 | source = "registry+https://github.com/rust-lang/crates.io-index" 1273 | checksum = "861e264a9a5ffc4514b89922750b19c9a83886158d539d4a52cb3b9b2d0d1f98" 1274 | dependencies = [ 1275 | "fnv", 1276 | "interpolation", 1277 | "piston-texture", 1278 | "piston-viewport", 1279 | "read_color", 1280 | "rusttype", 1281 | "vecmath", 1282 | ] 1283 | 1284 | [[package]] 1285 | name = "piston2d-opengl_graphics" 1286 | version = "0.82.0" 1287 | source = "registry+https://github.com/rust-lang/crates.io-index" 1288 | checksum = "62a12185c5d4ecd7fe8b85e0daecf5e49812063559a626d74fd3c5d0aa8a52f2" 1289 | dependencies = [ 1290 | "fnv", 1291 | "gl", 1292 | "image", 1293 | "khronos_api 2.2.0", 1294 | "piston-shaders_graphics2d", 1295 | "piston-texture", 1296 | "piston-viewport", 1297 | "piston2d-graphics", 1298 | "shader_version", 1299 | ] 1300 | 1301 | [[package]] 1302 | name = "piston_window" 1303 | version = "0.127.0" 1304 | source = "registry+https://github.com/rust-lang/crates.io-index" 1305 | checksum = "d8b9b08d3838083edd3e5ff7ba58ec294048ff7a0fdfb6bd4df4b190721a1851" 1306 | dependencies = [ 1307 | "gfx", 1308 | "gfx_device_gl", 1309 | "piston", 1310 | "piston-texture", 1311 | "piston2d-gfx_graphics", 1312 | "piston2d-graphics", 1313 | "pistoncore-glutin_window", 1314 | "shader_version", 1315 | ] 1316 | 1317 | [[package]] 1318 | name = "pistoncore-event_loop" 1319 | version = "0.53.1" 1320 | source = "registry+https://github.com/rust-lang/crates.io-index" 1321 | checksum = "41d86b3bf012430bb23694348615e37769aca0e9910539ce93674006aeeb77e6" 1322 | dependencies = [ 1323 | "pistoncore-input", 1324 | "pistoncore-window", 1325 | "spin_sleep", 1326 | ] 1327 | 1328 | [[package]] 1329 | name = "pistoncore-glutin_window" 1330 | version = "0.70.1" 1331 | source = "registry+https://github.com/rust-lang/crates.io-index" 1332 | checksum = "a2625037feaa575206054a7a10b397739c6c10e81be0ae65858182d6dd906d30" 1333 | dependencies = [ 1334 | "gl", 1335 | "glutin", 1336 | "pistoncore-input", 1337 | "pistoncore-window", 1338 | "shader_version", 1339 | ] 1340 | 1341 | [[package]] 1342 | name = "pistoncore-input" 1343 | version = "1.0.1" 1344 | source = "registry+https://github.com/rust-lang/crates.io-index" 1345 | checksum = "2977fed6eb16c554fd445a09a50c8a0c250f4c50f752be46a7bd9dcc5ba471f0" 1346 | dependencies = [ 1347 | "bitflags", 1348 | "piston-viewport", 1349 | "serde", 1350 | "serde_derive", 1351 | ] 1352 | 1353 | [[package]] 1354 | name = "pistoncore-sdl2_window" 1355 | version = "0.68.0" 1356 | source = "registry+https://github.com/rust-lang/crates.io-index" 1357 | checksum = "b9a96c39ba1217b7f124bfc88126e3338333020250a91ed3ff1d01f7b944bd88" 1358 | dependencies = [ 1359 | "gl", 1360 | "pistoncore-input", 1361 | "pistoncore-window", 1362 | "sdl2", 1363 | "shader_version", 1364 | ] 1365 | 1366 | [[package]] 1367 | name = "pistoncore-window" 1368 | version = "0.47.1" 1369 | source = "registry+https://github.com/rust-lang/crates.io-index" 1370 | checksum = "d62962b4e9cfc13143c77e032302fedc58a8f0f570d30006cdb38ba00a5e50bf" 1371 | dependencies = [ 1372 | "piston-graphics_api_version", 1373 | "pistoncore-input", 1374 | ] 1375 | 1376 | [[package]] 1377 | name = "pkg-config" 1378 | version = "0.3.26" 1379 | source = "registry+https://github.com/rust-lang/crates.io-index" 1380 | checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" 1381 | 1382 | [[package]] 1383 | name = "png" 1384 | version = "0.17.7" 1385 | source = "registry+https://github.com/rust-lang/crates.io-index" 1386 | checksum = "5d708eaf860a19b19ce538740d2b4bdeeb8337fa53f7738455e706623ad5c638" 1387 | dependencies = [ 1388 | "bitflags", 1389 | "crc32fast", 1390 | "flate2", 1391 | "miniz_oxide", 1392 | ] 1393 | 1394 | [[package]] 1395 | name = "proc-macro-crate" 1396 | version = "0.1.5" 1397 | source = "registry+https://github.com/rust-lang/crates.io-index" 1398 | checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" 1399 | dependencies = [ 1400 | "toml", 1401 | ] 1402 | 1403 | [[package]] 1404 | name = "proc-macro2" 1405 | version = "1.0.52" 1406 | source = "registry+https://github.com/rust-lang/crates.io-index" 1407 | checksum = "1d0e1ae9e836cc3beddd63db0df682593d7e2d3d891ae8c9083d2113e1744224" 1408 | dependencies = [ 1409 | "unicode-ident", 1410 | ] 1411 | 1412 | [[package]] 1413 | name = "quote" 1414 | version = "1.0.26" 1415 | source = "registry+https://github.com/rust-lang/crates.io-index" 1416 | checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" 1417 | dependencies = [ 1418 | "proc-macro2", 1419 | ] 1420 | 1421 | [[package]] 1422 | name = "rand" 1423 | version = "0.3.23" 1424 | source = "registry+https://github.com/rust-lang/crates.io-index" 1425 | checksum = "64ac302d8f83c0c1974bf758f6b041c6c8ada916fbb44a609158ca8b064cc76c" 1426 | dependencies = [ 1427 | "libc", 1428 | "rand 0.4.6", 1429 | ] 1430 | 1431 | [[package]] 1432 | name = "rand" 1433 | version = "0.4.6" 1434 | source = "registry+https://github.com/rust-lang/crates.io-index" 1435 | checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" 1436 | dependencies = [ 1437 | "fuchsia-cprng", 1438 | "libc", 1439 | "rand_core 0.3.1", 1440 | "rdrand", 1441 | "winapi 0.3.9", 1442 | ] 1443 | 1444 | [[package]] 1445 | name = "rand_core" 1446 | version = "0.3.1" 1447 | source = "registry+https://github.com/rust-lang/crates.io-index" 1448 | checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" 1449 | dependencies = [ 1450 | "rand_core 0.4.2", 1451 | ] 1452 | 1453 | [[package]] 1454 | name = "rand_core" 1455 | version = "0.4.2" 1456 | source = "registry+https://github.com/rust-lang/crates.io-index" 1457 | checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" 1458 | 1459 | [[package]] 1460 | name = "raw-window-handle" 1461 | version = "0.3.4" 1462 | source = "registry+https://github.com/rust-lang/crates.io-index" 1463 | checksum = "e28f55143d0548dad60bb4fbdc835a3d7ac6acc3324506450c5fdd6e42903a76" 1464 | dependencies = [ 1465 | "libc", 1466 | "raw-window-handle 0.4.3", 1467 | ] 1468 | 1469 | [[package]] 1470 | name = "raw-window-handle" 1471 | version = "0.4.3" 1472 | source = "registry+https://github.com/rust-lang/crates.io-index" 1473 | checksum = "b800beb9b6e7d2df1fe337c9e3d04e3af22a124460fb4c30fcc22c9117cefb41" 1474 | dependencies = [ 1475 | "cty", 1476 | ] 1477 | 1478 | [[package]] 1479 | name = "rayon" 1480 | version = "1.7.0" 1481 | source = "registry+https://github.com/rust-lang/crates.io-index" 1482 | checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" 1483 | dependencies = [ 1484 | "either", 1485 | "rayon-core", 1486 | ] 1487 | 1488 | [[package]] 1489 | name = "rayon-core" 1490 | version = "1.11.0" 1491 | source = "registry+https://github.com/rust-lang/crates.io-index" 1492 | checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" 1493 | dependencies = [ 1494 | "crossbeam-channel", 1495 | "crossbeam-deque", 1496 | "crossbeam-utils", 1497 | "num_cpus", 1498 | ] 1499 | 1500 | [[package]] 1501 | name = "rdrand" 1502 | version = "0.4.0" 1503 | source = "registry+https://github.com/rust-lang/crates.io-index" 1504 | checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" 1505 | dependencies = [ 1506 | "rand_core 0.3.1", 1507 | ] 1508 | 1509 | [[package]] 1510 | name = "read_color" 1511 | version = "1.0.0" 1512 | source = "registry+https://github.com/rust-lang/crates.io-index" 1513 | checksum = "9f4c8858baa4ad3c8bcc156ae91a0ffe22b76a3975c40c49b4f04c15c6bce0da" 1514 | 1515 | [[package]] 1516 | name = "redox_syscall" 1517 | version = "0.2.16" 1518 | source = "registry+https://github.com/rust-lang/crates.io-index" 1519 | checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" 1520 | dependencies = [ 1521 | "bitflags", 1522 | ] 1523 | 1524 | [[package]] 1525 | name = "redox_users" 1526 | version = "0.4.3" 1527 | source = "registry+https://github.com/rust-lang/crates.io-index" 1528 | checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" 1529 | dependencies = [ 1530 | "getrandom", 1531 | "redox_syscall", 1532 | "thiserror", 1533 | ] 1534 | 1535 | [[package]] 1536 | name = "rust-2048" 1537 | version = "0.0.0" 1538 | dependencies = [ 1539 | "piston2d-opengl_graphics", 1540 | "piston_window", 1541 | "pistoncore-sdl2_window", 1542 | "rand 0.3.23", 1543 | "rustc-serialize", 1544 | ] 1545 | 1546 | [[package]] 1547 | name = "rustc-serialize" 1548 | version = "0.3.24" 1549 | source = "registry+https://github.com/rust-lang/crates.io-index" 1550 | checksum = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" 1551 | 1552 | [[package]] 1553 | name = "rusttype" 1554 | version = "0.9.3" 1555 | source = "registry+https://github.com/rust-lang/crates.io-index" 1556 | checksum = "3ff8374aa04134254b7995b63ad3dc41c7f7236f69528b28553da7d72efaa967" 1557 | dependencies = [ 1558 | "ab_glyph_rasterizer", 1559 | "owned_ttf_parser", 1560 | ] 1561 | 1562 | [[package]] 1563 | name = "same-file" 1564 | version = "1.0.6" 1565 | source = "registry+https://github.com/rust-lang/crates.io-index" 1566 | checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" 1567 | dependencies = [ 1568 | "winapi-util", 1569 | ] 1570 | 1571 | [[package]] 1572 | name = "scoped-tls" 1573 | version = "1.0.1" 1574 | source = "registry+https://github.com/rust-lang/crates.io-index" 1575 | checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" 1576 | 1577 | [[package]] 1578 | name = "scoped_threadpool" 1579 | version = "0.1.9" 1580 | source = "registry+https://github.com/rust-lang/crates.io-index" 1581 | checksum = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8" 1582 | 1583 | [[package]] 1584 | name = "scopeguard" 1585 | version = "1.1.0" 1586 | source = "registry+https://github.com/rust-lang/crates.io-index" 1587 | checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" 1588 | 1589 | [[package]] 1590 | name = "sdl2" 1591 | version = "0.35.2" 1592 | source = "registry+https://github.com/rust-lang/crates.io-index" 1593 | checksum = "f7959277b623f1fb9e04aea73686c3ca52f01b2145f8ea16f4ff30d8b7623b1a" 1594 | dependencies = [ 1595 | "bitflags", 1596 | "lazy_static", 1597 | "libc", 1598 | "sdl2-sys", 1599 | ] 1600 | 1601 | [[package]] 1602 | name = "sdl2-sys" 1603 | version = "0.35.2" 1604 | source = "registry+https://github.com/rust-lang/crates.io-index" 1605 | checksum = "e3586be2cf6c0a8099a79a12b4084357aa9b3e0b0d7980e3b67aaf7a9d55f9f0" 1606 | dependencies = [ 1607 | "cfg-if 1.0.0", 1608 | "libc", 1609 | "version-compare", 1610 | ] 1611 | 1612 | [[package]] 1613 | name = "serde" 1614 | version = "1.0.155" 1615 | source = "registry+https://github.com/rust-lang/crates.io-index" 1616 | checksum = "71f2b4817415c6d4210bfe1c7bfcf4801b2d904cb4d0e1a8fdb651013c9e86b8" 1617 | 1618 | [[package]] 1619 | name = "serde_derive" 1620 | version = "1.0.155" 1621 | source = "registry+https://github.com/rust-lang/crates.io-index" 1622 | checksum = "d071a94a3fac4aff69d023a7f411e33f40f3483f8c5190b1953822b6b76d7630" 1623 | dependencies = [ 1624 | "proc-macro2", 1625 | "quote", 1626 | "syn", 1627 | ] 1628 | 1629 | [[package]] 1630 | name = "shader_version" 1631 | version = "0.7.0" 1632 | source = "registry+https://github.com/rust-lang/crates.io-index" 1633 | checksum = "dfadbf7574784ee97f062ace17e1008fb5e7f46dd714b7dd46baf6efebd30e26" 1634 | dependencies = [ 1635 | "piston-graphics_api_version", 1636 | ] 1637 | 1638 | [[package]] 1639 | name = "shared_library" 1640 | version = "0.1.9" 1641 | source = "registry+https://github.com/rust-lang/crates.io-index" 1642 | checksum = "5a9e7e0f2bfae24d8a5b5a66c5b257a83c7412304311512a0c054cd5e619da11" 1643 | dependencies = [ 1644 | "lazy_static", 1645 | "libc", 1646 | ] 1647 | 1648 | [[package]] 1649 | name = "simd-adler32" 1650 | version = "0.3.5" 1651 | source = "registry+https://github.com/rust-lang/crates.io-index" 1652 | checksum = "238abfbb77c1915110ad968465608b68e869e0772622c9656714e73e5a1a522f" 1653 | 1654 | [[package]] 1655 | name = "slab" 1656 | version = "0.4.8" 1657 | source = "registry+https://github.com/rust-lang/crates.io-index" 1658 | checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" 1659 | dependencies = [ 1660 | "autocfg", 1661 | ] 1662 | 1663 | [[package]] 1664 | name = "smallvec" 1665 | version = "1.10.0" 1666 | source = "registry+https://github.com/rust-lang/crates.io-index" 1667 | checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" 1668 | 1669 | [[package]] 1670 | name = "smithay-client-toolkit" 1671 | version = "0.12.3" 1672 | source = "registry+https://github.com/rust-lang/crates.io-index" 1673 | checksum = "4750c76fd5d3ac95fa3ed80fe667d6a3d8590a960e5b575b98eea93339a80b80" 1674 | dependencies = [ 1675 | "andrew", 1676 | "bitflags", 1677 | "calloop", 1678 | "dlib 0.4.2", 1679 | "lazy_static", 1680 | "log", 1681 | "memmap2", 1682 | "nix 0.18.0", 1683 | "wayland-client", 1684 | "wayland-cursor", 1685 | "wayland-protocols", 1686 | ] 1687 | 1688 | [[package]] 1689 | name = "spin" 1690 | version = "0.9.6" 1691 | source = "registry+https://github.com/rust-lang/crates.io-index" 1692 | checksum = "b5d6e0250b93c8427a177b849d144a96d5acc57006149479403d7861ab721e34" 1693 | dependencies = [ 1694 | "lock_api", 1695 | ] 1696 | 1697 | [[package]] 1698 | name = "spin_sleep" 1699 | version = "1.1.1" 1700 | source = "registry+https://github.com/rust-lang/crates.io-index" 1701 | checksum = "cafa7900db085f4354dbc7025e25d7a839a14360ea13b5fc4fd717f2d3b23134" 1702 | dependencies = [ 1703 | "once_cell", 1704 | "winapi 0.3.9", 1705 | ] 1706 | 1707 | [[package]] 1708 | name = "strsim" 1709 | version = "0.9.3" 1710 | source = "registry+https://github.com/rust-lang/crates.io-index" 1711 | checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" 1712 | 1713 | [[package]] 1714 | name = "syn" 1715 | version = "1.0.109" 1716 | source = "registry+https://github.com/rust-lang/crates.io-index" 1717 | checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" 1718 | dependencies = [ 1719 | "proc-macro2", 1720 | "quote", 1721 | "unicode-ident", 1722 | ] 1723 | 1724 | [[package]] 1725 | name = "thiserror" 1726 | version = "1.0.39" 1727 | source = "registry+https://github.com/rust-lang/crates.io-index" 1728 | checksum = "a5ab016db510546d856297882807df8da66a16fb8c4101cb8b30054b0d5b2d9c" 1729 | dependencies = [ 1730 | "thiserror-impl", 1731 | ] 1732 | 1733 | [[package]] 1734 | name = "thiserror-impl" 1735 | version = "1.0.39" 1736 | source = "registry+https://github.com/rust-lang/crates.io-index" 1737 | checksum = "5420d42e90af0c38c3290abcca25b9b3bdf379fc9f55c528f53a269d9c9a267e" 1738 | dependencies = [ 1739 | "proc-macro2", 1740 | "quote", 1741 | "syn", 1742 | ] 1743 | 1744 | [[package]] 1745 | name = "tiff" 1746 | version = "0.8.1" 1747 | source = "registry+https://github.com/rust-lang/crates.io-index" 1748 | checksum = "7449334f9ff2baf290d55d73983a7d6fa15e01198faef72af07e2a8db851e471" 1749 | dependencies = [ 1750 | "flate2", 1751 | "jpeg-decoder", 1752 | "weezl", 1753 | ] 1754 | 1755 | [[package]] 1756 | name = "toml" 1757 | version = "0.5.11" 1758 | source = "registry+https://github.com/rust-lang/crates.io-index" 1759 | checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" 1760 | dependencies = [ 1761 | "serde", 1762 | ] 1763 | 1764 | [[package]] 1765 | name = "ttf-parser" 1766 | version = "0.15.2" 1767 | source = "registry+https://github.com/rust-lang/crates.io-index" 1768 | checksum = "7b3e06c9b9d80ed6b745c7159c40b311ad2916abb34a49e9be2653b90db0d8dd" 1769 | 1770 | [[package]] 1771 | name = "unicode-ident" 1772 | version = "1.0.8" 1773 | source = "registry+https://github.com/rust-lang/crates.io-index" 1774 | checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" 1775 | 1776 | [[package]] 1777 | name = "vecmath" 1778 | version = "1.0.0" 1779 | source = "registry+https://github.com/rust-lang/crates.io-index" 1780 | checksum = "956ae1e0d85bca567dee1dcf87fb1ca2e792792f66f87dced8381f99cd91156a" 1781 | dependencies = [ 1782 | "piston-float", 1783 | ] 1784 | 1785 | [[package]] 1786 | name = "version-compare" 1787 | version = "0.1.1" 1788 | source = "registry+https://github.com/rust-lang/crates.io-index" 1789 | checksum = "579a42fc0b8e0c63b76519a339be31bed574929511fa53c1a3acae26eb258f29" 1790 | 1791 | [[package]] 1792 | name = "walkdir" 1793 | version = "2.3.2" 1794 | source = "registry+https://github.com/rust-lang/crates.io-index" 1795 | checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" 1796 | dependencies = [ 1797 | "same-file", 1798 | "winapi 0.3.9", 1799 | "winapi-util", 1800 | ] 1801 | 1802 | [[package]] 1803 | name = "wasi" 1804 | version = "0.11.0+wasi-snapshot-preview1" 1805 | source = "registry+https://github.com/rust-lang/crates.io-index" 1806 | checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" 1807 | 1808 | [[package]] 1809 | name = "wasm-bindgen" 1810 | version = "0.2.84" 1811 | source = "registry+https://github.com/rust-lang/crates.io-index" 1812 | checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" 1813 | dependencies = [ 1814 | "cfg-if 1.0.0", 1815 | "wasm-bindgen-macro", 1816 | ] 1817 | 1818 | [[package]] 1819 | name = "wasm-bindgen-backend" 1820 | version = "0.2.84" 1821 | source = "registry+https://github.com/rust-lang/crates.io-index" 1822 | checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" 1823 | dependencies = [ 1824 | "bumpalo", 1825 | "log", 1826 | "once_cell", 1827 | "proc-macro2", 1828 | "quote", 1829 | "syn", 1830 | "wasm-bindgen-shared", 1831 | ] 1832 | 1833 | [[package]] 1834 | name = "wasm-bindgen-macro" 1835 | version = "0.2.84" 1836 | source = "registry+https://github.com/rust-lang/crates.io-index" 1837 | checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" 1838 | dependencies = [ 1839 | "quote", 1840 | "wasm-bindgen-macro-support", 1841 | ] 1842 | 1843 | [[package]] 1844 | name = "wasm-bindgen-macro-support" 1845 | version = "0.2.84" 1846 | source = "registry+https://github.com/rust-lang/crates.io-index" 1847 | checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" 1848 | dependencies = [ 1849 | "proc-macro2", 1850 | "quote", 1851 | "syn", 1852 | "wasm-bindgen-backend", 1853 | "wasm-bindgen-shared", 1854 | ] 1855 | 1856 | [[package]] 1857 | name = "wasm-bindgen-shared" 1858 | version = "0.2.84" 1859 | source = "registry+https://github.com/rust-lang/crates.io-index" 1860 | checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" 1861 | 1862 | [[package]] 1863 | name = "wayland-client" 1864 | version = "0.28.6" 1865 | source = "registry+https://github.com/rust-lang/crates.io-index" 1866 | checksum = "e3ab332350e502f159382201394a78e3cc12d0f04db863429260164ea40e0355" 1867 | dependencies = [ 1868 | "bitflags", 1869 | "downcast-rs", 1870 | "libc", 1871 | "nix 0.20.0", 1872 | "scoped-tls", 1873 | "wayland-commons", 1874 | "wayland-scanner", 1875 | "wayland-sys", 1876 | ] 1877 | 1878 | [[package]] 1879 | name = "wayland-commons" 1880 | version = "0.28.6" 1881 | source = "registry+https://github.com/rust-lang/crates.io-index" 1882 | checksum = "a21817947c7011bbd0a27e11b17b337bfd022e8544b071a2641232047966fbda" 1883 | dependencies = [ 1884 | "nix 0.20.0", 1885 | "once_cell", 1886 | "smallvec", 1887 | "wayland-sys", 1888 | ] 1889 | 1890 | [[package]] 1891 | name = "wayland-cursor" 1892 | version = "0.28.6" 1893 | source = "registry+https://github.com/rust-lang/crates.io-index" 1894 | checksum = "be610084edd1586d45e7bdd275fe345c7c1873598caa464c4fb835dee70fa65a" 1895 | dependencies = [ 1896 | "nix 0.20.0", 1897 | "wayland-client", 1898 | "xcursor", 1899 | ] 1900 | 1901 | [[package]] 1902 | name = "wayland-egl" 1903 | version = "0.28.6" 1904 | source = "registry+https://github.com/rust-lang/crates.io-index" 1905 | checksum = "99ba1ab1e18756b23982d36f08856d521d7df45015f404a2d7c4f0b2d2f66956" 1906 | dependencies = [ 1907 | "wayland-client", 1908 | "wayland-sys", 1909 | ] 1910 | 1911 | [[package]] 1912 | name = "wayland-protocols" 1913 | version = "0.28.6" 1914 | source = "registry+https://github.com/rust-lang/crates.io-index" 1915 | checksum = "286620ea4d803bacf61fa087a4242ee316693099ee5a140796aaba02b29f861f" 1916 | dependencies = [ 1917 | "bitflags", 1918 | "wayland-client", 1919 | "wayland-commons", 1920 | "wayland-scanner", 1921 | ] 1922 | 1923 | [[package]] 1924 | name = "wayland-scanner" 1925 | version = "0.28.6" 1926 | source = "registry+https://github.com/rust-lang/crates.io-index" 1927 | checksum = "ce923eb2deb61de332d1f356ec7b6bf37094dc5573952e1c8936db03b54c03f1" 1928 | dependencies = [ 1929 | "proc-macro2", 1930 | "quote", 1931 | "xml-rs", 1932 | ] 1933 | 1934 | [[package]] 1935 | name = "wayland-sys" 1936 | version = "0.28.6" 1937 | source = "registry+https://github.com/rust-lang/crates.io-index" 1938 | checksum = "d841fca9aed7febf9bed2e9796c49bf58d4152ceda8ac949ebe00868d8f0feb8" 1939 | dependencies = [ 1940 | "dlib 0.5.0", 1941 | "lazy_static", 1942 | "pkg-config", 1943 | ] 1944 | 1945 | [[package]] 1946 | name = "weezl" 1947 | version = "0.1.7" 1948 | source = "registry+https://github.com/rust-lang/crates.io-index" 1949 | checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb" 1950 | 1951 | [[package]] 1952 | name = "winapi" 1953 | version = "0.2.8" 1954 | source = "registry+https://github.com/rust-lang/crates.io-index" 1955 | checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" 1956 | 1957 | [[package]] 1958 | name = "winapi" 1959 | version = "0.3.9" 1960 | source = "registry+https://github.com/rust-lang/crates.io-index" 1961 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 1962 | dependencies = [ 1963 | "winapi-i686-pc-windows-gnu", 1964 | "winapi-x86_64-pc-windows-gnu", 1965 | ] 1966 | 1967 | [[package]] 1968 | name = "winapi-build" 1969 | version = "0.1.1" 1970 | source = "registry+https://github.com/rust-lang/crates.io-index" 1971 | checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" 1972 | 1973 | [[package]] 1974 | name = "winapi-i686-pc-windows-gnu" 1975 | version = "0.4.0" 1976 | source = "registry+https://github.com/rust-lang/crates.io-index" 1977 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 1978 | 1979 | [[package]] 1980 | name = "winapi-util" 1981 | version = "0.1.5" 1982 | source = "registry+https://github.com/rust-lang/crates.io-index" 1983 | checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" 1984 | dependencies = [ 1985 | "winapi 0.3.9", 1986 | ] 1987 | 1988 | [[package]] 1989 | name = "winapi-x86_64-pc-windows-gnu" 1990 | version = "0.4.0" 1991 | source = "registry+https://github.com/rust-lang/crates.io-index" 1992 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 1993 | 1994 | [[package]] 1995 | name = "winit" 1996 | version = "0.24.0" 1997 | source = "registry+https://github.com/rust-lang/crates.io-index" 1998 | checksum = "da4eda6fce0eb84bd0a33e3c8794eb902e1033d0a1d5a31bc4f19b1b4bbff597" 1999 | dependencies = [ 2000 | "bitflags", 2001 | "cocoa 0.24.1", 2002 | "core-foundation 0.9.3", 2003 | "core-graphics 0.22.3", 2004 | "core-video-sys", 2005 | "dispatch", 2006 | "instant", 2007 | "lazy_static", 2008 | "libc", 2009 | "log", 2010 | "mio", 2011 | "mio-extras", 2012 | "ndk", 2013 | "ndk-glue", 2014 | "ndk-sys", 2015 | "objc", 2016 | "parking_lot", 2017 | "percent-encoding", 2018 | "raw-window-handle 0.3.4", 2019 | "smithay-client-toolkit", 2020 | "wayland-client", 2021 | "winapi 0.3.9", 2022 | "x11-dl", 2023 | ] 2024 | 2025 | [[package]] 2026 | name = "ws2_32-sys" 2027 | version = "0.2.1" 2028 | source = "registry+https://github.com/rust-lang/crates.io-index" 2029 | checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" 2030 | dependencies = [ 2031 | "winapi 0.2.8", 2032 | "winapi-build", 2033 | ] 2034 | 2035 | [[package]] 2036 | name = "x11-dl" 2037 | version = "2.21.0" 2038 | source = "registry+https://github.com/rust-lang/crates.io-index" 2039 | checksum = "38735924fedd5314a6e548792904ed8c6de6636285cb9fec04d5b1db85c1516f" 2040 | dependencies = [ 2041 | "libc", 2042 | "once_cell", 2043 | "pkg-config", 2044 | ] 2045 | 2046 | [[package]] 2047 | name = "xcursor" 2048 | version = "0.3.4" 2049 | source = "registry+https://github.com/rust-lang/crates.io-index" 2050 | checksum = "463705a63313cd4301184381c5e8042f0a7e9b4bb63653f216311d4ae74690b7" 2051 | dependencies = [ 2052 | "nom", 2053 | ] 2054 | 2055 | [[package]] 2056 | name = "xdg" 2057 | version = "2.4.1" 2058 | source = "registry+https://github.com/rust-lang/crates.io-index" 2059 | checksum = "0c4583db5cbd4c4c0303df2d15af80f0539db703fa1c68802d4cbbd2dd0f88f6" 2060 | dependencies = [ 2061 | "dirs", 2062 | ] 2063 | 2064 | [[package]] 2065 | name = "xml-rs" 2066 | version = "0.8.4" 2067 | source = "registry+https://github.com/rust-lang/crates.io-index" 2068 | checksum = "d2d7d3948613f75c98fd9328cfdcc45acc4d360655289d0a7d4ec931392200a3" 2069 | 2070 | [[package]] 2071 | name = "zune-inflate" 2072 | version = "0.2.51" 2073 | source = "registry+https://github.com/rust-lang/crates.io-index" 2074 | checksum = "a01728b79fb9b7e28a8c11f715e1cd8dc2cda7416a007d66cac55cebb3a8ac6b" 2075 | dependencies = [ 2076 | "simd-adler32", 2077 | ] 2078 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | 3 | name = "rust-2048" 4 | version = "0.0.0" 5 | authors = ["coeuvre "] 6 | 7 | [[bin]] 8 | 9 | name = "rust-2048" 10 | path = "src/main.rs" 11 | 12 | [dependencies] 13 | rustc-serialize = "0.3" 14 | rand = "0.3.7" 15 | piston_window = "0.127.0" 16 | pistoncore-sdl2_window = "0.68.0" 17 | piston2d-opengl_graphics = "0.82.0" 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Coeuvre Wong 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | rust-2048 2 | ========= 3 | 4 | A 2048 clone with Piston game engine. 5 | 6 | How to play 7 | ----------- 8 | Use arrow key to move tiles. 9 | 10 | ![alt tag](./rust-2048.png) 11 | 12 | ## Building Instructions 13 | 14 | To build this repository, you need [Cargo](https://github.com/rust-lang/cargo). 15 | 16 | You also need the _Freetype 6_ and _SDL2_ libs. 17 | Look at [Piston-Tutorials - Installing Dependencies](https://github.com/PistonDevelopers/Piston-Tutorials/tree/master/getting-started#installing-dependencies) and [Rust-SDL2 - Requirements](https://github.com/AngryLawyer/rust-sdl2#sdl20--development-libraries) how to install them. 18 | 19 | 20 | Clone this repository 21 | ``` 22 | git clone https://github.com/Coeuvre/rust-2048.git 23 | ``` 24 | 25 | Use Cargo to build 26 | ``` 27 | cargo build 28 | ``` 29 | 30 | Play! 31 | ``` 32 | cargo run 33 | ``` 34 | -------------------------------------------------------------------------------- /bin/assets/comment1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coeuvre/rust-2048/ebf96d9b89c9c1e11383f87d35408c22d0839b8c/bin/assets/comment1.png -------------------------------------------------------------------------------- /bin/assets/comment2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coeuvre/rust-2048/ebf96d9b89c9c1e11383f87d35408c22d0839b8c/bin/assets/comment2.png -------------------------------------------------------------------------------- /bin/assets/digits.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coeuvre/rust-2048/ebf96d9b89c9c1e11383f87d35408c22d0839b8c/bin/assets/digits.png -------------------------------------------------------------------------------- /bin/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coeuvre/rust-2048/ebf96d9b89c9c1e11383f87d35408c22d0839b8c/bin/assets/logo.png -------------------------------------------------------------------------------- /rust-2048.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coeuvre/rust-2048/ebf96d9b89c9c1e11383f87d35408c22d0839b8c/rust-2048.png -------------------------------------------------------------------------------- /src/app.rs: -------------------------------------------------------------------------------- 1 | use std::path::{ Path, PathBuf }; 2 | 3 | use piston_window::*; 4 | use opengl_graphics::GlGraphics; 5 | use opengl_graphics::Texture as GlTexture; 6 | use board::Board; 7 | use number_renderer::NumberRenderer; 8 | use settings::Settings; 9 | 10 | pub struct App<'a> { 11 | board: Board<'a>, 12 | number_renderer: Option, 13 | settings: &'a Settings, 14 | 15 | logo: Option, 16 | comment1: Option, 17 | comment2: Option, 18 | window_background_color: [f32; 4], 19 | } 20 | 21 | fn rgb2rgba(c: [f32; 3]) -> [f32; 4] { [c[0], c[1], c[2], 1.0] } 22 | 23 | impl<'a> App<'a> { 24 | pub fn new(settings: &'a Settings) -> App<'a> { 25 | App { 26 | board: Board::new(settings), 27 | number_renderer: None, 28 | settings: settings, 29 | 30 | logo: None, 31 | comment1: None, 32 | comment2: None, 33 | window_background_color: [1.0, 1.0, 1.0, 1.0], 34 | } 35 | } 36 | 37 | fn render_ui(&self, c: &Context, gl: &mut GlGraphics) { 38 | Image::new_color(rgb2rgba(self.settings.text_dark_color)) 39 | .draw(self.logo.iter().next().unwrap(), 40 | &DrawState::default(), 41 | c.trans(self.settings.board_padding,self.settings.board_padding).transform, 42 | gl); 43 | 44 | Rectangle::new(rgb2rgba(self.settings.label_color)) 45 | .draw(self.settings.best_rect, 46 | &DrawState::default(), 47 | c.transform, 48 | gl); 49 | 50 | let comment1_offset_y = self.settings.comment1_offset_y; 51 | let comment1 = self.comment1.as_ref().unwrap(); 52 | App::render_comment(self.settings, comment1, comment1_offset_y, c, gl); 53 | let comment2_offset_y = self.settings.comment2_offset_y; 54 | let comment2 = self.comment2.as_ref().unwrap(); 55 | App::render_comment(self.settings, comment2, comment2_offset_y, c, gl); 56 | } 57 | 58 | fn render_comment(settings: &Settings, comment: &GlTexture, y: f64, c: &Context, gl: &mut GlGraphics) { 59 | let (width, height) = comment.get_size(); 60 | let w = settings.window_size[0] as f64 - 2.0 * settings.board_padding; 61 | let h = height as f64 * w / width as f64; 62 | 63 | Image::new_color(rgb2rgba(settings.text_dark_color)) 64 | .rect([settings.board_padding, y, w, h]) 65 | .draw( comment, 66 | &DrawState::default(), 67 | c.transform, 68 | gl); 69 | } 70 | 71 | pub fn load(&mut self) { 72 | let mut asset_root = PathBuf::new(); 73 | asset_root.push(Path::new(&self.settings.asset_folder)); 74 | 75 | let mut logo_path = asset_root.clone(); 76 | logo_path.push(Path::new("logo.png")); 77 | let mut comment1_path = asset_root.clone(); 78 | comment1_path.push(Path::new("comment1.png")); 79 | let mut comment2_path = asset_root.clone(); 80 | comment2_path.push(Path::new("comment2.png")); 81 | 82 | self.number_renderer = Some(NumberRenderer::new()); 83 | let texture_settings = TextureSettings::new(); 84 | self.logo = Some(GlTexture::from_path(&logo_path, &texture_settings).unwrap()); 85 | self.comment1 = Some(GlTexture::from_path(&comment1_path, &texture_settings).unwrap()); 86 | self.comment2 = Some(GlTexture::from_path(&comment2_path, &texture_settings).unwrap()); 87 | } 88 | 89 | pub fn render(&mut self, args: &RenderArgs, gl: &mut GlGraphics) { 90 | let area = args.window_size; 91 | let ref c = Context::new_abs(area[0], area[1]); 92 | 93 | let w_bg_col = self.window_background_color; 94 | let ref nr = self.number_renderer; 95 | 96 | gl.draw(args.viewport(), |_, gl| { 97 | clear(w_bg_col, gl); 98 | self.render_ui(c, gl); 99 | self.board.render(nr.iter().next().unwrap(), c, gl); 100 | }); 101 | 102 | } 103 | 104 | pub fn update(&mut self, args: &UpdateArgs) { 105 | self.board.update(args.dt); 106 | } 107 | 108 | pub fn key_press(&mut self, args: &Button) { 109 | use piston_window::Button::Keyboard; 110 | 111 | if *args == Keyboard(Key::Left) { 112 | self.board.merge_from_right_to_left(); 113 | } 114 | 115 | if *args == Keyboard(Key::Right) { 116 | self.board.merge_from_left_to_right(); 117 | } 118 | 119 | if *args == Keyboard(Key::Up) { 120 | self.board.merge_from_bottom_to_top(); 121 | } 122 | 123 | if *args == Keyboard(Key::Down) { 124 | self.board.merge_from_top_to_bottom(); 125 | } 126 | 127 | if *args == Keyboard(Key::Space) { 128 | self.board = Board::new(self.settings); 129 | } 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /src/board.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashSet; 2 | use rand::random; 3 | use piston_window::*; 4 | use opengl_graphics::GlGraphics; 5 | use number_renderer::NumberRenderer; 6 | use settings::Settings; 7 | use tile::{ Tile, TileState }; 8 | 9 | fn rgb2rgba(c: [f32; 3]) -> [f32; 4] { [c[0], c[1], c[2], 1.0] } 10 | 11 | pub struct Board<'a> { 12 | tiles: Vec>, 13 | score: i32, 14 | settings: &'a Settings, 15 | } 16 | 17 | impl<'a> Board<'a> { 18 | pub fn new(settings: &'a Settings) -> Board<'a> { 19 | let mut board = Board { 20 | tiles: Vec::::new(), 21 | score: 0, 22 | settings: settings, 23 | }; 24 | board.generate_tile(); 25 | board.generate_tile(); 26 | board 27 | } 28 | 29 | pub fn generate_tile(&mut self) { 30 | if self.tiles.len() == (self.settings.tile_width * self.settings.tile_height) as usize { 31 | return; 32 | } 33 | 34 | loop { 35 | let x = (random::() % self.settings.tile_width as u32) as i32; 36 | let y = (random::() % self.settings.tile_height as u32) as i32; 37 | 38 | if self.get_tile(x, y).is_none() { 39 | let score = if random::() % 10 == 0 { 40 | 4 41 | } else { 42 | 2 43 | }; 44 | self.tiles.push(Tile::new(self.settings, score, x, y)); 45 | break; 46 | } 47 | } 48 | } 49 | 50 | pub fn update(&mut self, dt: f64) { 51 | for tile in self.tiles.iter_mut() { 52 | tile.update(dt); 53 | } 54 | 55 | if self.is_locking() { 56 | return; 57 | } 58 | 59 | let mut score_to_added = 0; 60 | let mut tiles_need_removed = HashSet::::new(); 61 | let mut tiles_need_added = Vec::::new(); 62 | 63 | for i in 0..self.tiles.len() { 64 | let tile1 = &self.tiles[i]; 65 | 66 | if tile1.status != TileState::TileStatic { 67 | continue; 68 | } 69 | 70 | for j in i+1..self.tiles.len() { 71 | let tile2 = &self.tiles[j]; 72 | 73 | if tile2.status != TileState::TileStatic 74 | || tile1.tile_x != tile2.tile_x 75 | || tile1.tile_y != tile2.tile_y { 76 | continue; 77 | } 78 | 79 | tiles_need_removed.insert(i); 80 | tiles_need_removed.insert(j); 81 | tiles_need_added.push(Tile::new_combined(self.settings, tile1.score + tile2.score, tile1.tile_x, tile1.tile_y)); 82 | score_to_added += tile1.score + tile2.score; 83 | break; 84 | } 85 | } 86 | 87 | if tiles_need_removed.len() > 0 { 88 | let mut tiles = Vec::::new(); 89 | 90 | for i in 0..self.tiles.len() { 91 | if !tiles_need_removed.contains(&i) { 92 | tiles.push(self.tiles[i].clone()); 93 | } 94 | } 95 | 96 | // better but unstable: tiles.append(&mut tiles_need_added); 97 | while let Some(tile_to_add) = tiles_need_added.pop() { 98 | tiles.push(tile_to_add); 99 | } 100 | 101 | self.tiles = tiles; 102 | self.add_score(score_to_added); 103 | } 104 | } 105 | 106 | pub fn render(&self, number_renderer: &NumberRenderer, c: &Context, gl: &mut GlGraphics) { 107 | number_renderer.render( 108 | self.score as u32, 109 | self.settings.best_rect[0] + self.settings.best_rect[2] / 2.0, 110 | self.settings.best_rect[1] + self.settings.best_rect[3] / 2.0, 111 | self.settings.best_rect[2], 112 | self.settings.text_light_color, c, gl); 113 | 114 | self.render_board(c, gl); 115 | self.render_tiles(number_renderer, c, gl); 116 | } 117 | 118 | pub fn merge_from_bottom_to_top(&mut self) { 119 | let height = self.settings.tile_height; 120 | self.merge_col(0, height, 1); 121 | } 122 | 123 | pub fn merge_from_top_to_bottom(&mut self) { 124 | let height = self.settings.tile_height; 125 | self.merge_col(height - 1, -1, -1); 126 | } 127 | 128 | fn merge_col(&mut self, y_start: i32, y_end: i32, y_step: i32) { 129 | if self.is_locking() { 130 | println!("return"); 131 | return; 132 | } 133 | 134 | let mut need_generate = false; 135 | let mut steps: Vec = Vec::with_capacity(self.settings.tile_height as usize); 136 | 137 | let mut next_step = y_start; 138 | 139 | if y_step < 0 { 140 | while next_step > y_end { 141 | steps.push(next_step); next_step += y_step 142 | } 143 | } else { 144 | while next_step < y_end { 145 | steps.push(next_step); next_step += y_step 146 | } 147 | } 148 | 149 | loop { 150 | // move all tiles to right place 151 | for col in 0 .. self.settings.tile_width { 152 | // TODO: replace steps by (y_start .. y_end).step_by(y_step) if step_by becomes stable 153 | for row in steps.to_vec() { 154 | match self.get_mut_tile(col, row) { 155 | None => { 156 | match self.get_mut_next_tile(col, row, 0, y_step) { 157 | Some(ref mut tile) => { 158 | println!("move ({}, {}) to ({}, {})", 159 | tile.tile_x, tile.tile_y, col, row); 160 | need_generate = true; 161 | tile.start_moving(col, row); 162 | }, 163 | _ => {}, 164 | } 165 | }, 166 | _ => {}, 167 | } 168 | } 169 | } 170 | 171 | let mut did_merged = false; 172 | for col in 0..self.settings.tile_width { 173 | let mut found = false; 174 | let mut sx = 0; 175 | let mut sy = 0; 176 | let mut dx = 0; 177 | let mut dy = 0; 178 | for row in steps.to_vec() { 179 | match self.get_tile(col, row) { 180 | Some(ref d_tile) => { 181 | match self.get_next_tile(col, row, 0, y_step) { 182 | Some(ref s_tile) 183 | if d_tile.score == s_tile.score 184 | && self.get_tile_count(d_tile.tile_x, d_tile.tile_y) == 1 => { 185 | found = true; 186 | dx = d_tile.tile_x; 187 | dy = d_tile.tile_y; 188 | sx = s_tile.tile_x; 189 | sy = s_tile.tile_y; 190 | break; 191 | }, 192 | _ => {}, 193 | } 194 | }, 195 | None => { 196 | break; 197 | } 198 | } 199 | } 200 | 201 | if found { 202 | need_generate = true; 203 | did_merged = true; 204 | let tile = self.get_mut_tile(sx, sy).unwrap(); 205 | tile.start_moving(dx, dy); 206 | println!("merge ({}, {}) to ({}, {})", sx, sy, dx, dy); 207 | } 208 | } 209 | 210 | if !did_merged { 211 | break; 212 | } 213 | } 214 | 215 | if need_generate { 216 | self.generate_tile(); 217 | } 218 | } 219 | 220 | pub fn merge_from_left_to_right(&mut self) { 221 | let width = self.settings.tile_width; 222 | self.merge_row(width - 1, -1, -1); 223 | } 224 | 225 | pub fn merge_from_right_to_left(&mut self) { 226 | let width = self.settings.tile_width; 227 | self.merge_row(0, width, 1); 228 | } 229 | 230 | fn merge_row(&mut self, x_start: i32, x_end: i32, x_step: i32) { 231 | if self.is_locking() { 232 | return; 233 | } 234 | 235 | let mut need_generate = false; 236 | let mut steps: Vec = Vec::with_capacity(self.settings.tile_width as usize); 237 | let mut next_step = x_start; 238 | 239 | if x_step < 0 { 240 | while next_step > x_end { 241 | steps.push(next_step); next_step += x_step 242 | } 243 | } else { 244 | while next_step < x_end { 245 | steps.push(next_step); next_step += x_step 246 | } 247 | } 248 | 249 | loop { 250 | // move all tiles to right place 251 | for row in 0..self.settings.tile_height { 252 | for col in steps.to_vec() { 253 | match self.get_mut_tile(col, row) { 254 | None => { 255 | match self.get_mut_next_tile(col, row, x_step, 0) { 256 | Some(ref mut tile) => { 257 | println!("move ({}, {}) to ({}, {})", tile.tile_x, tile.tile_y, col, row); 258 | need_generate = true; 259 | tile.start_moving(col, row); 260 | }, 261 | _ => {}, 262 | } 263 | }, 264 | _ => {}, 265 | } 266 | } 267 | } 268 | 269 | // merge 270 | let mut did_merged = false; 271 | for row in 0..self.settings.tile_height { 272 | let mut found = false; 273 | let mut sx = 0; 274 | let mut sy = 0; 275 | let mut dx = 0; 276 | let mut dy = 0; 277 | for col in steps.to_vec() { 278 | match self.get_tile(col, row) { 279 | Some(ref d_tile) => { 280 | match self.get_next_tile(col, row, x_step, 0) { 281 | Some(ref s_tile) 282 | if d_tile.score == s_tile.score 283 | && self.get_tile_count(d_tile.tile_x, d_tile.tile_y) == 1 => { 284 | found = true; 285 | dx = d_tile.tile_x; 286 | dy = d_tile.tile_y; 287 | sx = s_tile.tile_x; 288 | sy = s_tile.tile_y; 289 | break; 290 | }, 291 | _ => {}, 292 | } 293 | }, 294 | None => { 295 | break; 296 | } 297 | } 298 | } 299 | 300 | if found { 301 | need_generate = true; 302 | did_merged = true; 303 | let tile = self.get_mut_tile(sx, sy).unwrap(); 304 | tile.start_moving(dx, dy); 305 | println!("merge ({}, {}) to ({}, {})", sx, sy, dx, dy); 306 | } 307 | } 308 | 309 | if !did_merged { 310 | break; 311 | } 312 | } 313 | 314 | if need_generate { 315 | self.generate_tile(); 316 | } 317 | } 318 | 319 | fn is_locking(&self) -> bool { 320 | for tile in self.tiles.iter() { 321 | if tile.status != TileState::TileStatic { 322 | return true; 323 | } 324 | } 325 | false 326 | } 327 | 328 | /// Returns next tile right besides (x, y) 329 | fn get_next_tile<'b>(&'b self, x: i32, y: i32, step_x: i32, step_y: i32) -> Option<&'b Tile<'a>> { 330 | let mut x = x + step_x; 331 | let mut y = y + step_y; 332 | while x >= 0 && x < self.settings.tile_width 333 | && y >= 0 && y < self.settings.tile_height { 334 | let tile = self.get_tile(x, y); 335 | if tile.is_some() { 336 | return tile; 337 | } 338 | x += step_x; 339 | y += step_y; 340 | } 341 | None 342 | } 343 | 344 | fn get_mut_next_tile<'b>(&'b mut self, x: i32, y: i32, step_x: i32, step_y: i32) -> Option<&'b mut Tile<'a>> { 345 | let mut x = x + step_x; 346 | let mut y = y + step_y; 347 | let mut found = false; 348 | while x >= 0 && x < self.settings.tile_width 349 | && y >= 0 && y < self.settings.tile_height { 350 | let tile = self.get_tile(x, y); 351 | 352 | if tile.is_some() { 353 | found = true; 354 | break; 355 | } 356 | x += step_x; 357 | y += step_y; 358 | } 359 | 360 | if found { 361 | self.get_mut_tile(x, y) 362 | } else { 363 | None 364 | } 365 | } 366 | 367 | fn get_tile<'b>(&'b self, x: i32, y: i32) -> Option<&'b Tile<'a>> { 368 | for tile in self.tiles.iter() { 369 | if tile.tile_x == x && tile.tile_y == y { 370 | return Some(tile); 371 | } 372 | } 373 | 374 | None 375 | } 376 | 377 | fn get_mut_tile<'b>(&'b mut self, x: i32, y: i32) -> Option<&'b mut Tile<'a>> { 378 | for tile in self.tiles.iter_mut() { 379 | if tile.tile_x == x && tile.tile_y == y { 380 | return Some(tile); 381 | } 382 | } 383 | 384 | None 385 | } 386 | 387 | fn get_tile_count(&self, x: i32, y: i32) -> i32 { 388 | let mut count = 0; 389 | for tile in self.tiles.iter() { 390 | if tile.tile_x == x && tile.tile_y == y { 391 | count += 1; 392 | } 393 | } 394 | 395 | count 396 | } 397 | 398 | fn render_board(&self, c: &Context, gl: &mut GlGraphics) { 399 | Rectangle::new(rgb2rgba(self.settings.label_color)) 400 | .draw( 401 | [self.settings.board_padding, 402 | self.settings.board_padding + self.settings.board_offset_y, 403 | self.settings.board_size[0], 404 | self.settings.board_size[1]], 405 | &DrawState::default(), 406 | c.transform, 407 | gl); 408 | 409 | let mut x = self.settings.board_padding + self.settings.tile_padding; 410 | let mut y = self.settings.board_padding + self.settings.board_offset_y + self.settings.tile_padding; 411 | 412 | for _ in 0..self.settings.tile_height { 413 | for _ in 0..self.settings.tile_width { 414 | Rectangle::new( 415 | rgb2rgba(self.settings.tiles_colors[0])) 416 | .draw([x, y, self.settings.tile_size, self.settings.tile_size], 417 | &DrawState::default(), 418 | c.transform, 419 | gl); 420 | 421 | x += self.settings.tile_padding + self.settings.tile_size; 422 | } 423 | 424 | x = self.settings.board_padding + self.settings.tile_padding; 425 | y += self.settings.tile_padding + self.settings.tile_size; 426 | } 427 | } 428 | 429 | fn render_tiles(&self, number_renderer: &NumberRenderer, c: &Context, gl: &mut GlGraphics) { 430 | for tile in self.tiles.iter() { 431 | tile.render(number_renderer, c, gl); 432 | } 433 | } 434 | 435 | fn add_score(&mut self, score: i32) { 436 | self.score += score; 437 | println!("Score: {}", self.score); 438 | } 439 | } 440 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | extern crate rustc_serialize; 2 | extern crate rand; 3 | extern crate piston_window; 4 | extern crate opengl_graphics; 5 | extern crate sdl2_window; 6 | 7 | use piston_window::*; 8 | use sdl2_window::Sdl2Window; 9 | 10 | mod app; 11 | mod board; 12 | mod number_renderer; 13 | mod settings; 14 | mod tile; 15 | 16 | fn main() { 17 | use opengl_graphics::GlGraphics; 18 | let settings = settings::Settings::load(); 19 | 20 | let (width, height) = (settings.window_size[0], 21 | settings.window_size[1]); 22 | 23 | // according to piston WindowSettings documentation, OpenGL::V3_2 is the default version 24 | let mut window: PistonWindow = 25 | WindowSettings::new("Rust-2048", [width, height]) 26 | .exit_on_esc(true) 27 | .build() 28 | .unwrap_or_else(|e| { panic!("Failed to build PistonWindow: {}", e) }); 29 | 30 | let mut app = app::App::new(&settings); 31 | 32 | app.load(); 33 | 34 | let mut gl = GlGraphics::new(OpenGL::V3_2); 35 | 36 | while let Some(e) = window.next() { 37 | if let Some(ref args) = e.render_args() { 38 | app.render(args, &mut gl); 39 | } 40 | 41 | if let Some(ref args) = e.update_args() { 42 | // TODO: only update if necessary 43 | // println!("update"); 44 | app.update(args); 45 | } 46 | 47 | if let Some(ref args) = e.press_args() { 48 | app.key_press(args); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/number_renderer.rs: -------------------------------------------------------------------------------- 1 | use std::path::Path; 2 | use piston_window::*; 3 | use opengl_graphics::GlGraphics; 4 | use opengl_graphics::Texture as GlTexture; 5 | 6 | static DIGITS_WIDTH: f64 = 20.0; 7 | static DIGITS_HEIGHT: f64 = 26.0; 8 | 9 | pub struct NumberRenderer { 10 | image: GlTexture, 11 | } 12 | 13 | impl NumberRenderer { 14 | pub fn new() -> NumberRenderer { 15 | NumberRenderer { 16 | image: GlTexture::from_path( 17 | Path::new("bin/assets/digits.png"), 18 | &TextureSettings::new(), 19 | ).unwrap(), 20 | } 21 | } 22 | 23 | pub fn render(&self, number: u32, center_x: f64, center_y: f64, max_width: f64, 24 | color: [f32; 3], c: &Context, gl: &mut GlGraphics) { 25 | let digits = number_to_digits(number); 26 | let total_width = DIGITS_WIDTH * digits.len() as f64; 27 | let total_width = if total_width > max_width { 28 | max_width 29 | } else { 30 | total_width 31 | }; 32 | let mut x = center_x - total_width / 2.0; 33 | let width = total_width / digits.len() as f64; 34 | let height = width / DIGITS_WIDTH * DIGITS_HEIGHT; 35 | let y = center_y - height / 2.0; 36 | 37 | for digit in digits.iter() { 38 | Image::new_color([color[0], color[1], color[2], 1.0]) 39 | .src_rect([(*digit * DIGITS_WIDTH as u32) as f64, 0 as f64, DIGITS_WIDTH as f64, DIGITS_HEIGHT as f64]) 40 | .rect([x, y, width, height]) 41 | .draw(&self.image, 42 | &DrawState::default(), 43 | c.transform, 44 | gl); 45 | 46 | x += width; 47 | } 48 | } 49 | } 50 | 51 | fn number_to_digits(number: u32) -> Vec { 52 | let mut digits = Vec::::new(); 53 | 54 | if number == 0 { 55 | digits.push(0); 56 | return digits; 57 | } 58 | 59 | let mut n = number; 60 | 61 | while n != 0 { 62 | digits.insert(0, n % 10); 63 | n /= 10; 64 | } 65 | 66 | digits 67 | } -------------------------------------------------------------------------------- /src/settings.rs: -------------------------------------------------------------------------------- 1 | 2 | use std::env::current_exe; 3 | use std::io::{BufWriter, BufReader, Write}; 4 | use std::fs::{File}; 5 | use std::path::Path; 6 | use rustc_serialize::{ json, Encodable, Decodable }; 7 | 8 | static SETTING_FILENAME: &'static str = "settings.json"; 9 | 10 | pub struct Settings { 11 | pub asset_folder: String, 12 | pub window_size: [u32; 2], 13 | pub window_background_color: [f32; 3], 14 | pub comment1_offset_y: f64, 15 | pub comment2_offset_y: f64, 16 | pub board_padding: f64, 17 | pub board_size: [f64; 2], 18 | pub board_offset_y: f64, 19 | pub tile_width: i32, 20 | pub tile_height: i32, 21 | pub tile_size: f64, 22 | pub tile_padding: f64, 23 | pub tile_background_color: [f32; 3], 24 | pub tiles_colors: Vec<[f32; 3]>, 25 | pub tile_unknow_color: [f32; 3], 26 | pub tile_move_time: f64, 27 | pub tile_new_time: f64, 28 | pub tile_combine_time: f64, 29 | pub best_rect: [f64; 4], 30 | pub score_rect: [f64; 4], 31 | pub label_color: [f32; 3], 32 | pub button_color: [f32; 3], 33 | pub text_dark_color: [f32; 3], 34 | pub text_light_color: [f32; 3], 35 | } 36 | 37 | impl Settings { 38 | pub fn load() -> Settings { 39 | Settings::from_settings_in_json(&SettingsInJson::load()) 40 | } 41 | 42 | fn from_settings_in_json<'a>(s: &'a SettingsInJson) -> Settings { 43 | let board_size = [ 44 | s.tile_size * s.tile_width as f64 + s.tile_padding * (s.tile_width + 1) as f64, 45 | s.tile_size * s.tile_height as f64 + s.tile_padding * (s.tile_height + 1) as f64, 46 | ]; 47 | 48 | let mut tiles_colors = Vec::<[f32; 3]>::new(); 49 | 50 | for color in s.tiles_colors.iter() { 51 | tiles_colors.push([ 52 | color[0] / 255.0, 53 | color[1] / 255.0, 54 | color[2] / 255.0, 55 | ]); 56 | } 57 | 58 | Settings { 59 | asset_folder: s.asset_folder.clone(), 60 | comment1_offset_y: s.comment1_offset_y, 61 | comment2_offset_y: s.comment2_offset_y, 62 | window_size: [ 63 | (s.board_padding * 2.0 + board_size[0]) as u32, 64 | (s.board_padding * 2.0 + board_size[1] + s.board_offset_y) as u32, 65 | ], 66 | window_background_color: [ 67 | s.window_background_color[0] / 255.0, 68 | s.window_background_color[1] / 255.0, 69 | s.window_background_color[2] / 255.0, 70 | ], 71 | board_padding: s.board_padding, 72 | board_size: board_size, 73 | board_offset_y: s.board_offset_y, 74 | tile_width: s.tile_width, 75 | tile_height: s.tile_height, 76 | tile_size: s.tile_size, 77 | tile_padding: s.tile_padding, 78 | tile_background_color: [ 79 | s.tile_background_color[0] / 255.0, 80 | s.tile_background_color[1] / 255.0, 81 | s.tile_background_color[2] / 255.0, 82 | ], 83 | tiles_colors: tiles_colors, 84 | tile_unknow_color: [ 85 | s.tile_unknow_color[0] / 255.0, 86 | s.tile_unknow_color[1] / 255.0, 87 | s.tile_unknow_color[2] / 255.0, 88 | ], 89 | tile_move_time: s.tile_move_time, 90 | tile_new_time: s.tile_new_time, 91 | tile_combine_time: s.tile_combine_time, 92 | best_rect: [ 93 | s.best_rect[0], 94 | s.best_rect[1], 95 | s.best_rect[2], 96 | s.best_rect[3], 97 | ], 98 | score_rect: [ 99 | s.score_rect[0], 100 | s.score_rect[1], 101 | s.score_rect[2], 102 | s.score_rect[3], 103 | ], 104 | label_color: [ 105 | s.label_color[0] / 255.0, 106 | s.label_color[1] / 255.0, 107 | s.label_color[2] / 255.0, 108 | ], 109 | button_color: [ 110 | s.button_color[0] / 255.0, 111 | s.button_color[1] / 255.0, 112 | s.button_color[2] / 255.0, 113 | ], 114 | text_dark_color: [ 115 | s.text_dark_color[0] / 255.0, 116 | s.text_dark_color[1] / 255.0, 117 | s.text_dark_color[2] / 255.0, 118 | ], 119 | text_light_color: [ 120 | s.text_light_color[0] / 255.0, 121 | s.text_light_color[1] / 255.0, 122 | s.text_light_color[2] / 255.0, 123 | ], 124 | } 125 | } 126 | } 127 | 128 | #[derive(RustcEncodable, RustcDecodable)] 129 | struct SettingsInJson { 130 | asset_folder: String, 131 | 132 | // r g b (0 - 255) 133 | window_background_color: Vec, 134 | 135 | comment1_offset_y: f64, 136 | comment2_offset_y: f64, 137 | 138 | board_padding: f64, 139 | board_offset_y: f64, 140 | 141 | tile_width: i32, 142 | tile_height: i32, 143 | tile_size: f64, 144 | tile_padding: f64, 145 | tile_background_color: Vec, 146 | tiles_colors: Vec>, 147 | tile_unknow_color: Vec, 148 | 149 | tile_move_time: f64, 150 | tile_new_time: f64, 151 | tile_combine_time: f64, 152 | 153 | best_rect: Vec, 154 | score_rect: Vec, 155 | 156 | label_color: Vec, 157 | button_color: Vec, 158 | text_dark_color: Vec, 159 | text_light_color: Vec, 160 | } 161 | 162 | impl SettingsInJson { 163 | pub fn default_settings() -> SettingsInJson { 164 | let mut tiles_colors = Vec::>::new(); 165 | // empty color 166 | tiles_colors.push(vec![204.0, 192.0, 179.0]); 167 | // 2 color 168 | tiles_colors.push(vec![238.0, 228.0, 218.0]); 169 | // 4 color 170 | tiles_colors.push(vec![237.0, 224.0, 200.0]); 171 | // 8 color 172 | tiles_colors.push(vec![242.0, 177.0, 121.0]); 173 | // 16 color 174 | tiles_colors.push(vec![245.0, 149.0, 99.0]); 175 | // 32 color 176 | tiles_colors.push(vec![246.0, 124.0, 95.0]); 177 | // 64 color 178 | tiles_colors.push(vec![246.0, 94.0, 59.0]); 179 | // 128 color 180 | tiles_colors.push(vec![237.0, 207.0, 114.0]); 181 | // 256 color 182 | tiles_colors.push(vec![237.0, 204.0, 97.0]); 183 | // 512 color 184 | tiles_colors.push(vec![237.0, 200.0, 80.0]); 185 | SettingsInJson { 186 | asset_folder: "bin/assets".to_string(), 187 | window_background_color: vec![255.0, 248.0, 239.0], 188 | comment1_offset_y: 72.0, 189 | comment2_offset_y: 100.0, 190 | board_padding: 12.0, 191 | board_offset_y: 128.0, 192 | tile_width: 4, 193 | tile_height: 4, 194 | tile_size: 72.0, 195 | tile_padding: 16.0, 196 | tile_background_color: vec![187.0, 173.0, 160.0], 197 | tiles_colors: tiles_colors, 198 | tile_unknow_color: vec![200.0, 0.0, 0.0], 199 | tile_move_time: 0.1, 200 | tile_new_time: 0.1, 201 | tile_combine_time: 0.1, 202 | best_rect: vec![284.0, 12.0, 96.0, 48.0,], 203 | score_rect: vec![176.0, 12.0, 96.0, 48.0], 204 | label_color: vec![187.0, 173.0, 160.0], 205 | button_color: vec![142.0, 122.0, 102.0], 206 | text_dark_color: vec![119.0, 110.0, 101.0], 207 | text_light_color: vec![249.0, 246.0, 242.0], 208 | } 209 | } 210 | 211 | pub fn load() -> SettingsInJson { 212 | let exe_path = current_exe(); 213 | 214 | if exe_path.is_err() { 215 | return SettingsInJson::default_settings(); 216 | } 217 | 218 | let mut exe_path = exe_path.unwrap(); 219 | exe_path.pop(); 220 | let path = exe_path.join(Path::new(SETTING_FILENAME)); 221 | 222 | // FIXME: use this if possible (.exists() is unstable in Rust 1.0.0) 223 | /* if !path.as_path().exists() || !path.is_file() { 224 | println!("Configuration file not found. Generating a default one."); 225 | let default = SettingsInJson::default_settings(); 226 | default.save(); 227 | return default; 228 | } 229 | let file = File::open(&path).unwrap(); 230 | let mut reader = BufReader::new(file); 231 | */ 232 | let file = File::open(&path); 233 | 234 | match file { 235 | Err(e) => { 236 | println!("Configuration file can't be open ({}). Try to generate a default one.", e); 237 | let default = SettingsInJson::default_settings(); 238 | default.save(); 239 | return default; 240 | }, 241 | _ => {} 242 | } 243 | 244 | let mut reader = BufReader::new(file.unwrap()); 245 | // End FIXME 246 | 247 | let mut decoder = json::Decoder::new(json::Json::from_reader(&mut reader).unwrap()); 248 | Decodable::decode(&mut decoder).unwrap() 249 | } 250 | 251 | pub fn save(&self) { 252 | let exe_path = current_exe(); 253 | 254 | if exe_path.is_err() { 255 | println!("WARNING: Failed to save settings: can't find exe path."); 256 | return; 257 | } 258 | 259 | let path = exe_path.unwrap(); 260 | let file = File::create(&path.with_file_name(SETTING_FILENAME)).unwrap(); 261 | let mut writer = BufWriter::new(file); 262 | 263 | match json::encode(self) { 264 | Ok(encoded) => { 265 | if let Err(e) = writer.write(encoded.as_bytes()) { 266 | println!("WARNING: Failed to save settings: {}", e); 267 | } 268 | }, 269 | Err(e) => { 270 | println!("WARNING: Failed to save settings: {}", e); 271 | } 272 | } 273 | } 274 | } 275 | -------------------------------------------------------------------------------- /src/tile.rs: -------------------------------------------------------------------------------- 1 | use piston_window::*; 2 | use opengl_graphics::GlGraphics; 3 | use number_renderer::NumberRenderer; 4 | use settings::Settings; 5 | 6 | #[derive(Clone, PartialEq)] 7 | pub enum TileState { 8 | TileStatic, 9 | /// (t, x, y, origin_x, origin_y) 10 | TileMoving(f64, f64, f64, i32, i32), 11 | /// (t, size) 12 | TileNew(f64, f64), 13 | /// (t, size) 14 | TileCombine(f64, f64), 15 | } 16 | 17 | #[derive(Clone)] 18 | pub struct Tile<'a> { 19 | pub score: i32, 20 | pub tile_x: i32, 21 | pub tile_y: i32, 22 | pub status: TileState, 23 | 24 | settings: &'a Settings, 25 | } 26 | 27 | impl<'a> Tile<'a> { 28 | pub fn new(settings: &'a Settings, score: i32, tile_x: i32, tile_y: i32) -> Tile<'a> { 29 | Tile { 30 | score: score, 31 | tile_x: tile_x, 32 | tile_y: tile_y, 33 | status: TileState::TileNew(settings.tile_new_time, 0.0), 34 | 35 | settings: settings, 36 | } 37 | } 38 | 39 | pub fn new_combined(settings: &'a Settings, score: i32, tile_x: i32, tile_y: i32) -> Tile<'a> { 40 | Tile { 41 | score: score, 42 | tile_x: tile_x, 43 | tile_y: tile_y, 44 | status: TileState::TileCombine(settings.tile_combine_time, 1.2 * settings.tile_size), 45 | 46 | settings: settings, 47 | } 48 | } 49 | 50 | fn tile_to_pos(&self, tile_x: i32, tile_y: i32) -> (f64, f64) { 51 | let x = self.settings.board_padding + tile_x as f64 * self.settings.tile_size + (tile_x + 1) as f64 * self.settings.tile_padding; 52 | let y = self.settings.board_padding + self.settings.board_offset_y + tile_y as f64 * self.settings.tile_size + (tile_y + 1) as f64 * self.settings.tile_padding; 53 | (x, y) 54 | } 55 | 56 | pub fn start_moving(&mut self, destination_tile_x: i32, destination_tile_y: i32) { 57 | match self.status { 58 | TileState::TileMoving(_, _, _, ox, oy) => { 59 | let (x, y) = self.tile_to_pos(ox, oy); 60 | self.status = TileState::TileMoving(self.settings.tile_move_time, x, y, ox, oy); 61 | self.tile_x = destination_tile_x; 62 | self.tile_y = destination_tile_y; 63 | }, 64 | TileState::TileStatic => { 65 | let (x, y) = self.tile_to_pos(self.tile_x, self.tile_y); 66 | self.status = TileState::TileMoving(self.settings.tile_move_time, x, y, self.tile_x, self.tile_y); 67 | self.tile_x = destination_tile_x; 68 | self.tile_y = destination_tile_y; 69 | }, 70 | _ => {}, 71 | } 72 | } 73 | 74 | pub fn update(&mut self, dt: f64) { 75 | match self.status { 76 | TileState::TileMoving(t, x, y, ox, oy) => { 77 | if dt >= t { 78 | self.status = TileState::TileStatic; 79 | } else { 80 | let (dx, dy) = self.tile_to_pos(self.tile_x, self.tile_y); 81 | let factor = dt / t; 82 | self.status = TileState::TileMoving(t - dt, x + factor * (dx - x), y + factor * (dy - y), ox, oy); 83 | } 84 | }, 85 | TileState::TileNew(t, size) => { 86 | if dt >= t { 87 | self.status = TileState::TileStatic; 88 | } else { 89 | let factor = dt / t; 90 | self.status = TileState::TileNew(t - dt, size + factor * (self.settings.tile_size - size)); 91 | } 92 | }, 93 | TileState::TileCombine(t, size) => { 94 | if dt >= t { 95 | self.status = TileState::TileStatic; 96 | } else { 97 | let factor = dt / t; 98 | self.status = TileState::TileCombine(t - dt, size + factor * (self.settings.tile_size - size)); 99 | } 100 | }, 101 | _ => {}, 102 | } 103 | } 104 | 105 | pub fn render(&self, number_renderer: &NumberRenderer, c: &Context, gl: &mut GlGraphics) { 106 | let mut pos = self.tile_to_pos(self.tile_x, self.tile_y); 107 | let mut size = (self.settings.tile_size, self.settings.tile_size); 108 | 109 | match self.status { 110 | TileState::TileMoving(_, x, y, _, _) => { 111 | pos = (x, y); 112 | }, 113 | TileState::TileNew(_, s) => { 114 | size = (s, s); 115 | }, 116 | TileState::TileCombine(_, s) => { 117 | size = (s, s); 118 | }, 119 | _ => {}, 120 | } 121 | 122 | let (x, y) = pos; 123 | let (w, h) = size; 124 | let color = self.get_color(); 125 | 126 | Rectangle::new([color[0], color[1], color[2], 1.0]) 127 | .draw(rectangle::centered([x + self.settings.tile_size / 2.0, 128 | y + self.settings.tile_size / 2., 129 | w/2.0, h/2.0]), 130 | &DrawState::default(), 131 | c.transform, 132 | gl); 133 | 134 | let color = if self.score >= 8 { 135 | self.settings.text_light_color 136 | } else { 137 | self.settings.text_dark_color 138 | }; 139 | 140 | number_renderer.render(self.score as u32, x + self.settings.tile_size / 2.0, y + self.settings.tile_size / 2.0, self.settings.tile_size, color, c, gl); 141 | } 142 | 143 | fn get_color(&self) -> [f32; 3] { 144 | let i = (self.score as f64).log2() as usize; 145 | if i > 0 && i < self.settings.tiles_colors.len() { 146 | self.settings.tiles_colors[i] 147 | } else { 148 | self.settings.tile_unknow_color 149 | } 150 | } 151 | } 152 | --------------------------------------------------------------------------------