{"author_link":"\/users\/hexkritor","author_name":"hexkritor","author_uid":"hexkritor","comments":[],"epoch":1534526063,"event":"LD42","format":"md","ldjam_node_id":117365,"likes":4,"metadata":{"p_key":"120874","p_author":"hexkritor","p_authorkey":"1105197","p_urlkey":"336909","p_title":"Development secrets in Alchemist Dungeon. Minimap","p_cat":"LDJam ","p_event":"LD42","p_time":"1534526063","p_likes":"4","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":"This post inspired by @noah-beckman question about how made the minimap in this game\n\nSo, let's start answering\n\nFirst of all, the game zone is the matrix of tiles [N+2,N+2], where N - is dungeon size, so it makes easier to create level map. After the generation of dungeon I use loop [0..N+1,0..N+1] to create a level texture [N+2,N+2] pixels, which will be used later. Blue pixels shows walls and white - free space. Also I create a black fog of war texture with same size.\n\nNext, the step-by-step explanation of map creation called every frame:\n1. Copy level texture created earlier\n2. Loop [0..N+1,0..N+1] to add info about exit and gas locations\n3. Add the location of the player by transforming the coords with Mathf.Round function\n4. Apply the changes for level texture copy\n5. Loop [0..N+1,0..N+1] and calculate the distance between pixel and player coords. If it less than 5, set current pixel on fog or war texture to blank\n6. Apply the changes for fog of war texture\n7. Create blank texture [N+2,N+2] pixels\n8. Loop [0..N+1,0..N+1] to fill created texture with combinig info of two previous textures. If fog of war pixel is black, add the black pixel, otherwise add the pixel from level with objects texture\n9. Apply changes and transform to sprite\n10. Show the sprite in UI\n\nThe image below represents how it works in game:\n\n![3ee941c2c5b53bed866f6c1341488d2b_new.gif](\/\/\/raw\/dea\/91\/z\/1a216.gif)\n\nIf you want to play the game: https:\/\/ldjam.com\/events\/ludum-dare\/42\/alchemist-dungeon\n\nP.S: if the game got the 50 rating I'll post the explanation of dungeon generation algorithm","comments":0,"created":"2018-08-17T06:06:22Z","files":[],"files-timestamp":0,"id":117365,"love":4,"love-timestamp":"2018-08-25T20:44:01Z","meta":[],"modified":"2018-08-25T20:44:01Z","name":"Development secrets in Alchemist Dungeon. Minimap","node-timestamp":"2018-08-17T17:14:23Z","parent":108609,"parents":[1,5,9,97793,108609],"path":"\/events\/ludum-dare\/42\/alchemist-dungeon\/development-secrets-in-alchemist-dungeon-minimap","published":"2018-08-17T17:14:23Z","scope":"public","slug":"development-secrets-in-alchemist-dungeon-minimap","subsubtype":"","subtype":"","type":"post","version":350900},"node_metadata":{"n_key":"117365","n_urlkey":"336909","n_parent":"108609","n_path":"\/events\/ludum-dare\/42\/alchemist-dungeon\/development-secrets-in-alchemist-dungeon-minimap","n_slug":"development-secrets-in-alchemist","n_type":"post","n_subtype":"","n_subsubtype":"","n_author":"105197","n_created":"1534485982","n_modified":"1535229841","n_version":"350900","n_status":"WAYBACK"},"source_url":"https:\/\/ldjam.com\/events\/ludum-dare\/42\/alchemist-dungeon\/development-secrets-in-alchemist-dungeon-minimap","text":"This post inspired by @noah-beckman question about how made the minimap in this game\n\nSo, let's start answering\n\nFirst of all, the game zone is the matrix of tiles [N+2,N+2], where N - is dungeon size, so it makes easier to create level map. After the generation of dungeon I use loop [0..N+1,0..N+1] to create a level texture [N+2,N+2] pixels, which will be used later. Blue pixels shows walls and white - free space. Also I create a black fog of war texture with same size.\n\nNext, the step-by-step explanation of map creation called every frame:\n1. Copy level texture created earlier\n2. Loop [0..N+1,0..N+1] to add info about exit and gas locations\n3. Add the location of the player by transforming the coords with Mathf.Round function\n4. Apply the changes for level texture copy\n5. Loop [0..N+1,0..N+1] and calculate the distance between pixel and player coords. If it less than 5, set current pixel on fog or war texture to blank\n6. Apply the changes for fog of war texture\n7. Create blank texture [N+2,N+2] pixels\n8. Loop [0..N+1,0..N+1] to fill created texture with combinig info of two previous textures. If fog of war pixel is black, add the black pixel, otherwise add the pixel from level with objects texture\n9. Apply changes and transform to sprite\n10. Show the sprite in UI\n\nThe image below represents how it works in game:\n\n![3ee941c2c5b53bed866f6c1341488d2b_new.gif](\/\/\/raw\/dea\/91\/z\/1a216.gif)\n\nIf you want to play the game: https:\/\/ldjam.com\/events\/ludum-dare\/42\/alchemist-dungeon\n\nP.S: if the game got the 50 rating I'll post the explanation of dungeon generation algorithm","title":"Development secrets in Alchemist Dungeon. Minimap","wayback_source":[]}