shitty tileset code
							parent
							
								
									71f8759bd5
								
							
						
					
					
						commit
						edcfd29de8
					
				
											
												Binary file not shown.
											
										
									
								| After Width: | Height: | Size: 74 KiB | 
| @ -0,0 +1,299 @@ | |||||||
|  | { "height":16, | ||||||
|  |  "infinite":false, | ||||||
|  |  "layers":[ | ||||||
|  |         { | ||||||
|  |          "data":[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], | ||||||
|  |          "height":16, | ||||||
|  |          "id":4, | ||||||
|  |          "name":"Hintergrund", | ||||||
|  |          "opacity":1, | ||||||
|  |          "type":"tilelayer", | ||||||
|  |          "visible":false, | ||||||
|  |          "width":20, | ||||||
|  |          "x":0, | ||||||
|  |          "y":0 | ||||||
|  |         },  | ||||||
|  |         { | ||||||
|  |          "data":[43, 43, 41, 42, 42, 41, 43, 43, 81, 81, 82, 82, 81, 0, 0, 0, 0, 0, 0, 0, 42, 43, 43, 43, 43, 41, 42, 43, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 81, 81, 81, 43, 43, 42, 41, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 81, 43, 43, 43, 41, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 81, 42, 43, 42, 41, 81, 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 9, 0, 0, 0, 82, 43, 42, 41, 42, 82, 615, 615, 615, 0, 0, 0, 0, 0, 47, 48, 49, 0, 0, 0, 82, 41, 43, 41, 43, 81, 0, 0, 0, 0, 328, 334, 335, 336, 0, 0, 0, 0, 0, 0, 82, 43, 43, 41, 43, 81, 0, 0, 0, 0, 328, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 82, 82, 82, 698, 81, 0, 0, 0, 0, 328, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 328, 0, 0, 0, 0, 0, 328, 0, 0, 0, 0, 0, 0, 367, 367, 367, 367, 367, 367, 367, 368, 367, 367, 367, 367, 367, 368, 369, 369, 369, 369, 369, 369, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | ||||||
|  |          "height":16, | ||||||
|  |          "id":5, | ||||||
|  |          "name":"Dekoration", | ||||||
|  |          "opacity":1, | ||||||
|  |          "type":"tilelayer", | ||||||
|  |          "visible":true, | ||||||
|  |          "width":20, | ||||||
|  |          "x":0, | ||||||
|  |          "y":0 | ||||||
|  |         },  | ||||||
|  |         { | ||||||
|  |          "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 486, 487, 488, 489, 490, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 526, 527, 528, 529, 530, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 566, 567, 568, 569, 570, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 776, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | ||||||
|  |          "height":16, | ||||||
|  |          "id":7, | ||||||
|  |          "name":"Vordergrund", | ||||||
|  |          "opacity":1, | ||||||
|  |          "type":"tilelayer", | ||||||
|  |          "visible":false, | ||||||
|  |          "width":20, | ||||||
|  |          "x":0, | ||||||
|  |          "y":0 | ||||||
|  |         }], | ||||||
|  |  "nextlayerid":9, | ||||||
|  |  "nextobjectid":33, | ||||||
|  |  "orientation":"orthogonal", | ||||||
|  |  "renderorder":"right-down", | ||||||
|  |  "tiledversion":"2018.09.12", | ||||||
|  |  "tileheight":16, | ||||||
|  |  "tilesets":[ | ||||||
|  |         { | ||||||
|  |          "columns":40, | ||||||
|  |          "firstgid":1, | ||||||
|  |          "image":"PokemonLike.png", | ||||||
|  |          "imageheight":640, | ||||||
|  |          "imagewidth":640, | ||||||
|  |          "margin":0, | ||||||
|  |          "name":"pokelike", | ||||||
|  |          "spacing":0, | ||||||
|  |          "terrains":[ | ||||||
|  |                 { | ||||||
|  |                  "name":"Base", | ||||||
|  |                  "tile":0 | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "name":"Gras", | ||||||
|  |                  "tile":1 | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "name":"Feld", | ||||||
|  |                  "tile":40 | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "name":"Sand", | ||||||
|  |                  "tile":200 | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "name":"Dreck", | ||||||
|  |                  "tile":44 | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "name":"Buschwerk", | ||||||
|  |                  "tile":80 | ||||||
|  |                 }], | ||||||
|  |          "tilecount":1600, | ||||||
|  |          "tileheight":16, | ||||||
|  |          "tiles":[ | ||||||
|  |                 { | ||||||
|  |                  "id":1, | ||||||
|  |                  "terrain":[1, 1, 1, 1] | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "id":2, | ||||||
|  |                  "terrain":[1, 1, 1, 1] | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "id":40, | ||||||
|  |                  "terrain":[2, 2, 2, 2] | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "id":41, | ||||||
|  |                  "terrain":[2, 2, 2, 2] | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "id":42, | ||||||
|  |                  "terrain":[2, 2, 2, 2] | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "id":44, | ||||||
|  |                  "terrain":[4, 4, 4, 4] | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "id":45, | ||||||
|  |                  "terrain":[4, 4, 4, 4] | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "id":80, | ||||||
|  |                  "terrain":[5, 5, 5, 5] | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "id":81, | ||||||
|  |                  "terrain":[5, 5, 5, 5] | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "id":200, | ||||||
|  |                  "terrain":[3, 3, 3, 3] | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "id":201, | ||||||
|  |                  "terrain":[3, 3, 3, 3] | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "id":333, | ||||||
|  |                  "objectgroup": | ||||||
|  |                     { | ||||||
|  |                      "draworder":"index", | ||||||
|  |                      "name":"", | ||||||
|  |                      "objects":[ | ||||||
|  |                             { | ||||||
|  |                              "height":16, | ||||||
|  |                              "id":1, | ||||||
|  |                              "name":"", | ||||||
|  |                              "rotation":0, | ||||||
|  |                              "type":"", | ||||||
|  |                              "visible":true, | ||||||
|  |                              "width":16, | ||||||
|  |                              "x":0, | ||||||
|  |                              "y":0 | ||||||
|  |                             }], | ||||||
|  |                      "opacity":1, | ||||||
|  |                      "type":"objectgroup", | ||||||
|  |                      "visible":true, | ||||||
|  |                      "x":0, | ||||||
|  |                      "y":0 | ||||||
|  |                     } | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "id":334, | ||||||
|  |                  "objectgroup": | ||||||
|  |                     { | ||||||
|  |                      "draworder":"index", | ||||||
|  |                      "name":"", | ||||||
|  |                      "objects":[ | ||||||
|  |                             { | ||||||
|  |                              "height":16, | ||||||
|  |                              "id":3, | ||||||
|  |                              "name":"", | ||||||
|  |                              "rotation":0, | ||||||
|  |                              "type":"", | ||||||
|  |                              "visible":true, | ||||||
|  |                              "width":16, | ||||||
|  |                              "x":0, | ||||||
|  |                              "y":0 | ||||||
|  |                             }], | ||||||
|  |                      "opacity":1, | ||||||
|  |                      "type":"objectgroup", | ||||||
|  |                      "visible":true, | ||||||
|  |                      "x":0, | ||||||
|  |                      "y":0 | ||||||
|  |                     } | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "id":335, | ||||||
|  |                  "objectgroup": | ||||||
|  |                     { | ||||||
|  |                      "draworder":"index", | ||||||
|  |                      "name":"", | ||||||
|  |                      "objects":[ | ||||||
|  |                             { | ||||||
|  |                              "height":16, | ||||||
|  |                              "id":1, | ||||||
|  |                              "name":"", | ||||||
|  |                              "rotation":0, | ||||||
|  |                              "type":"", | ||||||
|  |                              "visible":true, | ||||||
|  |                              "width":16, | ||||||
|  |                              "x":0, | ||||||
|  |                              "y":0 | ||||||
|  |                             }], | ||||||
|  |                      "opacity":1, | ||||||
|  |                      "type":"objectgroup", | ||||||
|  |                      "visible":true, | ||||||
|  |                      "x":0, | ||||||
|  |                      "y":0 | ||||||
|  |                     } | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "id":488, | ||||||
|  |                  "objectgroup": | ||||||
|  |                     { | ||||||
|  |                      "draworder":"index", | ||||||
|  |                      "name":"", | ||||||
|  |                      "objects":[ | ||||||
|  |                             { | ||||||
|  |                              "height":0, | ||||||
|  |                              "id":1, | ||||||
|  |                              "name":"", | ||||||
|  |                              "rotation":0, | ||||||
|  |                              "type":"", | ||||||
|  |                              "visible":true, | ||||||
|  |                              "width":16, | ||||||
|  |                              "x":0, | ||||||
|  |                              "y":0 | ||||||
|  |                             }], | ||||||
|  |                      "opacity":1, | ||||||
|  |                      "type":"objectgroup", | ||||||
|  |                      "visible":true, | ||||||
|  |                      "x":0, | ||||||
|  |                      "y":0 | ||||||
|  |                     } | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "id":527, | ||||||
|  |                  "objectgroup": | ||||||
|  |                     { | ||||||
|  |                      "draworder":"index", | ||||||
|  |                      "name":"", | ||||||
|  |                      "objects":[ | ||||||
|  |                             { | ||||||
|  |                              "height":16, | ||||||
|  |                              "id":2, | ||||||
|  |                              "name":"", | ||||||
|  |                              "rotation":0, | ||||||
|  |                              "type":"", | ||||||
|  |                              "visible":true, | ||||||
|  |                              "width":0, | ||||||
|  |                              "x":16, | ||||||
|  |                              "y":0 | ||||||
|  |                             }], | ||||||
|  |                      "opacity":1, | ||||||
|  |                      "type":"objectgroup", | ||||||
|  |                      "visible":true, | ||||||
|  |                      "x":0, | ||||||
|  |                      "y":0 | ||||||
|  |                     } | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "animation":[ | ||||||
|  |                         { | ||||||
|  |                          "duration":250, | ||||||
|  |                          "tileid":775 | ||||||
|  |                         },  | ||||||
|  |                         { | ||||||
|  |                          "duration":250, | ||||||
|  |                          "tileid":776 | ||||||
|  |                         },  | ||||||
|  |                         { | ||||||
|  |                          "duration":250, | ||||||
|  |                          "tileid":777 | ||||||
|  |                         },  | ||||||
|  |                         { | ||||||
|  |                          "duration":250, | ||||||
|  |                          "tileid":778 | ||||||
|  |                         }], | ||||||
|  |                  "id":778 | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "animation":[ | ||||||
|  |                         { | ||||||
|  |                          "duration":250, | ||||||
|  |                          "tileid":816 | ||||||
|  |                         },  | ||||||
|  |                         { | ||||||
|  |                          "duration":250, | ||||||
|  |                          "tileid":817 | ||||||
|  |                         },  | ||||||
|  |                         { | ||||||
|  |                          "duration":250, | ||||||
|  |                          "tileid":818 | ||||||
|  |                         },  | ||||||
|  |                         { | ||||||
|  |                          "duration":250, | ||||||
|  |                          "tileid":819 | ||||||
|  |                         }], | ||||||
|  |                  "id":819 | ||||||
|  |                 }], | ||||||
|  |          "tilewidth":16 | ||||||
|  |         }], | ||||||
|  |  "tilewidth":16, | ||||||
|  |  "type":"map", | ||||||
|  |  "version":1.2, | ||||||
|  |  "width":20 | ||||||
|  | } | ||||||
											
												Binary file not shown.
											
										
									
								| After Width: | Height: | Size: 19 KiB | 
| @ -0,0 +1,126 @@ | |||||||
|  | <?xml version="1.0" encoding="UTF-8"?> | ||||||
|  | <map version="1.1" tiledversion="2018.09.12" orientation="orthogonal" renderorder="right-down" width="20" height="16" tilewidth="16" tileheight="16" infinite="0" nextlayerid="9" nextobjectid="33"> | ||||||
|  |  <tileset firstgid="1" name="pokelike" tilewidth="16" tileheight="16" tilecount="1600" columns="40"> | ||||||
|  |   <image source="PokemonLike.png" width="640" height="640"/> | ||||||
|  |   <terraintypes> | ||||||
|  |    <terrain name="Base" tile="0"/> | ||||||
|  |    <terrain name="Gras" tile="1"/> | ||||||
|  |    <terrain name="Feld" tile="40"/> | ||||||
|  |    <terrain name="Sand" tile="200"/> | ||||||
|  |    <terrain name="Dreck" tile="44"/> | ||||||
|  |    <terrain name="Buschwerk" tile="80"/> | ||||||
|  |   </terraintypes> | ||||||
|  |   <tile id="1" terrain="1,1,1,1"/> | ||||||
|  |   <tile id="2" terrain="1,1,1,1"/> | ||||||
|  |   <tile id="40" terrain="2,2,2,2"/> | ||||||
|  |   <tile id="41" terrain="2,2,2,2"/> | ||||||
|  |   <tile id="42" terrain="2,2,2,2"/> | ||||||
|  |   <tile id="44" terrain="4,4,4,4"/> | ||||||
|  |   <tile id="45" terrain="4,4,4,4"/> | ||||||
|  |   <tile id="80" terrain="5,5,5,5"/> | ||||||
|  |   <tile id="81" terrain="5,5,5,5"/> | ||||||
|  |   <tile id="200" terrain="3,3,3,3"/> | ||||||
|  |   <tile id="201" terrain="3,3,3,3"/> | ||||||
|  |   <tile id="333"> | ||||||
|  |    <objectgroup draworder="index"> | ||||||
|  |     <object id="1" x="0" y="0" width="16" height="16"/> | ||||||
|  |    </objectgroup> | ||||||
|  |   </tile> | ||||||
|  |   <tile id="334"> | ||||||
|  |    <objectgroup draworder="index"> | ||||||
|  |     <object id="3" x="0" y="0" width="16" height="16"/> | ||||||
|  |    </objectgroup> | ||||||
|  |   </tile> | ||||||
|  |   <tile id="335"> | ||||||
|  |    <objectgroup draworder="index"> | ||||||
|  |     <object id="1" x="0" y="0" width="16" height="16"/> | ||||||
|  |    </objectgroup> | ||||||
|  |   </tile> | ||||||
|  |   <tile id="488"> | ||||||
|  |    <objectgroup draworder="index"> | ||||||
|  |     <object id="1" x="0" y="0" width="16"/> | ||||||
|  |    </objectgroup> | ||||||
|  |   </tile> | ||||||
|  |   <tile id="527"> | ||||||
|  |    <objectgroup draworder="index"> | ||||||
|  |     <object id="2" x="16" y="0" height="16"/> | ||||||
|  |    </objectgroup> | ||||||
|  |   </tile> | ||||||
|  |   <tile id="778"> | ||||||
|  |    <animation> | ||||||
|  |     <frame tileid="775" duration="250"/> | ||||||
|  |     <frame tileid="776" duration="250"/> | ||||||
|  |     <frame tileid="777" duration="250"/> | ||||||
|  |     <frame tileid="778" duration="250"/> | ||||||
|  |    </animation> | ||||||
|  |   </tile> | ||||||
|  |   <tile id="819"> | ||||||
|  |    <animation> | ||||||
|  |     <frame tileid="816" duration="250"/> | ||||||
|  |     <frame tileid="817" duration="250"/> | ||||||
|  |     <frame tileid="818" duration="250"/> | ||||||
|  |     <frame tileid="819" duration="250"/> | ||||||
|  |    </animation> | ||||||
|  |   </tile> | ||||||
|  |  </tileset> | ||||||
|  |  <layer id="4" name="Hintergrund" width="20" height="16"> | ||||||
|  |   <data encoding="csv"> | ||||||
|  | 1,1,1,1,1,1,1,1,1,1,1,1,1,3,2,3,2,3,3,3, | ||||||
|  | 1,1,1,1,1,1,1,1,1,3,2,3,3,2,2,3,2,2,2,3, | ||||||
|  | 1,1,1,1,1,1,1,1,1,2,2,3,2,3,2,2,2,3,3,2, | ||||||
|  | 2,2,2,1,1,1,1,1,1,2,3,3,1,1,1,1,1,2,3,3, | ||||||
|  | 3,2,3,1,1,1,1,1,1,2,2,3,1,1,1,1,1,1,1,1, | ||||||
|  | 2,3,2,1,1,1,1,1,1,3,2,3,1,1,1,1,1,1,1,1, | ||||||
|  | 2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, | ||||||
|  | 2,3,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, | ||||||
|  | 2,3,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, | ||||||
|  | 3,3,3,3,3,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1, | ||||||
|  | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, | ||||||
|  | 2,2,2,3,3,3,3,3,2,3,2,2,3,3,2,3,2,2,3,2, | ||||||
|  | 2,2,2,2,2,3,2,3,3,3,2,3,3,2,3,2,2,2,3,3, | ||||||
|  | 3,3,3,2,2,3,2,2,2,2,3,3,3,2,2,3,2,3,2,2, | ||||||
|  | 3,3,2,3,3,2,3,3,3,2,3,3,3,2,3,3,3,2,2,2, | ||||||
|  | 2,3,2,3,2,3,2,3,2,2,3,3,2,2,3,3,2,2,2,3 | ||||||
|  | </data> | ||||||
|  |  </layer> | ||||||
|  |  <layer id="5" name="Dekoration" width="20" height="16"> | ||||||
|  |   <data encoding="csv"> | ||||||
|  | 43,43,41,42,42,41,43,43,81,81,82,82,81,0,0,0,0,0,0,0, | ||||||
|  | 42,43,43,43,43,41,42,43,82,0,0,0,0,0,0,0,0,0,0,0, | ||||||
|  | 82,81,81,81,43,43,42,41,82,0,0,0,0,0,0,0,0,0,0,0, | ||||||
|  | 0,0,0,81,43,43,43,41,81,0,0,0,0,0,0,0,0,0,0,0, | ||||||
|  | 0,0,0,81,42,43,42,41,81,0,0,0,0,0,0,0,0,7,8,9, | ||||||
|  | 0,0,0,82,43,42,41,42,82,615,615,615,0,0,0,0,0,47,48,49, | ||||||
|  | 0,0,0,82,41,43,41,43,81,0,0,0,0,328,334,335,336,0,0,0, | ||||||
|  | 0,0,0,82,43,43,41,43,81,0,0,0,0,328,0,0,0,0,0,0, | ||||||
|  | 0,0,0,82,82,82,82,698,81,0,0,0,0,328,0,0,0,0,0,0, | ||||||
|  | 0,0,0,0,0,0,0,328,0,0,0,0,0,328,0,0,0,0,0,0, | ||||||
|  | 367,367,367,367,367,367,367,368,367,367,367,367,367,368,369,369,369,369,369,369, | ||||||
|  | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | ||||||
|  | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | ||||||
|  | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | ||||||
|  | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | ||||||
|  | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 | ||||||
|  | </data> | ||||||
|  |  </layer> | ||||||
|  |  <layer id="7" name="Vordergrund" width="20" height="16"> | ||||||
|  |   <data encoding="csv"> | ||||||
|  | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | ||||||
|  | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | ||||||
|  | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | ||||||
|  | 0,0,0,0,0,0,0,0,0,0,0,0,486,487,488,489,490,0,0,0, | ||||||
|  | 0,0,0,0,0,0,0,0,0,0,0,0,526,527,528,529,530,0,0,0, | ||||||
|  | 0,0,0,0,0,0,0,0,0,0,0,0,566,567,568,569,570,0,0,0, | ||||||
|  | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | ||||||
|  | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | ||||||
|  | 0,0,0,0,0,0,0,0,0,0,776,0,0,0,0,0,0,0,0,0, | ||||||
|  | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | ||||||
|  | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | ||||||
|  | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | ||||||
|  | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | ||||||
|  | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | ||||||
|  | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | ||||||
|  | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 | ||||||
|  | </data> | ||||||
|  |  </layer> | ||||||
|  | </map> | ||||||
| @ -0,0 +1,299 @@ | |||||||
|  | { "height":16, | ||||||
|  |  "infinite":false, | ||||||
|  |  "layers":[ | ||||||
|  |         { | ||||||
|  |          "data":[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], | ||||||
|  |          "height":16, | ||||||
|  |          "id":4, | ||||||
|  |          "name":"Hintergrund", | ||||||
|  |          "opacity":1, | ||||||
|  |          "type":"tilelayer", | ||||||
|  |          "visible":false, | ||||||
|  |          "width":20, | ||||||
|  |          "x":0, | ||||||
|  |          "y":0 | ||||||
|  |         },  | ||||||
|  |         { | ||||||
|  |          "data":[43, 43, 41, 42, 42, 41, 43, 43, 81, 81, 82, 82, 81, 0, 0, 0, 0, 0, 0, 0, 42, 43, 43, 43, 43, 41, 42, 43, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 81, 81, 81, 43, 43, 42, 41, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 81, 43, 43, 43, 41, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 81, 42, 43, 42, 41, 81, 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 9, 0, 0, 0, 82, 43, 42, 41, 42, 82, 615, 615, 615, 0, 0, 0, 0, 0, 47, 48, 49, 0, 0, 0, 82, 41, 43, 41, 43, 81, 0, 0, 0, 0, 328, 334, 335, 336, 0, 0, 0, 0, 0, 0, 82, 43, 43, 41, 43, 81, 0, 0, 0, 0, 328, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 82, 82, 82, 698, 81, 0, 0, 0, 0, 328, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 328, 0, 0, 0, 0, 0, 328, 0, 0, 0, 0, 0, 0, 367, 367, 367, 367, 367, 367, 367, 368, 367, 367, 367, 367, 367, 368, 369, 369, 369, 369, 369, 369, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | ||||||
|  |          "height":16, | ||||||
|  |          "id":5, | ||||||
|  |          "name":"Dekoration", | ||||||
|  |          "opacity":1, | ||||||
|  |          "type":"tilelayer", | ||||||
|  |          "visible":true, | ||||||
|  |          "width":20, | ||||||
|  |          "x":0, | ||||||
|  |          "y":0 | ||||||
|  |         },  | ||||||
|  |         { | ||||||
|  |          "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 486, 487, 488, 489, 490, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 526, 527, 528, 529, 530, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 566, 567, 568, 569, 570, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 776, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | ||||||
|  |          "height":16, | ||||||
|  |          "id":7, | ||||||
|  |          "name":"Vordergrund", | ||||||
|  |          "opacity":1, | ||||||
|  |          "type":"tilelayer", | ||||||
|  |          "visible":false, | ||||||
|  |          "width":20, | ||||||
|  |          "x":0, | ||||||
|  |          "y":0 | ||||||
|  |         }], | ||||||
|  |  "nextlayerid":9, | ||||||
|  |  "nextobjectid":33, | ||||||
|  |  "orientation":"orthogonal", | ||||||
|  |  "renderorder":"right-down", | ||||||
|  |  "tiledversion":"2018.09.12", | ||||||
|  |  "tileheight":16, | ||||||
|  |  "tilesets":[ | ||||||
|  |         { | ||||||
|  |          "columns":40, | ||||||
|  |          "firstgid":1, | ||||||
|  |          "image":"PokemonLike.png", | ||||||
|  |          "imageheight":640, | ||||||
|  |          "imagewidth":640, | ||||||
|  |          "margin":0, | ||||||
|  |          "name":"pokelike", | ||||||
|  |          "spacing":0, | ||||||
|  |          "terrains":[ | ||||||
|  |                 { | ||||||
|  |                  "name":"Base", | ||||||
|  |                  "tile":0 | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "name":"Gras", | ||||||
|  |                  "tile":1 | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "name":"Feld", | ||||||
|  |                  "tile":40 | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "name":"Sand", | ||||||
|  |                  "tile":200 | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "name":"Dreck", | ||||||
|  |                  "tile":44 | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "name":"Buschwerk", | ||||||
|  |                  "tile":80 | ||||||
|  |                 }], | ||||||
|  |          "tilecount":1600, | ||||||
|  |          "tileheight":16, | ||||||
|  |          "tiles":[ | ||||||
|  |                 { | ||||||
|  |                  "id":1, | ||||||
|  |                  "terrain":[1, 1, 1, 1] | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "id":2, | ||||||
|  |                  "terrain":[1, 1, 1, 1] | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "id":40, | ||||||
|  |                  "terrain":[2, 2, 2, 2] | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "id":41, | ||||||
|  |                  "terrain":[2, 2, 2, 2] | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "id":42, | ||||||
|  |                  "terrain":[2, 2, 2, 2] | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "id":44, | ||||||
|  |                  "terrain":[4, 4, 4, 4] | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "id":45, | ||||||
|  |                  "terrain":[4, 4, 4, 4] | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "id":80, | ||||||
|  |                  "terrain":[5, 5, 5, 5] | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "id":81, | ||||||
|  |                  "terrain":[5, 5, 5, 5] | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "id":200, | ||||||
|  |                  "terrain":[3, 3, 3, 3] | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "id":201, | ||||||
|  |                  "terrain":[3, 3, 3, 3] | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "id":333, | ||||||
|  |                  "objectgroup": | ||||||
|  |                     { | ||||||
|  |                      "draworder":"index", | ||||||
|  |                      "name":"", | ||||||
|  |                      "objects":[ | ||||||
|  |                             { | ||||||
|  |                              "height":16, | ||||||
|  |                              "id":1, | ||||||
|  |                              "name":"", | ||||||
|  |                              "rotation":0, | ||||||
|  |                              "type":"", | ||||||
|  |                              "visible":true, | ||||||
|  |                              "width":16, | ||||||
|  |                              "x":0, | ||||||
|  |                              "y":0 | ||||||
|  |                             }], | ||||||
|  |                      "opacity":1, | ||||||
|  |                      "type":"objectgroup", | ||||||
|  |                      "visible":true, | ||||||
|  |                      "x":0, | ||||||
|  |                      "y":0 | ||||||
|  |                     } | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "id":334, | ||||||
|  |                  "objectgroup": | ||||||
|  |                     { | ||||||
|  |                      "draworder":"index", | ||||||
|  |                      "name":"", | ||||||
|  |                      "objects":[ | ||||||
|  |                             { | ||||||
|  |                              "height":16, | ||||||
|  |                              "id":3, | ||||||
|  |                              "name":"", | ||||||
|  |                              "rotation":0, | ||||||
|  |                              "type":"", | ||||||
|  |                              "visible":true, | ||||||
|  |                              "width":16, | ||||||
|  |                              "x":0, | ||||||
|  |                              "y":0 | ||||||
|  |                             }], | ||||||
|  |                      "opacity":1, | ||||||
|  |                      "type":"objectgroup", | ||||||
|  |                      "visible":true, | ||||||
|  |                      "x":0, | ||||||
|  |                      "y":0 | ||||||
|  |                     } | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "id":335, | ||||||
|  |                  "objectgroup": | ||||||
|  |                     { | ||||||
|  |                      "draworder":"index", | ||||||
|  |                      "name":"", | ||||||
|  |                      "objects":[ | ||||||
|  |                             { | ||||||
|  |                              "height":16, | ||||||
|  |                              "id":1, | ||||||
|  |                              "name":"", | ||||||
|  |                              "rotation":0, | ||||||
|  |                              "type":"", | ||||||
|  |                              "visible":true, | ||||||
|  |                              "width":16, | ||||||
|  |                              "x":0, | ||||||
|  |                              "y":0 | ||||||
|  |                             }], | ||||||
|  |                      "opacity":1, | ||||||
|  |                      "type":"objectgroup", | ||||||
|  |                      "visible":true, | ||||||
|  |                      "x":0, | ||||||
|  |                      "y":0 | ||||||
|  |                     } | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "id":488, | ||||||
|  |                  "objectgroup": | ||||||
|  |                     { | ||||||
|  |                      "draworder":"index", | ||||||
|  |                      "name":"", | ||||||
|  |                      "objects":[ | ||||||
|  |                             { | ||||||
|  |                              "height":0, | ||||||
|  |                              "id":1, | ||||||
|  |                              "name":"", | ||||||
|  |                              "rotation":0, | ||||||
|  |                              "type":"", | ||||||
|  |                              "visible":true, | ||||||
|  |                              "width":16, | ||||||
|  |                              "x":0, | ||||||
|  |                              "y":0 | ||||||
|  |                             }], | ||||||
|  |                      "opacity":1, | ||||||
|  |                      "type":"objectgroup", | ||||||
|  |                      "visible":true, | ||||||
|  |                      "x":0, | ||||||
|  |                      "y":0 | ||||||
|  |                     } | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "id":527, | ||||||
|  |                  "objectgroup": | ||||||
|  |                     { | ||||||
|  |                      "draworder":"index", | ||||||
|  |                      "name":"", | ||||||
|  |                      "objects":[ | ||||||
|  |                             { | ||||||
|  |                              "height":16, | ||||||
|  |                              "id":2, | ||||||
|  |                              "name":"", | ||||||
|  |                              "rotation":0, | ||||||
|  |                              "type":"", | ||||||
|  |                              "visible":true, | ||||||
|  |                              "width":0, | ||||||
|  |                              "x":16, | ||||||
|  |                              "y":0 | ||||||
|  |                             }], | ||||||
|  |                      "opacity":1, | ||||||
|  |                      "type":"objectgroup", | ||||||
|  |                      "visible":true, | ||||||
|  |                      "x":0, | ||||||
|  |                      "y":0 | ||||||
|  |                     } | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "animation":[ | ||||||
|  |                         { | ||||||
|  |                          "duration":250, | ||||||
|  |                          "tileid":775 | ||||||
|  |                         },  | ||||||
|  |                         { | ||||||
|  |                          "duration":250, | ||||||
|  |                          "tileid":776 | ||||||
|  |                         },  | ||||||
|  |                         { | ||||||
|  |                          "duration":250, | ||||||
|  |                          "tileid":777 | ||||||
|  |                         },  | ||||||
|  |                         { | ||||||
|  |                          "duration":250, | ||||||
|  |                          "tileid":778 | ||||||
|  |                         }], | ||||||
|  |                  "id":778 | ||||||
|  |                 },  | ||||||
|  |                 { | ||||||
|  |                  "animation":[ | ||||||
|  |                         { | ||||||
|  |                          "duration":250, | ||||||
|  |                          "tileid":816 | ||||||
|  |                         },  | ||||||
|  |                         { | ||||||
|  |                          "duration":250, | ||||||
|  |                          "tileid":817 | ||||||
|  |                         },  | ||||||
|  |                         { | ||||||
|  |                          "duration":250, | ||||||
|  |                          "tileid":818 | ||||||
|  |                         },  | ||||||
|  |                         { | ||||||
|  |                          "duration":250, | ||||||
|  |                          "tileid":819 | ||||||
|  |                         }], | ||||||
|  |                  "id":819 | ||||||
|  |                 }], | ||||||
|  |          "tilewidth":16 | ||||||
|  |         }], | ||||||
|  |  "tilewidth":16, | ||||||
|  |  "type":"map", | ||||||
|  |  "version":1.2, | ||||||
|  |  "width":20 | ||||||
|  | } | ||||||
| @ -0,0 +1,4 @@ | |||||||
|  | (ns topdown2d.dom) | ||||||
|  | 
 | ||||||
|  | (defn by-id [id] | ||||||
|  |   (.getElementById js/document id)) | ||||||
| @ -0,0 +1,82 @@ | |||||||
|  | (ns topdown2d.tileset | ||||||
|  |   (:require [topdown2d.collision :as coll])) | ||||||
|  | 
 | ||||||
|  | (def ^:dynamic tileset) | ||||||
|  | 
 | ||||||
|  | (defn next-animation-cycle [animation curr-cycle] | ||||||
|  |   (let [curr-ix (.indexOf animation curr-cycle) | ||||||
|  |         next-ix (inc curr-ix) | ||||||
|  |         next-ix (if (> next-ix (count animation)) | ||||||
|  |                   0 next-ix)] | ||||||
|  |     (nth animation next-ix))) | ||||||
|  | 
 | ||||||
|  | (defn map-def->tileset [map-def tileset-id] | ||||||
|  |   (->> (:tilesets map-def) | ||||||
|  |        (filter #(= (name tileset-id) (:name %))) | ||||||
|  |        first)) | ||||||
|  | 
 | ||||||
|  | (defn tick-animation [tileset-def anim-def now] | ||||||
|  |   (let [map-def (:def tileset-def) | ||||||
|  |         {:keys [ids last-cycle curr-id tileset]} anim-def | ||||||
|  |         animation (->> (map-def->tileset map-def tileset) | ||||||
|  |                        :tiles | ||||||
|  |                        (filter #(= curr-id (:id %))) | ||||||
|  |                        first | ||||||
|  |                        :animation) | ||||||
|  |         curr-cycle (filter #(= curr-id (:tileid %)) animation) | ||||||
|  |         trigger-cycle? (> (- now last-cycle) | ||||||
|  |                           (:duration curr-cycle)) | ||||||
|  |         next-cycle (and trigger-cycle? | ||||||
|  |                         (next-animation-cycle animation curr-cycle))] | ||||||
|  |     (if trigger-cycle? | ||||||
|  |       (assoc anim-def | ||||||
|  |              :last-cycle now | ||||||
|  |              :curr-id (:tileid next-cycle)) | ||||||
|  |       anim-def))) | ||||||
|  | 
 | ||||||
|  | (defn ix->coords [ix width height] | ||||||
|  |   (let [x (rem ix width)] | ||||||
|  |     [(dec x) | ||||||
|  |      (/ (- ix x) width)])) | ||||||
|  | 
 | ||||||
|  | (defn layer->dest [layer tileset data] | ||||||
|  |   (map-indexed | ||||||
|  |    (fn [ix tile] | ||||||
|  |      (let [{:keys [width height]} layer | ||||||
|  |            [dxc dyc] (ix->coords ix width height) | ||||||
|  |            {:keys [tilewidth tileheight]} tileset] | ||||||
|  |        {:tile tile | ||||||
|  |         :x (* dxc tilewidth) | ||||||
|  |         :y (* dyc tileheight) | ||||||
|  |         :w tilewidth | ||||||
|  |         :h tileheight})) | ||||||
|  |    data)) | ||||||
|  | 
 | ||||||
|  | (defn draw-tile [ctx tileset image tileid dest] | ||||||
|  |   (let [{:keys [tileheight tilewidth | ||||||
|  |                 tiles-x tiles-y]} tileset | ||||||
|  |         [x y] (ix->coords tileid tiles-x tiles-y) | ||||||
|  |         sx (* x tilewidth) | ||||||
|  |         sy (* y tileheight)] | ||||||
|  |     (.drawImage ctx image | ||||||
|  |                 sx sy tilewidth tileheight | ||||||
|  |                 (:x dest) (:y dest) | ||||||
|  |                 tilewidth tileheight))) | ||||||
|  | 
 | ||||||
|  | (defn draw-viewport [map-def ctx viewport] | ||||||
|  |   (let [{:keys [images def]} map-def | ||||||
|  |         {:keys [tileheight tilewidth | ||||||
|  |                 height width layers]} def | ||||||
|  |         tileset-id (:tileset viewport) | ||||||
|  |         image (tileset-id images) | ||||||
|  |         tileset (map-def->tileset def (:tileset viewport))] | ||||||
|  |     (doseq [layer layers | ||||||
|  |             :let [destinations (->> (:data layer) | ||||||
|  |                                     (layer->dest layer tileset) | ||||||
|  |                                     (filter #(not= 0 (:tile %))))]] | ||||||
|  |       (doseq [dest destinations | ||||||
|  |               :let [dx (- (:x dest) (:x viewport)) | ||||||
|  |                     dy (- (:y dest) (:y viewport))]] | ||||||
|  |         (draw-tile ctx tileset image | ||||||
|  |                    (:tile dest) | ||||||
|  |                    {:x dx :y dy}))))) | ||||||
					Loading…
					
					
				
		Reference in New Issue
	
	 Josha von Gizycki
						Josha von Gizycki