diff options
-rw-r--r-- | Cargo.lock | 167 | ||||
-rw-r--r-- | Cargo.toml | 3 | ||||
-rw-r--r-- | resources/tileset.tsx | 4 | ||||
-rw-r--r-- | src/constants.rs | 1 | ||||
-rw-r--r-- | src/lib.rs | 2 | ||||
-rw-r--r-- | src/main.rs | 50 | ||||
-rw-r--r-- | src/map.rs | 92 |
7 files changed, 121 insertions, 198 deletions
@@ -122,14 +122,6 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "base64" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] name = "bindgen" version = "0.32.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -150,11 +142,6 @@ dependencies = [ [[package]] name = "bitflags" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "bitflags" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -164,11 +151,6 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "build_const" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] name = "bumpalo" version = "2.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -202,15 +184,6 @@ dependencies = [ ] [[package]] -name = "c2-chacha" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] name = "cargo_metadata" version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -380,14 +353,6 @@ dependencies = [ ] [[package]] -name = "crc" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "build_const 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] name = "crc32fast" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -518,17 +483,6 @@ dependencies = [ ] [[package]] -name = "flate2" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "miniz_oxide_c_api 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] name = "fnv" version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -560,17 +514,6 @@ dependencies = [ ] [[package]] -name = "getrandom" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] name = "gfx" version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1075,34 +1018,6 @@ dependencies = [ ] [[package]] -name = "miniz-sys" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "miniz_oxide" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "miniz_oxide_c_api" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", - "crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "miniz_oxide 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] name = "mint" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1303,8 +1218,7 @@ name = "pax-romana" version = "0.1.0" dependencies = [ "ggez 0.5.0-rc.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tiled 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "xml-rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1339,11 +1253,6 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "ppv-lite86" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] name = "proc-macro2" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1423,19 +1332,6 @@ dependencies = [ ] [[package]] -name = "rand" -version = "0.7.0-pre.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "getrandom 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_chacha 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] name = "rand_chacha" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1445,16 +1341,6 @@ dependencies = [ ] [[package]] -name = "rand_chacha" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] name = "rand_core" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1468,14 +1354,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "rand_core" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "getrandom 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] name = "rand_hc" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1484,14 +1362,6 @@ dependencies = [ ] [[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] name = "rand_isaac" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1917,16 +1787,6 @@ dependencies = [ ] [[package]] -name = "tiled" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "base64 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "flate2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", - "xml-rs 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] name = "toml" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2189,14 +2049,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "xml-rs" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "xml-rs" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2226,18 +2078,14 @@ dependencies = [ "checksum backtrace 0.3.30 (registry+https://github.com/rust-lang/crates.io-index)" = "ada4c783bb7e7443c14e0480f429ae2cc99da95065aeab7ee1b81ada0419404f" "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" "checksum base-x 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "76f4eae81729e69bb1819a26c6caac956cc429238388091f98cb6cd858f16443" -"checksum base64 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "30e93c03064e7590d0466209155251b90c22e37fab1daf2771582598b5827557" "checksum bindgen 0.32.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8b242e11a8f446f5fc7b76b37e81d737cabca562a927bd33766dac55b5f1177f" -"checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" "checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd" "checksum block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" -"checksum build_const 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39092a32794787acd8525ee150305ff051b0aa6cc2abaf193924f5ab05425f39" "checksum bumpalo 2.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "84dca3afd8e01b9526818b7963e5b4916063b3cdf9f10cf6b73ef0bd0ec37aa5" "checksum bytecount 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b92204551573580e078dc80017f36a213eb77a0450e4ddd8cfa0f3f2d1f0178f" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum bzip2 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "42b7c3cbf0fa9c1b82308d57191728ca0256cb821220f4e2fd410a72ade26e3b" "checksum bzip2-sys 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "6584aa36f5ad4c9247f5323b0a42f37802b37a836f0ad87084d7a33961abe25f" -"checksum c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d64d04786e0f528460fc884753cf8dddcc466be308f6026f8e355c41a0e4101" "checksum cargo_metadata 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e5d1b4d380e1bab994591a24c2bdd1b054f64b60bef483a8c598c7c345bc3bbe" "checksum cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)" = "39f75544d7bbaf57560d2168f28fd649ff9c76153874db88bdbdfd839b1a7e7d" "checksum cexpr 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "42aac45e9567d97474a834efdee3081b3c942b2205be932092f53354ce503d6c" @@ -2257,7 +2105,6 @@ dependencies = [ "checksum coreaudio-rs 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f229761965dad3e9b11081668a6ea00f1def7aa46062321b5ec245b834f6e491" "checksum coreaudio-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "78fdbabf58d5b1f461e31b94a571c109284f384cec619a3d96e66ec55b4de82b" "checksum cpal 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d58ae1ed6536b1b233f5e3aeb6997a046ddb4d05e3f61701b58a92eb254a829e" -"checksum crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d663548de7f5cca343f1e0a48d14dcfb0e9eb4e079ec58883b7251539fa10aeb" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b18cd2e169ad86297e6bc0ad9aa679aee9daa4f19e8163860faf7c164e4f5a71" "checksum crossbeam-epoch 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "04c9e3102cc2d69cd681412141b390abd55a362afc1540965dad0ad4d34280b4" @@ -2273,13 +2120,11 @@ dependencies = [ "checksum error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3ab49e9dcb602294bc42f9a7dfc9bc6e936fca4418ea300dbfb84fe16de0b7d9" "checksum euclid 0.19.9 (registry+https://github.com/rust-lang/crates.io-index)" = "596b99621b9477e7a5f94d2d8dd13a9c5c302ac358b822c67a42b6f1054450e1" "checksum euclid_macros 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fdcb84c18ea5037a1c5a23039b4ff29403abce2e0d6b1daa11cf0bde2b30be15" -"checksum flate2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f87e68aa82b2de08a6e037f1385455759df6e445a8df5e005b4297191dbf18aa" "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" "checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" "checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" "checksum generic-array 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c0f28c2f5bfb5960175af447a2da7c18900693738343dc896ffbcabd9839592" -"checksum getrandom 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8d1dffef07351aafe6ef177e4dd2b8dcf503e6bc765dea3b0de9ed149a3db1ec" "checksum gfx 0.18.1 (registry+https://github.com/rust-lang/crates.io-index)" = "619e38a31e275efaf92c6a94f977db8aac396e3cb6998c176cfde32ce3239b69" "checksum gfx_core 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4e1127b02a9d4fcc880091d8a0f4419efd598de4f1649edcd005c76e5792176f" "checksum gfx_device_gl 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3fdb9c21d057f32d5a9fc7b8737a28e09a93006a095e0a129723b424cffd2003" @@ -2335,9 +2180,6 @@ dependencies = [ "checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3" "checksum minimp3 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "542e9bed56860c5070a09939eee0e2df6f8f73f60304ddf56d620947e7017239" "checksum minimp3-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c109ae05c00ad6e3a53fab101e2f234545bdd010f0fffd399355efaf70817817" -"checksum miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9e3ae51cea1576ceba0dde3d484d30e6e5b86dee0b2d412fe3a16a15c98202" -"checksum miniz_oxide 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c468f2369f07d651a5d0bb2c9079f8488a66d5466efe42d0c5c6466edcb7f71e" -"checksum miniz_oxide_c_api 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b7fe927a42e3807ef71defb191dc87d4e24479b221e67015fe38ae2b7b447bab" "checksum mint 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c9e6c29b4bb0155117ea1a61520406c975673ee71b0287323f06d1a8d69c4a7c" "checksum nalgebra 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8e12856109b5cb8e2934b5e45e4624839416e1c6c1f7d286711a7a66b79db29d" "checksum nix 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "becb657d662f1cd2ef38c7ad480ec6b8cf9e96b27adb543e594f9cf0f2e6065c" @@ -2365,7 +2207,6 @@ dependencies = [ "checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c" "checksum png 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "63daf481fdd0defa2d1d2be15c674fbfa1b0fd71882c303a91f9a79b3252c359" "checksum podio 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "780fb4b6698bbf9cf2444ea5d22411cef2953f0824b98f33cf454ec5615645bd" -"checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" "checksum proc-macro2 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cd07deb3c6d1d9ff827999c7f9b04cdfd66b1b17ae508e14fe47b620f2282ae0" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" "checksum pulldown-cmark 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eef52fac62d0ea7b9b4dc7da092aa64ea7ec3d90af6679422d3d7e0e14b6ee15" @@ -2374,14 +2215,10 @@ dependencies = [ "checksum rand 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)" = "64ac302d8f83c0c1974bf758f6b041c6c8ada916fbb44a609158ca8b064cc76c" "checksum rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" "checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" -"checksum rand 0.7.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)" = "866531c9bb6613da04a1e6ad99d27a7c8acd488020d7a8b177b058a10c900eec" "checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" -"checksum rand_chacha 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e193067942ef6f485a349a113329140d0ab9e2168ce92274499bb0e9a4190d9d" "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" "checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0" -"checksum rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "615e683324e75af5d43d8f7a39ffe3ee4a9dc42c5c701167a71dc59c3a493aca" "checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" -"checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" "checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" "checksum rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" "checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" @@ -2430,7 +2267,6 @@ dependencies = [ "checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" "checksum tiff 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1e4834f28a0330cb9f3f2c87d2649dca723cb33802e2bdcf18da32759fbec7ce" -"checksum tiled 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3e43db82e3c62f96d84482c1b69e8a9b9ceb1c5cd80bd2ee1669caec58f5831d" "checksum toml 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b8c96d7873fa7ef8bdeb3a9cda3ac48389b4154f32b9803b4bc26220b677b039" "checksum twox-hash 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6c7bcecad121018bdcd6b709fa2325b004878fcb3d3067934ce90749f0faff9a" "checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169" @@ -2464,6 +2300,5 @@ dependencies = [ "checksum x11-dl 2.18.3 (registry+https://github.com/rust-lang/crates.io-index)" = "940586acb859ea05c53971ac231685799a7ec1dee66ac0bccc0e6ad96e06b4e3" "checksum xdg 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d089681aa106a86fade1b0128fb5daf07d5867a509ab036d99988dec80429a57" "checksum xi-unicode 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "12ea8eda4b1eb72f02d148402e23832d56a33f55d8c1b2d5bcdde91d79d47cb1" -"checksum xml-rs 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7ec6c39eaa68382c8e31e35239402c0a9489d4141a8ceb0c716099a0b515b562" "checksum xml-rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "541b12c998c5b56aa2b4e6f18f03664eef9a4fd0a246a55594efae6cc2d964b5" "checksum zip 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c18fc320faf909036e46ac785ea827f72e485304877faf1a3a39538d3714dbc3" @@ -6,5 +6,4 @@ edition = "2018" [dependencies] ggez = "0.5.0-rc.2" -rand = "0.7.0-pre.1" -tiled = "0.8.0" +xml-rs = "0.8" diff --git a/resources/tileset.tsx b/resources/tileset.tsx new file mode 100644 index 0000000..d3f1cf4 --- /dev/null +++ b/resources/tileset.tsx @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> +<tileset version="1.2" tiledversion="1.2.1" name="tileset" tilewidth="16" tileheight="16" tilecount="3" columns="3"> + <image source="tileset.png" width="48" height="16"/> +</tileset> diff --git a/src/constants.rs b/src/constants.rs new file mode 100644 index 0000000..8276340 --- /dev/null +++ b/src/constants.rs @@ -0,0 +1 @@ +pub const TILE_SCALE: f32 = 3.0; diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..32420a3 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,2 @@ +pub mod constants; +pub mod map; diff --git a/src/main.rs b/src/main.rs index 1d4c606..bb85c0a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,34 +1,31 @@ use ggez::conf::Conf; use ggez::event::{self, EventHandler}; use ggez::filesystem; -use ggez::graphics::{self, spritebatch::SpriteBatch, DrawParam, FilterMode, Image, Rect}; +use ggez::graphics::{self, spritebatch::SpriteBatch, DrawParam, FilterMode, Image}; use ggez::nalgebra::{Point2, Vector2}; use ggez::{Context, ContextBuilder, GameResult}; -use std::io::BufReader; -use tiled::{parse, Map}; +use pax_romana::constants; +use pax_romana::map::{Map, Tileset}; struct State { - spritebatch: SpriteBatch, map: Map, + tileset: Tileset, + spritebatch: SpriteBatch, } impl State { fn new(context: &mut Context) -> GameResult<State> { - let mut tileset = Image::new(context, "/tileset.png")?; - tileset.set_filter(FilterMode::Nearest); - - let reader = BufReader::new(filesystem::open(context, "/map.tmx")?); + let mut image = Image::new(context, "/tileset.png")?; + image.set_filter(FilterMode::Nearest); Ok(State { - spritebatch: SpriteBatch::new(tileset), - map: parse(reader).unwrap(), + map: Map::new(filesystem::open(context, "/map.tmx")?), + tileset: Tileset::new(filesystem::open(context, "/tileset.tsx")?), + spritebatch: SpriteBatch::new(image), }) } } -const TILE_SIZE: f32 = 16.0; -const TILE_SCALE: f32 = 3.0; - impl EventHandler for State { fn update(&mut self, _context: &mut Context) -> GameResult { Ok(()) @@ -37,24 +34,17 @@ impl EventHandler for State { fn draw(&mut self, context: &mut Context) -> GameResult { graphics::clear(context, graphics::BLACK); - for layer in self.map.layers.iter() { - for x in 0..self.map.width { - for y in 0..self.map.height { - let draw_param = DrawParam::default() - .dest(Point2::new( - TILE_SIZE * TILE_SCALE * x as f32, - TILE_SIZE * TILE_SCALE * y as f32, - )) - .scale(Vector2::new(TILE_SCALE, TILE_SCALE)) - .src(match layer.tiles[y as usize][x as usize] { - 1 => Rect::new(0.0, 0.0, 1.0 / 3.0, 1.0), - 2 => Rect::new(1.0 / 3.0, 0.0, 2.0 / 3.0, 1.0), - 3 => Rect::new(2.0 / 3.0, 0.0, 1.0, 1.0), - _ => Rect::zero(), - }); + for x in 0..self.map.width { + for y in 0..self.map.height { + let draw_param = DrawParam::default() + .src(self.tileset.tiles[self.map.data[x + (y * self.map.height)]]) + .dest(Point2::new( + self.tileset.tile_width * constants::TILE_SCALE * x as f32, + self.tileset.tile_height * constants::TILE_SCALE * y as f32, + )) + .scale(Vector2::new(constants::TILE_SCALE, constants::TILE_SCALE)); - self.spritebatch.add(draw_param); - } + self.spritebatch.add(draw_param); } } diff --git a/src/map.rs b/src/map.rs new file mode 100644 index 0000000..2028b50 --- /dev/null +++ b/src/map.rs @@ -0,0 +1,92 @@ +use ggez::filesystem::File; +use ggez::graphics::Rect; +use std::io::BufReader; +use xml::reader::{EventReader, XmlEvent}; + +pub struct Map { + pub width: usize, + pub height: usize, + pub data: Vec<usize>, +} + +impl Map { + pub fn new(file: File) -> Map { + let mut width = None; + let mut height = None; + let mut data: Option<Vec<usize>> = None; + + for e in EventReader::new(BufReader::new(file)) { + if let Ok(XmlEvent::StartElement { + name, attributes, .. + }) = e + { + if name.local_name == "map" { + for attribute in attributes { + match attribute.name.local_name.as_str() { + "width" => width = Some(attribute.value.parse::<usize>().unwrap()), + "height" => height = Some(attribute.value.parse::<usize>().unwrap()), + _ => (), + } + } + } + } else if let Ok(XmlEvent::Characters(text)) = e { + data = Some( + text.replace("\n", "") + .split(',') + .map(|s| s.parse().unwrap()) + .collect(), + ); + } + } + + Map { + data: data.unwrap(), + width: width.unwrap(), + height: height.unwrap(), + } + } +} + +pub struct Tileset { + pub tiles: Vec<Rect>, + pub tile_width: f32, + pub tile_height: f32, +} + +impl Tileset { + pub fn new(file: File) -> Tileset { + let mut tile_width = None; + let mut tile_height = None; + let mut columns = None; + + for e in EventReader::new(BufReader::new(file)) { + if let Ok(XmlEvent::StartElement { attributes, .. }) = e { + for attribute in attributes { + match attribute.name.local_name.as_str() { + "columns" => columns = Some(attribute.value.parse::<usize>().unwrap()), + "tilewidth" => tile_width = Some(attribute.value.parse::<f32>().unwrap()), + "tileheight" => tile_height = Some(attribute.value.parse::<f32>().unwrap()), + _ => (), + } + } + } + } + + let columns = columns.unwrap(); + + let mut tiles = Vec::new(); + tiles.push(Rect::zero()); + + for c in 0..columns { + let x = c as f32 / columns as f32; + let w = (c as f32 + 1.0) / columns as f32; + tiles.push(Rect::new(x, 0.0, w, 1.0)); + } + + Tileset { + tiles, + tile_height: tile_height.unwrap(), + tile_width: tile_width.unwrap(), + } + } +} |