{"id":31,"date":"2021-10-14T21:25:54","date_gmt":"2021-10-14T21:25:54","guid":{"rendered":"https:\/\/blogs.oregonstate.edu\/selfisnotdefined\/?p=31"},"modified":"2021-10-14T21:25:54","modified_gmt":"2021-10-14T21:25:54","slug":"now-we-can-start-coding","status":"publish","type":"post","link":"https:\/\/blogs.oregonstate.edu\/selfisnotdefined\/2021\/10\/14\/now-we-can-start-coding\/","title":{"rendered":"Now we can start coding"},"content":{"rendered":"\n<p>There are lots of helpful <a rel=\"noreferrer noopener\" href=\"https:\/\/phaser.io\/news\/category\/tutorial\" target=\"_blank\">tutorials<\/a> and <a rel=\"noreferrer noopener\" href=\"https:\/\/phaser.io\/examples\" target=\"_blank\">example files<\/a> for Phaser 3.\u00a0 Since I had never worked with this game framework before, the first thing I wanted to do was to see if I could get one of the example games working on my local computer.\u00a0 But, these files are not quite plug-and-play.\u00a0 I needed to make a web server first.<\/p>\n\n\n\n<p>By remembering what I learned from my web development class, I wrote a simple server.js file like so:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"776\" height=\"352\" src=\"https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/4705\/files\/2021\/10\/server-code-img.png\" alt=\"server.js image\" class=\"wp-image-32\" srcset=\"https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/4705\/files\/2021\/10\/server-code-img.png 776w, https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/4705\/files\/2021\/10\/server-code-img-300x136.png 300w, https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/4705\/files\/2021\/10\/server-code-img-768x348.png 768w\" sizes=\"auto, (max-width: 776px) 100vw, 776px\" \/><figcaption>A simple web server using Node.js and Express<\/figcaption><\/figure>\n\n\n\n<p>Then I added the example files, made double sure that the file paths pointed to the correct locations, ran the server with Node.js, and <em>voila<\/em>!\u00a0 It worked.\u00a0 I had seen the inner workings of an example game and proved that I had everything I needed to run it locally.\u00a0 I could now move on to the specifics of our own game.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">First try at map-making<\/h2>\n\n\n\n<p>One of my main tasks in the group is to create the maps for each level of the game.\u00a0 At this point, we still hadn\u2019t decided on a specific art style.\u00a0 So, I browsed <a rel=\"noreferrer noopener\" href=\"https:\/\/opengameart.org\/\" target=\"_blank\">OpenGameArt<\/a> for the best looking tile set and settled on <a rel=\"noreferrer noopener\" href=\"https:\/\/opengameart.org\/content\/tiled-terrains\" target=\"_blank\">this one<\/a>, which is from an open-source art competition called the <a rel=\"noreferrer noopener\" href=\"https:\/\/lpc.opengameart.org\/\" target=\"_blank\">Liberated Pixel Cup<\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/4705\/files\/2021\/10\/terrain-1024x1024.png\" alt=\"LPC_terrain\" class=\"wp-image-33\" srcset=\"https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/4705\/files\/2021\/10\/terrain.png 1024w, https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/4705\/files\/2021\/10\/terrain-300x300.png 300w, https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/4705\/files\/2021\/10\/terrain-150x150.png 150w, https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/4705\/files\/2021\/10\/terrain-768x768.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>Terrain tile set created for the LPC.  Attribution found <a rel=\"noreferrer noopener\" href=\"https:\/\/opengameart.org\/content\/tiled-terrains\" target=\"_blank\">here<\/a>.<\/figcaption><\/figure>\n\n\n\n<p>I imported the tile set into <a rel=\"noreferrer noopener\" href=\"https:\/\/www.mapeditor.org\/\" target=\"_blank\">Tiled <\/a>(a free open-source map editor with a <a rel=\"noreferrer noopener\" href=\"https:\/\/gamefromscratch.com\/tiled-map-editor-tutorial-series\/\" target=\"_blank\">great tutorial series here<\/a>) and created a draft of the first map.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"780\" src=\"https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/4705\/files\/2021\/10\/level01-draft1-1024x780.png\" alt=\"level01-v1\" class=\"wp-image-34\" srcset=\"https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/4705\/files\/2021\/10\/level01-draft1-1024x780.png 1024w, https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/4705\/files\/2021\/10\/level01-draft1-300x228.png 300w, https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/4705\/files\/2021\/10\/level01-draft1-768x585.png 768w, https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/4705\/files\/2021\/10\/level01-draft1-1536x1169.png 1536w, https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/4705\/files\/2021\/10\/level01-draft1.png 1617w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>My first draft of the first level of our tower defense game.<\/figcaption><\/figure>\n\n\n\n<p>In this level, enemies march in from the right towards the tower, which will sit in the dirt clearing on the left side.\u00a0 They can choose either the high road or low road, but they must stay on the path.\u00a0 Players can place turrets in any open field.\u00a0 I left some empty space on the right side so that UI elements can appear there in a vertical strip.\u00a0 A couple small elements like health and money indicators can sit in the top-left corner too.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Some things to figure out<\/h2>\n\n\n\n<p>Before I go any further with this map, I\u2019ll need to discuss some things with my group.\u00a0 One big concern is figuring out the right resolution and aspect ratio.\u00a0 I had to start somewhere to get some practice with the Tiled software, so for this map I chose the following dimensions:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Tile size:<\/strong> 32&#215;32 pixels<\/li><li><strong>Map size:<\/strong> 800&#215;608 pixels or 25&#215;19 tiles<\/li><li><strong>Aspect ratio:<\/strong> roughly 4:3<\/li><\/ul>\n\n\n\n<p>It isn\u2019t too difficult to change the map at this point, but it\u2019ll be harder once things like collision boundaries are coded in.\u00a0 We\u2019ll also have to agree on where exactly UI elements will appear, so that enemies and turrets don\u2019t get lost behind a button.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are lots of helpful tutorials and example files for Phaser 3.\u00a0 Since I had never worked with this game framework before, the first thing I wanted to do was to see if I could get one of the example games working on my local computer.\u00a0 But, these files are not quite plug-and-play.\u00a0 I needed &hellip; <a href=\"https:\/\/blogs.oregonstate.edu\/selfisnotdefined\/2021\/10\/14\/now-we-can-start-coding\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Now we can start coding<\/span><\/a><\/p>\n","protected":false},"author":11576,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-31","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.oregonstate.edu\/selfisnotdefined\/wp-json\/wp\/v2\/posts\/31","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.oregonstate.edu\/selfisnotdefined\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.oregonstate.edu\/selfisnotdefined\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/selfisnotdefined\/wp-json\/wp\/v2\/users\/11576"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/selfisnotdefined\/wp-json\/wp\/v2\/comments?post=31"}],"version-history":[{"count":1,"href":"https:\/\/blogs.oregonstate.edu\/selfisnotdefined\/wp-json\/wp\/v2\/posts\/31\/revisions"}],"predecessor-version":[{"id":35,"href":"https:\/\/blogs.oregonstate.edu\/selfisnotdefined\/wp-json\/wp\/v2\/posts\/31\/revisions\/35"}],"wp:attachment":[{"href":"https:\/\/blogs.oregonstate.edu\/selfisnotdefined\/wp-json\/wp\/v2\/media?parent=31"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/selfisnotdefined\/wp-json\/wp\/v2\/categories?post=31"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/selfisnotdefined\/wp-json\/wp\/v2\/tags?post=31"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}