{"id":58,"date":"2021-11-26T14:00:52","date_gmt":"2021-11-26T14:00:52","guid":{"rendered":"http:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/?p=58"},"modified":"2023-04-06T14:01:01","modified_gmt":"2023-04-06T13:01:01","slug":"week-4-developer-journal","status":"publish","type":"post","link":"https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/2021\/11\/26\/week-4-developer-journal\/","title":{"rendered":"Week 4 &#8211; Developer Journal"},"content":{"rendered":"\n<p>Following up from the Phaser introduction, this week we&#8217;re introduced to Tiled which allows us to import and use &#8217;tilesets&#8217; to put together levels as &#8217;tilemaps&#8217;. The first task being making a nice level to navigate with the supplied tileset, while doing this I experimented a lot with flipping tiles horizontally and vertically to create a lot of variation within the level and a particular favourite touch being pillars in the background.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"458\" src=\"https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-content\/uploads\/2021\/11\/image_2021-11-25_211357-1024x458.png\" alt=\"\" class=\"wp-image-59\" srcset=\"https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-content\/uploads\/2021\/11\/image_2021-11-25_211357-1024x458.png 1024w, https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-content\/uploads\/2021\/11\/image_2021-11-25_211357-300x134.png 300w, https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-content\/uploads\/2021\/11\/image_2021-11-25_211357-768x343.png 768w, https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-content\/uploads\/2021\/11\/image_2021-11-25_211357-1536x687.png 1536w, https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-content\/uploads\/2021\/11\/image_2021-11-25_211357-1568x701.png 1568w, https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-content\/uploads\/2021\/11\/image_2021-11-25_211357.png 1682w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>Tilemap of 5 layers with its contents colour-coded<br>Foreground &#8211; assets that appear in front of the player<br>Platforms &#8211; tiles which the player primarily walks upon<br>ladders &#8211; tiles added with the intent to function as &#8216;ladders&#8217;<br>Props &#8211; assets which the player may collide with<br>midground &#8211; assets behind the player, intent to be decorative<br>background &#8211; the backmost layer which will function as a backdrop for the level.<br><\/figcaption><\/figure>\n\n\n\n<p>When it came to coding, they were a bit of work to set up but they&#8217;re incredibly resourceful for setting up levels and pose as an alternative for adding static objects like collectables and hazards<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-content\/uploads\/2021\/11\/image-2-1024x429.png\" alt=\"\" class=\"wp-image-61\" width=\"610\" height=\"255\" srcset=\"https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-content\/uploads\/2021\/11\/image-2-1024x429.png 1024w, https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-content\/uploads\/2021\/11\/image-2-300x126.png 300w, https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-content\/uploads\/2021\/11\/image-2-768x322.png 768w, https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-content\/uploads\/2021\/11\/image-2.png 1216w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><figcaption>code required for importing the tileset, tilemap and setting up layers.<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"311\" height=\"168\" src=\"https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-content\/uploads\/2021\/11\/TiledLayers-Example.png\" alt=\"\" class=\"wp-image-62\" srcset=\"https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-content\/uploads\/2021\/11\/TiledLayers-Example.png 311w, https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-content\/uploads\/2021\/11\/TiledLayers-Example-300x162.png 300w\" sizes=\"auto, (max-width: 311px) 100vw, 311px\" \/><figcaption>Depths for each layer is also a lot easier to manage.<\/figcaption><\/figure>\n\n\n\n<p>To add some objectives, I&#8217;ve brought in the stars from the previous Phaser project however this time, collecting all the stars will load the next level. To hint that this is the objective, the player is given a remaining stars counter.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"489\" src=\"https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-content\/uploads\/2021\/11\/image-3-1024x489.png\" alt=\"\" class=\"wp-image-66\" srcset=\"https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-content\/uploads\/2021\/11\/image-3-1024x489.png 1024w, https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-content\/uploads\/2021\/11\/image-3-300x143.png 300w, https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-content\/uploads\/2021\/11\/image-3-768x367.png 768w, https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-content\/uploads\/2021\/11\/image-3-1536x733.png 1536w, https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-content\/uploads\/2021\/11\/image-3-1568x748.png 1568w, https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-content\/uploads\/2021\/11\/image-3.png 1810w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>Level Preview (Stars)<\/figcaption><\/figure>\n\n\n\n<p>Developing on top of stars I also tried adding &#8216;upgrades&#8217; the first of which is a white star that spawns randomly among the other stars but when you pick it up, it increases the maximum jumps &#8211; this was the only suitable thing I figured I could really upgrade.<\/p>\n\n\n\n<p>Another benefit is collision events can also be made between specific tileset pieces, so in this case we could make another prop collectable for score much alike the stars.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"508\" height=\"504\" src=\"https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-content\/uploads\/2021\/11\/TiledProps-and-Score.png\" alt=\"\" class=\"wp-image-64\" srcset=\"https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-content\/uploads\/2021\/11\/TiledProps-and-Score.png 508w, https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-content\/uploads\/2021\/11\/TiledProps-and-Score-300x298.png 300w, https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-content\/uploads\/2021\/11\/TiledProps-and-Score-150x150.png 150w\" sizes=\"auto, (max-width: 508px) 100vw, 508px\" \/><figcaption>Collecting the Mushroom tile and score increasing.<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"836\" height=\"158\" src=\"https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-content\/uploads\/2021\/11\/image_2021-11-25_214724.png\" alt=\"\" class=\"wp-image-65\" srcset=\"https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-content\/uploads\/2021\/11\/image_2021-11-25_214724.png 836w, https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-content\/uploads\/2021\/11\/image_2021-11-25_214724-300x57.png 300w, https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-content\/uploads\/2021\/11\/image_2021-11-25_214724-768x145.png 768w\" sizes=\"auto, (max-width: 836px) 100vw, 836px\" \/><figcaption>Collision check, adding score and removing tile function.<\/figcaption><\/figure>\n\n\n\n<p>Another design choice I considered about the floor is a pit, I just wanted there to be a fall rather than tiles or spikes.<br>If the player fall down then they are moved back to the last tile they touched.<br>I initially tried to add this as a collider with the bottom worldbound but I couldn&#8217;t find the right code to work, so instead I built upon what I previous did by adding two new tiles to emulate a shadow that the player could collide with<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1016\" height=\"285\" src=\"https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-content\/uploads\/2021\/11\/image-4.png\" alt=\"\" class=\"wp-image-67\" srcset=\"https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-content\/uploads\/2021\/11\/image-4.png 1016w, https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-content\/uploads\/2021\/11\/image-4-300x84.png 300w, https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-content\/uploads\/2021\/11\/image-4-768x215.png 768w\" sizes=\"auto, (max-width: 1016px) 100vw, 1016px\" \/><figcaption>Callback code<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"620\" height=\"319\" src=\"https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-content\/uploads\/2021\/11\/image-7.png\" alt=\"\" class=\"wp-image-70\" srcset=\"https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-content\/uploads\/2021\/11\/image-7.png 620w, https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-content\/uploads\/2021\/11\/image-7-300x154.png 300w\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" \/><figcaption>Callback in action<\/figcaption><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Following up from the Phaser introduction, this week we&#8217;re introduced to Tiled which allows us to import and use &#8217;tilesets&#8217; to put together levels as &#8217;tilemaps&#8217;. The first task being making a nice level to navigate with the supplied tileset, while doing this I experimented a lot with flipping tiles horizontally and vertically to create&hellip; <a class=\"more-link\" href=\"https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/2021\/11\/26\/week-4-developer-journal\/\">Continue reading <span class=\"screen-reader-text\">Week 4 &#8211; Developer Journal<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[4],"class_list":["post-58","post","type-post","status-publish","format-standard","hentry","category-uncategorised","tag-bsc1a","entry"],"_links":{"self":[{"href":"https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-json\/wp\/v2\/posts\/58","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-json\/wp\/v2\/comments?post=58"}],"version-history":[{"count":2,"href":"https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-json\/wp\/v2\/posts\/58\/revisions"}],"predecessor-version":[{"id":119,"href":"https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-json\/wp\/v2\/posts\/58\/revisions\/119"}],"wp:attachment":[{"href":"https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-json\/wp\/v2\/media?parent=58"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-json\/wp\/v2\/categories?post=58"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lloydmills.nuacomputerscience.co.uk\/blog\/wp-json\/wp\/v2\/tags?post=58"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}