{"id":186,"date":"2013-02-17T16:42:06","date_gmt":"2013-02-17T15:42:06","guid":{"rendered":"http:\/\/www.radicalfishgames.com\/?p=186"},"modified":"2013-03-19T12:25:38","modified_gmt":"2013-03-19T11:25:38","slug":"weekly-update-5-path-finding-and-gameaddons","status":"publish","type":"post","link":"https:\/\/www.radicalfishgames.com\/?p=186","title":{"rendered":"Weekly Update #5 &#8211; Path Finding and GameAddons"},"content":{"rendered":"<p>We had a fairly productive week this time! Here a short list of things we did:<\/p>\n<ul>\n<li>Last polishments on GUI system with respect to mouse and gamepad input. Works fairly well now.<\/li>\n<li>Slightly improved controls of player &#8211; there are now less movement delays when switching in and out of aiming mode<\/li>\n<li>Continued working on <b>path finding<\/b><\/li>\n<li>We refactored our game code to use <b>GameAddons<\/b> to extend the engine without hacking main.js too much.<\/li>\n<li>Some concept arts for future characters &#8211; just the faces though<\/li>\n<li>First steps toward a saving and loading the game state using local storage<\/li>\n<\/ul>\n<p>A few details:<\/p>\n<h2>Path Finding<\/h2>\n<p>We managed to create the structure required to perform path finding search based on A*.<br \/>\nThe Path Finding does not simply operate on a tile basis, as this would be too much of an overhead for this type of game.<br \/>\nHowever, we still use a tile map to create the way point structure of the map.<\/p>\n<p>So for instance, for the following map&#8230;<\/p>\n<p><a href=\"http:\/\/www.radicalfishgames.com\/wp-content\/uploads\/path-finding-1.png\"><img decoding=\"async\" src=\"http:\/\/www.radicalfishgames.com\/wp-content\/uploads\/path-finding-1-300x200.png\" alt=\"path-finding-1\" width=\"300\" height=\"200\" class=\"aligncenter size-medium wp-image-191\" srcset=\"https:\/\/www.radicalfishgames.com\/wp-content\/uploads\/path-finding-1-300x200.png 300w, https:\/\/www.radicalfishgames.com\/wp-content\/uploads\/path-finding-1-450x300.png 450w, https:\/\/www.radicalfishgames.com\/wp-content\/uploads\/path-finding-1.png 960w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>..we&#8217;ll create this tile structure:<\/p>\n<p><a href=\"http:\/\/www.radicalfishgames.com\/wp-content\/uploads\/path-finding-2.png\"><img decoding=\"async\" src=\"http:\/\/www.radicalfishgames.com\/wp-content\/uploads\/path-finding-2-300x200.png\" alt=\"path-finding-2\" width=\"300\" height=\"200\" class=\"aligncenter size-medium wp-image-192\" srcset=\"https:\/\/www.radicalfishgames.com\/wp-content\/uploads\/path-finding-2-300x200.png 300w, https:\/\/www.radicalfishgames.com\/wp-content\/uploads\/path-finding-2-450x300.png 450w, https:\/\/www.radicalfishgames.com\/wp-content\/uploads\/path-finding-2.png 960w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Each colored regions is a (more or less concave) area. Adjacent areas are connected. Areas without colors are not covered by the way-point-map. The arrows (lower part of the map) connect to way points of the upper layer.<\/p>\n<p>When the map is loaded in the game, the tile map of the way points is <i>compiled<\/i> into a more simplified structure. Here, we simply connect each colored area with it&#8217;s neighbors, but also keep the precise edges on where the regions connect. Here a visualization of the final structure<\/p>\n<p><a href=\"http:\/\/www.radicalfishgames.com\/wp-content\/uploads\/path-finding-3.png\"><img decoding=\"async\" src=\"http:\/\/www.radicalfishgames.com\/wp-content\/uploads\/path-finding-3-300x200.png\" alt=\"path-finding-3\" width=\"300\" height=\"200\" class=\"aligncenter size-medium wp-image-193\" srcset=\"https:\/\/www.radicalfishgames.com\/wp-content\/uploads\/path-finding-3-300x200.png 300w, https:\/\/www.radicalfishgames.com\/wp-content\/uploads\/path-finding-3-450x300.png 450w, https:\/\/www.radicalfishgames.com\/wp-content\/uploads\/path-finding-3.png 960w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>On that structure, we plan to run the A* algorithm. And that&#8217;s the next step!<\/p>\n<h2>GameAddons<\/h2>\n<p>Now the following is mostly interesting for people familiar with impact.js<\/p>\n<p>As you might know, impact.js is designed fairly low-level and encourages extending the engine by simply overloading and extending methods of the game object, e.g. update() or draw(). So far, we did exactly that. On the other hand, we have started structuring our game code into something we call <i>features<\/i>. Features are implemented in seperat folders, extending the game with additional entities or singleton objects. The idea is: you can simply add or remove a feature by linking it with the game (via requires()). However, whenever the feature had to change something inside the game loop, we still had to hack the main.js in our game, calling functions of global features objects etc. So you could not simply add\/remove a feature, you often had to modify main.js as well. The <i>plug &#038; play<\/i> idea didn&#8217;t really work perfectly.<\/p>\n<p>Now we solved this issue by implementing GameAddons. Features can now provide a GameAddon, which is automatically connected to the game and called on different points of the game loop (e.g. preUpdate, postUpdate, preDraw or postDraw) and only if required. With this, we finally get our <i>plug &#038; play features<\/i>, that simply work on connection without any further coding.<\/p>\n<p><strong>If you are further interested in any of the implemented features, write a comment or mail and we might tell you more about it.<\/strong><\/p>\n<p>That&#8217;s all for now.<br \/>\nUntil next week!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We had a fairly productive week this time! Here a short list of things we did: Last polishments on GUI system with respect to mouse and gamepad input. Works fairly well now. Slightly improved controls of player &#8211; there are now less movement delays when switching in and out of aiming mode Continued working on [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,7],"tags":[],"class_list":["post-186","post","type-post","status-publish","format-standard","hentry","category-crosscode","category-weekly"],"_links":{"self":[{"href":"https:\/\/www.radicalfishgames.com\/index.php?rest_route=\/wp\/v2\/posts\/186","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.radicalfishgames.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.radicalfishgames.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.radicalfishgames.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.radicalfishgames.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=186"}],"version-history":[{"count":13,"href":"https:\/\/www.radicalfishgames.com\/index.php?rest_route=\/wp\/v2\/posts\/186\/revisions"}],"predecessor-version":[{"id":353,"href":"https:\/\/www.radicalfishgames.com\/index.php?rest_route=\/wp\/v2\/posts\/186\/revisions\/353"}],"wp:attachment":[{"href":"https:\/\/www.radicalfishgames.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=186"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.radicalfishgames.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=186"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.radicalfishgames.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=186"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}