{"id":15179,"date":"2020-07-01T05:03:45","date_gmt":"2020-07-01T05:03:45","guid":{"rendered":"https:\/\/www.7generationgames.com\/game_design\/?page_id=15179"},"modified":"2022-09-14T16:58:36","modified_gmt":"2022-09-14T16:58:36","slug":"time-to-code","status":"publish","type":"page","link":"https:\/\/www.7generationgames.com\/game_design\/time-to-code\/","title":{"rendered":"8. Time to code"},"content":{"rendered":"\n<p>If you&#8217;ve been following along, you&#8217;ve learned about <a href=\"https:\/\/www.7generationgames.com\/game_design\/lesson-testing\/\" data-type=\"URL\" data-id=\"https:\/\/www.7generationgames.com\/game_design\/lesson-testing\/\">game testers<\/a> and  <a href=\"https:\/\/www.7generationgames.com\/game_design\/3-becoming-a-designer\/\">designers<\/a> and  <a href=\"https:\/\/www.7generationgames.com\/game_design\/team-lesson-5\/\" data-type=\"URL\" data-id=\"https:\/\/www.7generationgames.com\/game_design\/team-lesson-5\/\">project managers<\/a> and the <a href=\"https:\/\/www.7generationgames.com\/game_design\/4-creative-director\/\" data-type=\"URL\" data-id=\"https:\/\/www.7generationgames.com\/game_design\/4-creative-director\/\">creative director<\/a>.<\/p>\n\n\n\n<p>You&#8217;ve met the audio engineer and artists\/ animators.<\/p>\n\n\n\n<p class=\"has-cyan-bluish-gray-background-color has-background\" style=\"background-color:#ecf4f9\"><em>Now it&#8217;s time for my favorite people on the team because that includes me &#8211; the developers! (I have just been informed by Maria that I am not allowed to have favorite people on the team just like I am not allowed to have favorite children. Also, if it was allowed my favorite person would be her. I take it back. You are all my favorite.)<\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">A developer&#8217;s first job in game design<\/h2>\n\n\n\n<p>You might think the first job in game design is doing some code like this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>var <em>audio <\/em><\/strong>= <strong>new <em>Audio<\/em><\/strong>(<strong>''<\/strong>);\n<strong>function <\/strong><em>playAudio<\/em>(scene) {\n    <strong>var <\/strong>rootURL = homeDirectory();\n    <strong>var <\/strong>src = rootURL + <strong>\"sounds\/\" <\/strong>+ scene + <strong>\".mp3\"<\/strong>;\n    <strong><em>audio<\/em><\/strong>.src = src\n    <strong><em>audio<\/em><\/strong>.play();\n    <strong>return new <em>Promise<\/em><\/strong>(<strong>function<\/strong>(resolve){\n        <strong><em>audio<\/em><\/strong>.onended = resolve\n    }); <em>\/\/return a promise for when audio finishes\n<\/em>}<\/pre>\n\n\n\n<p>Actually, it&#8217;s quite the opposite. Read on.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">If you don&#8217;t want to make yourself crazy, here&#8217;s your first step.<\/h3>\n\n\n\n<div class=\"wp-block-media-text alignwide has-background\" style=\"background-color:#ecf4f9;grid-template-columns:26% auto\"><figure class=\"wp-block-media-text__media\"><img decoding=\"async\" src=\"https:\/\/www.7generationgames.com\/7gen\/wp-content\/uploads\/2020\/06\/jose-emotion-think-567x1024.png\" alt=\"\" class=\"wp-image-21712 size-full\"\/><\/figure><div class=\"wp-block-media-text__content\">\n<p class=\"has-large-font-size\">Think.<\/p>\n\n\n\n<p><br>You don&#8217;t sit down and start writing code, if you are smart. <br><br>The first step is to <em>think<\/em>.<\/p>\n\n\n\n<p>You come up with a file structure.<\/p>\n\n\n\n<p>Once that is done, you sketch out your idea, which is sort of like a &#8220;road map&#8221; to guide you in your project. That way you know where you are going. <br><br>You can literally sketch it, like a flow chart, or you can write what&#8217;s called &#8220;pseudo code.&#8221; <\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Setting up your file structure<\/h3>\n\n\n\n<p>Think about it &#8211; even a fairly simple game may end up having thousands of files! <br>Every character probably has a front view,  a back view,  a side view.  There are arrows and hint buttons to map out. Every single scene has a background &#8211; and that&#8217;s just the beginning of the art plan! You still have sound, scripts to control movies, or different parts of the game to plan and sketch out.<\/p>\n\n\n\n<p>This might sound complicated, so maybe this picture from a candy store will help. Or, maybe it will just make you hungry.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.7generationgames.com\/7gen\/wp-content\/uploads\/2020\/06\/candy_store.png\" alt=\"Candy store shelves organized by your type of candy. \" class=\"wp-image-21711\" width=\"480\" height=\"427\"\/><figcaption>Candy organized by type<\/figcaption><\/figure><\/div>\n\n\n\n<p>Okay, so this candy store organized their items in a specific way, with popcorn on the bottom shelf, gummy candies on the next shelf, then candy bars. <br>The top two shelves are boxes of chocolate and teddy bears; stuff you might give as a gift. <\/p>\n\n\n\n<p>When I start on a new game, the first thing I do is set up the project by creating all the folders I&#8217;ll need. These include art, movies, sound and scripts. I do this because it&#8217;s easy to waste HOURS looking for a file if you haven&#8217;t set up your file structure right from the beginning. It&#8217;s best to stay organized from the very beginning.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">ASSIGNMENT 1: Students will create a file structure<\/h2>\n\n\n\n<p>All the software developers I know use some kind of <em>integrated development environment<\/em> (IDE). An IDE allows you to edit and debug source code. Setting up a new project, I open an IDE and create the folders I need.<\/p>\n\n\n\n<ul><li>We&#8217;ll look briefly at two IDEs (WebStorms and Dreamweaver) <\/li><li>With help from the instructor, students will create a file structure. <\/li><li>We&#8217;ll then take a look at the actual file structure for some 7 Generation Games apps.<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">ASSIGNMENT 2: Think like a developer<\/h2>\n\n\n\n<p>If you wanted to go on a trip, you wouldn&#8217;t start by just driving as fast as you can in a random direction. Even if I knew which direction I wanted to go, say, I wanted to go from California to Wyoming, I wouldn&#8217;t just hop in a car and head east.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img decoding=\"async\" src=\"https:\/\/www.7generationgames.com\/7gen\/wp-content\/uploads\/2020\/06\/aunt_map.jpg\" alt=\"Woman reading a map\" class=\"wp-image-21714\"\/><figcaption>You need a map to know where you are going.<\/figcaption><\/figure><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Creating a &#8220;road map&#8221; for your design<\/h3>\n\n\n\n<p>Before you start writing a program, you need a map. Sometimes, I draw it out. This can be like the picture we saw in the class on being a designer. <br><br>It can be a flow chart, where you draw each part of it. <br><br>It can be a diagram like this:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.7generationgames.com\/7gen\/wp-content\/uploads\/2020\/06\/function_architecture.jpg\" alt=\"Aunt from Forgotten Trail holding a map\" class=\"wp-image-21713\" width=\"853\" height=\"569\"\/><figcaption>This diagram shows all of the major parts of Crossroads.<\/figcaption><\/figure><\/div>\n\n\n\n<p>That&#8217;s the easy part of finding your way. You get on the highway and there are all kinds of signs saying, &#8220;Minneapolis, this way.&#8221; There aren&#8217;t signs to &#8220;Eva&#8217;s house,&#8221; though. Not yet, at least.<\/p>\n\n\n\n<p>A flow chart or diagram shows all the major parts you need to make. It&#8217;s like a map of getting to the city.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Pseudo code for the details<\/h3>\n\n\n\n<p>Personally, I don&#8217;t flow chart a lot, which isn&#8217;t to say you can&#8217;t. <br><br>Instead, I write a lot of pseudo code as my &#8220;map.&#8221; <br><br>This is just a fancy way for saying, &#8220;Write down what the programming statements should do.&#8221;<br><\/p>\n\n\n\n<p class=\"has-background\" style=\"background-color:#ecf4f9\"><strong>Example of pseudo code for a search-and-find game:<\/strong><\/p>\n\n\n\n<ul><li>Decide on the number of items to be found, to the number of items that should exist on the screen.<\/li><li>When the &#8220;Hint&#8221; button is clicked, display of a list of items remaining to be found.<\/li><li>Close the item list when a red X in the corner is clicked.<\/li><li>Randomly put items on the page, some of which can appear behind other items.<\/li><li>When an item is clicked, do this: Subtract 1 from the total number of items to be found, remove the item from the list of items remaining, check to see if the number of items to be found = 0. If it does, my code will execute the &#8220;Win&#8221; function to indicate to the player that they have won the game.<\/li><li>&#8220;Win&#8221; function: A victory sound plays when the remaining items = 0. Winning screen is shown with dancing hamsters alongside with the text, &#8220;YOU WON!&#8221; <\/li><\/ul>\n\n\n\n<p>As you can see, some elements of my pseudo code involved planning, logic, and even some basic math. And why include the dancing hamsters? Because code makes it possible<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Assignment 3:  Students write their own pseudo code<\/h2>\n\n\n\n<p>Students will write their own pseudo code using one part of their own game design they&#8217;ve been working on in the course.<\/p>\n\n\n\n<h3 class=\"has-text-align-center\"><a href=\"http:\/\/www.7generationgames.com\/game_design\/game-sounds\/\">Go back to Level 7<\/a> <\/h3>\n","protected":false},"excerpt":{"rendered":"<p>If you&#8217;ve been following along, you&#8217;ve learned about game testers and designers and project managers and the creative director. You&#8217;ve met the audio engineer and artists\/ animators. Now it&#8217;s time<\/p>\n","protected":false},"author":11,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/www.7generationgames.com\/game_design\/wp-json\/wp\/v2\/pages\/15179"}],"collection":[{"href":"https:\/\/www.7generationgames.com\/game_design\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.7generationgames.com\/game_design\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.7generationgames.com\/game_design\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/www.7generationgames.com\/game_design\/wp-json\/wp\/v2\/comments?post=15179"}],"version-history":[{"count":3,"href":"https:\/\/www.7generationgames.com\/game_design\/wp-json\/wp\/v2\/pages\/15179\/revisions"}],"predecessor-version":[{"id":15388,"href":"https:\/\/www.7generationgames.com\/game_design\/wp-json\/wp\/v2\/pages\/15179\/revisions\/15388"}],"wp:attachment":[{"href":"https:\/\/www.7generationgames.com\/game_design\/wp-json\/wp\/v2\/media?parent=15179"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}