{"author_link":"\/users\/hexkritor","author_name":"hexkritor","author_uid":"hexkritor","comments":[],"epoch":1534861859,"event":"LD42","format":"md","ldjam_node_id":117471,"likes":1,"metadata":{"p_key":"120944","p_author":"hexkritor","p_authorkey":"1105197","p_urlkey":"336979","p_title":"Development secrets in Alchemist Dungeon. Building walls","p_cat":"LDJam ","p_event":"LD42","p_time":"1534861859","p_likes":"1","p_comments":"0","p_status":"WAYBACK","us_key":"1105197","us_name":"hexkritor","us_username":"hexkritor","event_start":"1533859200","event_key":"73","event_name":"LD 42"},"node":{"_collation":{"body_sanitizer":"TextUtils::SanitizeHTML via existing importer","event":"LD42","removed_author":false},"_superparent":97793,"_trust":7,"author":105197,"body":"In this post I'll explain how the walls made in this game\n\nThe problem that I encountered is drawing the correct wall sprite depending on the neighboring walls cause of many variations of it. So how to avoid lots of these checks in code? Bits. Let's explain this one\n\n![Random Bits.png](\/\/\/raw\/dea\/91\/z\/1a5a2.png)\n\nLet's suppose we have to choose correct sprite in red-squared tile. At the beginning, we look at the state of neighbors (wall or not) and mark it as 1 or 0 as a bit. After that, we combine all bits to one number from top neighbor in clockwise direction. In this example it will be 01000000b = 64. The found number is a ID for sprite that we need to draw\n\n### Pluses \n\n+ constant time to find the correct sprite\n+ easy to debug\n+ easy to implement\n\n### Minuses\n\n- need a 256 sprite sheet\n- sprite repeating\n\nTest this algorithm here: https:\/\/ldjam.com\/events\/ludum-dare\/42\/alchemist-dungeon","comments":1,"comments-timestamp":"2018-08-22T04:09:39Z","created":"2018-08-17T15:12:12Z","files":[],"files-timestamp":0,"id":117471,"love":1,"love-timestamp":"2018-08-21T15:23:53Z","meta":[],"modified":"2018-08-22T04:09:39Z","name":"Development secrets in Alchemist Dungeon. Building walls","node-timestamp":"2018-08-21T14:30:59Z","parent":108609,"parents":[1,5,9,97793,108609],"path":"\/events\/ludum-dare\/42\/alchemist-dungeon\/development-secrets-in-alchemist-dungeon-building-walls","published":"2018-08-21T14:30:59Z","scope":"public","slug":"development-secrets-in-alchemist-dungeon-building-walls","subsubtype":"","subtype":"","type":"post","version":353520},"node_metadata":{"n_key":"117471","n_urlkey":"336979","n_parent":"108609","n_path":"\/events\/ludum-dare\/42\/alchemist-dungeon\/development-secrets-in-alchemist-dungeon-building-walls","n_slug":"development-secrets-in-alchemist","n_type":"post","n_subtype":"","n_subsubtype":"","n_author":"105197","n_created":"1534518732","n_modified":"1534910979","n_version":"353520","n_status":"WAYBACK"},"source_url":"https:\/\/ldjam.com\/events\/ludum-dare\/42\/alchemist-dungeon\/development-secrets-in-alchemist-dungeon-building-walls","text":"In this post I'll explain how the walls made in this game\n\nThe problem that I encountered is drawing the correct wall sprite depending on the neighboring walls cause of many variations of it. So how to avoid lots of these checks in code? Bits. Let's explain this one\n\n![Random Bits.png](\/\/\/raw\/dea\/91\/z\/1a5a2.png)\n\nLet's suppose we have to choose correct sprite in red-squared tile. At the beginning, we look at the state of neighbors (wall or not) and mark it as 1 or 0 as a bit. After that, we combine all bits to one number from top neighbor in clockwise direction. In this example it will be 01000000b = 64. The found number is a ID for sprite that we need to draw\n\n### Pluses \n\n+ constant time to find the correct sprite\n+ easy to debug\n+ easy to implement\n\n### Minuses\n\n- need a 256 sprite sheet\n- sprite repeating\n\nTest this algorithm here: https:\/\/ldjam.com\/events\/ludum-dare\/42\/alchemist-dungeon","title":"Development secrets in Alchemist Dungeon. Building walls","wayback_source":[]}