{"id":406,"date":"2025-07-08T16:44:44","date_gmt":"2025-07-08T06:44:44","guid":{"rendered":"https:\/\/nonlinearexperience.com\/?p=406"},"modified":"2025-07-27T15:56:14","modified_gmt":"2025-07-27T05:56:14","slug":"maps-and-levels","status":"publish","type":"post","link":"https:\/\/nonlinearexperience.com\/index.php\/2025\/07\/08\/maps-and-levels\/","title":{"rendered":"Maps and levels"},"content":{"rendered":"<h1 class=\"wp-block-post-title\">Maps and levels<\/h1>\n\n\n<p class=\"wp-block-paragraph\">See also: <a href=\"https:\/\/nonlinearexperience.com\/index.php\/2025\/07\/27\/layers\/\" data-type=\"post\" data-id=\"579\">layers<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">System:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">loading\/unloading maps<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Tile Buffer<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/www.youtube.com\/watch?v=XmmvblvSOho\">A More Efficient Tile Map<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A tile buffer &#8211; draw once, reuse many times<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Draw map onto a buffer canvas &#8211; then render the buffer canvas &#8211; and this is what can be animated?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Logical layers<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Tile size<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Map size<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">loading levels and different rooms etc.<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">a 2 way door &#8211; can be lockable &#8211; other properties? destroyable &#8211; changeable (e.g. destination changes)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">predictive loading?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">if player is heading towards a door &#8211; door has a sensor a certain distance away from it that detects approach, and loads into level cache &#8211; would remove whatever is in there<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Multi-rooms<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">An approach &#8211; <a href=\"https:\/\/www.youtube.com\/watch?v=Lcdc2v-9PjA\">Multi-room Platformer Game Tutorial with JavaScript and HTML Canvas<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Collision blocks<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">map-based blocks that players can&#8217;t travel through<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">well, maybe in certain directions &#8211; see: <a href=\"https:\/\/docs.google.com\/document\/d\/1AG3jOFts8Txf6aYTNznSe3lBOa0GsQ8yWp8YigJkfGc\/edit#heading=h.f04m9klz8eoz\">Directional Collisions<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Working with Tiled data<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">creating the map<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">export all the data<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">in the game engine &#8211; for each layer in &#8217;tiled&#8217;, create a 2d array<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">need to know the width of the game in tiles<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h6 class=\"wp-block-heading\"><strong>Change map<\/strong><\/h6>\n\n\n\n<p class=\"wp-block-paragraph\">In <strong>Overworld.js<\/strong>, change map using:&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">{type: &#8220;changeMap&#8221;, map:&#8221;DemoRoom&#8221; }<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">in <strong>OverworldEvent.js<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">changeMap(resolve){<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;this.map.overworld.startMap(window.OverworldMaps[this.event.map]);<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;resolve();<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">}<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">in <strong>Overworld.js<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">startMap(mapConfig){<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;this.map = new OverworldMap(mapConfig);<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;this.map.overworld = this;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;this.map.mountObjects();<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">}<\/p>\n\n\n\n<h6 class=\"wp-block-heading\"><strong>Change map transition<\/strong><\/h6>\n\n\n\n<p class=\"wp-block-paragraph\">Fade to black &#8211; change map &#8211; fade from black<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use iris would be better<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Fade out: black &#8211; 1.2s<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Fade in: black &#8211; 1.2s<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Resources<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>See also: layers System: loading\/unloading maps Tile Buffer A More Efficient Tile Map A tile buffer &#8211; draw once, reuse many times Draw map onto a buffer canvas &#8211; then render the buffer canvas &#8211; and this is what can be animated? Logical layers Tile size Map size loading levels and different rooms etc. a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"wp-custom-template-nlx-the-knowledge-page","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-406","post","type-post","status-publish","format-standard","hentry","category-the-knowledge"],"_links":{"self":[{"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/posts\/406","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/comments?post=406"}],"version-history":[{"count":3,"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/posts\/406\/revisions"}],"predecessor-version":[{"id":582,"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/posts\/406\/revisions\/582"}],"wp:attachment":[{"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/media?parent=406"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/categories?post=406"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/tags?post=406"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}