{"componentChunkName":"component---src-templates-legacy-tutorial-page-js","path":"/oa/tutorials/ramp-0/io-api/","result":{"pageContext":{"tutorial":{"id":"T0E6OlR1dG9yaWFsLTE4NQ==","slug":"ramp-0","title":"Ramp","previewText":"Practice coding fundamentals -\nvariables and objects, arrays,\nloops, conditionals, functions,\nand classes - by completing\nprogramming challenges that\nincrease in complexity as you\nbuild up your coding skills.\n","heroImagePath":"https://raw.githubusercontent.com/MakeSchool-Tutorials/Ramp-Level-0/master/cover.png","heroImageFile":{"childImageSharp":{"gatsbyImageData":{"layout":"constrained","placeholder":{"fallback":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAACXBIWXMAAAsTAAALEwEAmpwYAAAD6ElEQVQ4y42RX0xcRRTGLwu+YKxGk1ZD60N3Gl7qCwoxmmqkaGO0aXzQxNYHHzSxPmliNBqNYrVWU+auRYnWSA1SoYFuNPhQ2vLn3pUWUigiKBQKhYXddZe1bFl22b33zvnMzN1rtm2aOMnkzJw553e+c0YDkZZzRAkAuTVB9AkRrViOiIAoBhRvxIgoZjkiCqKkI8SrMgdA6T9ZSyMi7ToYgE+JCAAhmbVRP7iMdwcSeG8ggZe6w9jdNY83jSiylgMSQsUBeKUYqhXDImkLx/5MOQAJgKh/MUN1wUV65MQ83fbVBG1pnqILsYyqmM7ZzuHQHK6tW9dBNQ+2mnew71TUecuMq7JZy1H2YnwdO0+G8UDrNGaurksXcrYg2cmO7wbFC22jcJRaF6pg0TUL+3v/FjXtC/Th+WX5SN/8kUTH9IoChJbWMJbIqnPrZAq/RTIqZk/rCG6vPy1e7hzD1UxeQSUw8svsKh4+sWDVBRfx/rll1dLBC3GUN02gL5yGt7rm0jIOxpILfPbHYdr8RS/uOnAm1z+XlL5+zXKoGsBqy2QKVT/N2x+ccxXqo8vkaxzH5uZJ9ITT6F7IoC4YxmMdYalQFX2mZRgbPj5tdYxHZc5Mat26vzBDF/r12AreMOK2fG0YSVB50wTdc/QvbG+Zws72GezuiuLxjgVygYQnvh+yjo0syvDLa3m7wpthWeFjqgXR6nBczcoOjC6jtHGcqtrm6KnOK9imm6htn6ba4BINqBkKazCsZnw574iKAqPM+2UFJZJKSQ3t0HDC3tJ8Cc/9GqFdJ+eJcYMqdYOqW6bQv5S1CmOdXcs7FcUMzXEcr23lSGYd1f7P7kfZe7oieLLzClUGTNp6uA/3ft5njcbWlLKpZKbiBkGqZQUVQkiHehDCnem34yvY0RG2nw7Oq5Y3HuyxWkeXFOxazlUmcyRIbqVQLnnxoJ5SOVMA6aMTKdQcn7XvO9TrwWZzDv2nzIMpdcXLgxa3AHKVNo4k8MPFiFKWyORvavMmWDHUtm+Agh4CkAJwKWs5/x92C2iptFlbbF3JWpuKfbeEMW74GDel1Rg3S+T9bApa+Ufd2oYDZ3zHf4+U5QsFmgYXyk5NJ7TKgOlTeYEBmVfq50Ypc7fPA8ntY3rIvQeGpC3xc0Or1E2tvnemTHvwiDpv01WiG/fleWX93p0bUqG5l+mhOxVMD93NuPkiOzJUUii0l3HzUVVQD21k3HzeTTZrGTdeY4GBOxg33mHc+IxxQ5e5khpj3GjzN/TJc5BxI+Jv6JGATYW3s37eL+9V8sy4uY9xY4Rxs4bpoe2MG3N+brzu58bbjBu7/gWOSk/VhPcKJgAAAABJRU5ErkJggg=="},"images":{"fallback":{"src":"/mediabook/static/a69ceb219f4e17b4f09e707a84068da8/5aead/cover.png","srcSet":"/mediabook/static/a69ceb219f4e17b4f09e707a84068da8/e9fba/cover.png 50w,\n/mediabook/static/a69ceb219f4e17b4f09e707a84068da8/15e42/cover.png 100w,\n/mediabook/static/a69ceb219f4e17b4f09e707a84068da8/5aead/cover.png 200w,\n/mediabook/static/a69ceb219f4e17b4f09e707a84068da8/d6138/cover.png 400w","sizes":"(min-width: 200px) 200px, 100vw"},"sources":[{"srcSet":"/mediabook/static/a69ceb219f4e17b4f09e707a84068da8/b79cb/cover.avif 50w,\n/mediabook/static/a69ceb219f4e17b4f09e707a84068da8/6d0de/cover.avif 100w,\n/mediabook/static/a69ceb219f4e17b4f09e707a84068da8/f2685/cover.avif 200w,\n/mediabook/static/a69ceb219f4e17b4f09e707a84068da8/4ff31/cover.avif 400w","type":"image/avif","sizes":"(min-width: 200px) 200px, 100vw"},{"srcSet":"/mediabook/static/a69ceb219f4e17b4f09e707a84068da8/dbc4a/cover.webp 50w,\n/mediabook/static/a69ceb219f4e17b4f09e707a84068da8/d8057/cover.webp 100w,\n/mediabook/static/a69ceb219f4e17b4f09e707a84068da8/2e34e/cover.webp 200w,\n/mediabook/static/a69ceb219f4e17b4f09e707a84068da8/416c3/cover.webp 400w","type":"image/webp","sizes":"(min-width: 200px) 200px, 100vw"}]},"width":200,"height":200}}},"pages":{"nodes":[{"id":"T0E6OlBhZ2UtMjQwMw==","title":"Tips For Success","slug":"tips-for-success","sections":{"nodes":[{"id":"T0E6OlNlY3Rpb24tMTIwMDU=","title":"Tips For Success","htmlContent":"<h2>Welcome to Ramp!</h2><p>We are excited to have you in the program and we look forward to helping you <strong>ramp up</strong> your programming skills. :)</p>"},{"id":"T0E6OlNlY3Rpb24tMTIwMDY=","title":"Assignment Formatting","htmlContent":"<p>As you read through the assignments here, you'll see different kinds of formats for drawing your attention to key areas.</p><h3>Learning</h3><p>Along the way, important information will be highlighted in an...</p><div class=\"info\">\n<p>\nInformation box.</p>\n</div><h3>Doing</h3><p>Any time you need to add some code or complete an important step, you'll find it in an...</p><div class=\"action\">\n<p>\nAction box.</p>\n</div><h3>Checking</h3><p>After you've come up with your own answer, you can click to expand the...</p><div class=\"solution\">\n<p>\nSolution box.</p>\n</div><h3>Growing</h3><p>Along the way and at the end of the tutorial, you can push yourself by tackling all of the...</p><div class=\"challenge\">\n<p>\nbonus challenges in boxes like this.</p>\n</div>"},{"id":"T0E6OlNlY3Rpb24tMTIwMDc=","title":"Tips for Success","htmlContent":"<p>How to get familiar with the program structure and get the most out of Ramp.</p><h2>Watch the Videos</h2><p>Each assignment in Ramp starts with a selection of videos from <a href=\"https://www.youtube.com/watch?list=PLRqwX-V7Uu6Zy51Q-x9tMWIv9cueOFTFA&amp;v=8j0UDiN7my4\" target=\"_blank\">The Coding Train's p5.js Tutorial Playlist</a>.</p><p>We strongly recommend watching all of the videos at the top of each assignment to best prepare for completing the code challenges for that assignment.</p><p>The code challenges are designed to allow you to practice and extend your understanding of the concepts covered in the videos. Often, the solution to a code challenge relies upon using the same exact coding technique from one of the videos with a few small changes.</p><div class=\"info\">\n<p>\nNote: Students who choose to tackle the code challenges without watching the videos first may spend time working on solutions that are more complicated than they need to be.</p>\n</div><h2>Use the Walkthrough Guides</h2><p>In each video, there are code examples that you may want to follow along with for greater understanding.</p><p>Under each video in the instructions will be a link to a walkthrough project that you can use to follow along with the video.</p><h2>Skim the Starter Code</h2><p>At the top of each assignment instruction page will be a link for you to access the starter code. Before you start coding, it's always good to look through the project and see how much of it you already understand or to think of questions that you have that might be answered by the assignment.</p><p>Each assignment is set up like a web page, that can use HTML, CSS, and Javascript, with the following files:</p><pre><span class=\"nx\">index</span><span class=\"p\">.</span><span class=\"nx\">html</span> <span class=\"c1\">// HTML file, web page setup (edit carefully!)</span>\n<span class=\"nx\">sketch</span><span class=\"p\">.</span><span class=\"nx\">js</span>  <span class=\"c1\">// JS file, where you will write your code</span>\n<span class=\"nx\">helpers</span><span class=\"p\">.</span><span class=\"nx\">js</span> <span class=\"c1\">// JS file, helper code (DO NOT EDIT)</span>\n</pre><p>The majority of your code will be added to <code>sketch.js</code>.</p><div class=\"info\">\n<p>\nIn some assignments there will be code in a <code>helper.js</code> file that helps make the program more beginner friendly but that you don't need to interact with directly. Feel free to look at the contents, but please <strong>do not</strong> make edits there.</p>\n</div><h2>Read Instructions Carefully</h2><p>Complete all of the challenges in each assignment by <strong>reading the directions carefully</strong> and checking that both your code and the end result meet all of the requirements as given.</p><h2>Use the Documentation</h2><p>All of the assignments in Ramp are written in Javascript (JS) and use the <code>p5.js</code> library, which provides useful code features packaged together for convenient use.</p><p>All of the available <code>p5.js</code> functions and features are described in the documentation at <a href=\"http://p5js.org/reference/\" target=\"_blank\">http://p5js.org/reference/</a>. Click on the name of a function to see examples and explanations of how to use it.</p><p>Check out this <a href=\"https://medium.com/@faith.chikwekwe/how-to-use-documentation-a-review-of-the-p5-js-reference-manual-and-the-mdn-docs-861912eeaa61\" target=\"_blank\">helpful guide to using documentation</a>, written by a former Make School student.</p><h2>Check Your Work</h2><p>Like in science experiments where you form a hypothesis, run an experiment, and then evaluate the results - programmers can follow a similar pattern to help check their work as they go:</p><ul>\n<li>Think about what changes you expect to occur with your recently added code. (hypothesis)</li>\n<li>Run your program, and pay attention to the output or results. (experiment)</li>\n<li>Did the program run as you expected? If not, what was different from what you expected? What clue might that give you about how your code can be improved? (evaluate)</li>\n</ul><h2>Getting Help and Feedback</h2><p>What if you are stuck?</p><p>Read tips in <a href=\"https://medium.com/make-school/how-to-ask-for-coding-help-for-beginners-16362ae97dc6\" target=\"_blank\">How to Ask for Coding Help for Beginners</a>, written by a former Make School student.</p><p>As a Ramp participant, we also have a few options for getting help from members of the Make School community, listed below.</p><h3>Get Help on Discord</h3><p>Join the Make School Online Learning Community Discord by visiting <a href=\"https://make.sc/join-discord\" target=\"_blank\">https://make.sc/join-discord</a>.</p><p>Once you've joined the Make School Discord community, you can post a question in the <code>#ramp-support</code> channel to get peer support. Our community mentors won't give you the exact answers, but are always happy to help you get back on track! :)</p><h3>Attend Office Hours</h3><p>Office hours are hosted by volunteer mentors and dependent on volunteer availability. Upcoming office hour times will be shared in the <code>#ramp-support</code> channel on Discord.</p><h2>Completing Assignments</h2><p>Once you are finished with an assignment you can share a link to your finished project to <code>#ramp-support</code> on Slack to request a peer review for feedback or tips to further improve your code.</p><div class=\"info\">\n<p>\nNote: Peer reviews are all done by volunteers and there is no guarantee of how long it may take to get a reply (though we hope not long!). There is no need to wait for feedback before moving on to the next assignment if you feel ready!</p>\n</div><h2>Other Questions</h2><p>Email <a href=\"mailto:ramp@makeschool.com\" target=\"_blank\">ramp@makeschool.com</a> for any other questions you have.</p><p>Good luck, and happy coding as you tackle your first code challenges in the next section! :)</p>"}]},"next":{"id":"T0E6OlBhZ2UtMjQwNA==","slug":"hello-world","title":"0.0 Hello World"},"previous":{"id":"T0E6OlBhZ2UtMjQwNA==","slug":"hello-world","title":"0.0 Hello World"}},{"id":"T0E6OlBhZ2UtMjQwNA==","title":"0.0 Hello World","slug":"hello-world","sections":{"nodes":[{"id":"T0E6OlNlY3Rpb24tMTIwMDg=","title":"0.0 Hello World","htmlContent":"<div class=\"action\">\n<p>\nAccess the assignment <a href=\"https://repl.it/@MakeSchoolRAMP/00-Hello-World\" target=\"_blank\">0.0 Hello World</a>.</p>\n</div><p>Remember to view the p5.js documentation as needed: <a href=\"http://p5js.org/reference/\" target=\"_blank\">http://p5js.org/reference/</a>.</p>"},{"id":"T0E6OlNlY3Rpb24tMTIwMDk=","title":"Challenge 1: Add your name","htmlContent":"<p><strong>in <code>index.html</code></strong></p><div class=\"action\">\n<p>\nFind the <code>h1</code> tags in <code>index.html</code> and add your name so that it says <code>YOURNAME's Hello World</code></p>\n</div>"},{"id":"T0E6OlNlY3Rpb24tMTIwMTA=","title":"Challenge 2: Update the canvas color","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><div class=\"action\">\n<p>\nLocate <code>backgroundColor = color(#, #, #);</code> inside of <code>sketch.js</code> and change the 3 number values to create a custom color.</p>\n</div>"},{"id":"T0E6OlNlY3Rpb24tMTIwMTE=","title":"Challenge 3: Fill in your info","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><div class=\"action\">\n<p>\nFind the <code>?</code> in <code>sketch.js</code> and replace them with your own answers.</p>\n</div><p>Make sure your answers work with the text on the screen:</p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P01-Hello-World/assets/example.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P01-Hello-World/assets/example.png\" alt=\"example\" title=\"example\">\n        </a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwMTI=","title":"Challenge 4: Answer a question using the print function","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><p>Question: What inspired you to learn to code?</p><div class=\"action\">\n<p>\nType your answer inside of a <code>print()</code> function at the bottom of the file.</p>\n</div><p>View the console tab in the results panel to check your output:</p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P01-Hello-World/assets/console.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P01-Hello-World/assets/console.png\" alt=\"console\" title=\"console\">\n        </a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwMTM=","title":"Bonus 1: Answer another question","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><div class=\"challenge\">\n<p>\nAdd a new <code>print</code> statement and answer the question \"What would you like to help create in the world?\"</p>\n</div>"}]},"next":{"id":"T0E6OlBhZ2UtMjQwNQ==","slug":"shapes-colors","title":"0.1 Shapes and Colors"},"previous":{"id":"T0E6OlBhZ2UtMjQwNQ==","slug":"shapes-colors","title":"0.1 Shapes and Colors"}},{"id":"T0E6OlBhZ2UtMjQwNQ==","title":"0.1 Shapes and Colors","slug":"shapes-colors","sections":{"nodes":[{"id":"T0E6OlNlY3Rpb24tMTIwMTQ=","title":"0.1 Shapes and Colors","htmlContent":"<div class=\"action\">\n<p>\nAccess the assignment <a href=\"https://repl.it/@MakeSchoolRAMP/01-Shapes-and-Colors\" target=\"_blank\">0.1 Shapes and Colors</a>.</p>\n</div><p>Remember to view the p5.js documentation as needed: <a href=\"http://p5js.org/reference/\" target=\"_blank\">http://p5js.org/reference/</a>.</p><h2>Watch <a href=\"https://www.youtube.com/watch?v=8j0UDiN7my4\" target=\"_blank\">Video 1.1 - Introduction</a>\n</h2><p><iframe width=\"640\" height=\"360\" src=\"https://www.youtube.com/embed/8j0UDiN7my4\" frameborder=\"0\" allowfullscreen></iframe></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwMTU=","title":"Watch Video 1.3 - Basics of Drawing","htmlContent":"<p><iframe width=\"640\" height=\"360\" src=\"https://www.youtube.com/embed/D1ELEeIs0j8\" frameborder=\"0\" allowfullscreen></iframe></p><p>Follow along with the <a href=\"https://repl.it/@MakeSchoolRAMP/p5js-Video-Guide-13-Shapes-and-Drawing\" target=\"_blank\">video guide</a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwMTY=","title":"Watch Video 1.4 - Color","htmlContent":"<p><iframe width=\"640\" height=\"360\" src=\"https://www.youtube.com/embed/9mucjcrhFcM\" frameborder=\"0\" allowfullscreen></iframe></p><p>Follow along with the <a href=\"https://repl.it/@MakeSchoolRAMP/p5js-Video-Guide-14-Color\" target=\"_blank\">video guide</a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwMTc=","title":"Challenge 1: Add your name","htmlContent":"<p><strong>in <code>index.html</code></strong></p><div class=\"action\">\n<p>\nFind the <code>h1</code> tags in <code>index.html</code> and add your name so that it says <code>YOURNAME's Colorful Creatures</code></p>\n</div>"},{"id":"T0E6OlNlY3Rpb24tMTIwMTg=","title":"Challenge 2: Draw Creature 1 and Creature 2","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><p>Create a creature by combining multiple shapes to create a more complex drawing.</p><div class=\"info\">\n<p>\nLook up how to use new functions by viewing the <strong>Shape</strong> section in the <a href=\"https://p5js.org/reference/\" target=\"_blank\">p5.js Reference</a></p>\n</div><p>As you are making your creatures you should notice that the location <code>0,0</code> is in the top left corner and <code>x</code> and <code>y</code> values get bigger as you move down and to the right.</p><div class=\"info\">\n<p>\nFor help getting exact <code>x</code> and <code>y</code> values for your shapes, click on the canvas, then look in the console to see the values for where you clicked.</p>\n</div><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P01-Shapes-Colors/assets/get_x_y_values.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P01-Shapes-Colors/assets/get_x_y_values.png\" alt=\"getting x y values\" title=\"Get x and y values in the console\">\n        </a></p><div class=\"action\">\n<p>\ncreate one creature on each side of the center line</p>\n</div><!--  --><div class=\"action\">\n<p>\nUse 4 or more different shape functions (<code>rect</code> , <code>line</code> , <code>ellipse</code> , <code>arc</code> , <code>triangle</code> , <code>quad</code> , etc)</p>\n</div><!--  --><div class=\"action\">\n<p>\nUse 4 or more different colors in <code>fill</code> and/or <code>stroke</code></p>\n</div><p>You should now have two colorful creatures on the canvas:</p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P01-Shapes-Colors/assets/example.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P01-Shapes-Colors/assets/example.png\" alt=\"example creatures\" title=\"example creatures\">\n        </a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwMTk=","title":"Bonus 1: Give your creatures names","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><div class=\"challenge\">\n<p>\nAdd more code to display your creature names - do not change the existing text or modify the <code>helper.js</code> file.</p>\n</div>"}]},"next":{"id":"T0E6OlBhZ2UtMjQwNg==","slug":"variables","title":"0.2 Variables"},"previous":{"id":"T0E6OlBhZ2UtMjQwNg==","slug":"variables","title":"0.2 Variables"}},{"id":"T0E6OlBhZ2UtMjQwNg==","title":"0.2 Variables","slug":"variables","sections":{"nodes":[{"id":"T0E6OlNlY3Rpb24tMTIwMjA=","title":"0.2 Variables","htmlContent":"<div class=\"action\">\n<p>\nAccess the assignment <a href=\"https://repl.it/@MakeSchoolRAMP/02-Variables\" target=\"_blank\">0.2 Variables</a>.</p>\n</div><p>Remember to view the p5.js documentation as needed: <a href=\"http://p5js.org/reference/\" target=\"_blank\">http://p5js.org/reference/</a>.</p><h2>Watch <a href=\"https://www.youtube.com/watch?v=RnS0YNuLfQQ\" target=\"_blank\">Video 2.1 - Variables (mouseX, mouseY)</a>\n</h2><p><iframe width=\"640\" height=\"360\" src=\"https://www.youtube.com/embed/RnS0YNuLfQQ\" frameborder=\"0\" allowfullscreen></iframe></p><p>Follow along with the <a href=\"https://repl.it/@MakeSchoolRAMP/p5js-Video-Guide-21-Variables-mouseX-mouseY\" target=\"_blank\">video guide</a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwMjE=","title":"Watch Video 2.2 - Variables (make your own)","htmlContent":"<p><iframe width=\"640\" height=\"360\" src=\"https://www.youtube.com/embed/Bn_B3T_Vbxs\" frameborder=\"0\" allowfullscreen></iframe></p><p>Follow along with the <a href=\"https://repl.it/@MakeSchoolRAMP/p5js-Video-Guide-22-Variables-Make-your-own\" target=\"_blank\">video guide</a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwMjI=","title":"Challenge 1: Add your name","htmlContent":"<p><strong>in <code>index.html</code></strong></p><div class=\"action\">\n<p>\nFind the <code>h1</code> tags in <code>index.html</code> and add your name so that it says <code>YOURNAME's...</code></p>\n</div>"},{"id":"T0E6OlNlY3Rpb24tMTIwMjM=","title":"Challenge 2: Create a big arrow that follows the mouse","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><div class=\"action\">\n<p>\nUse <code>line</code> to add 3 more lines to create the triangle top of the arrow</p>\n</div><p>Arrow size and shape should be the same no matter where you move the mouse. Customize the color and line size to your liking.</p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P02-Variables/assets/line_arrow.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P02-Variables/assets/line_arrow.png\" alt=\"example arrow\" title=\"example arrow\">\n        </a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwMjQ=","title":"Challenge 3: Create a variable for the background color","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><div class=\"action\">\n<p>\nDeclare a custom variable name at the top of the file:</p>\n<pre><span class=\"kd\">var</span> <span class=\"nx\">backgroundColor</span><span class=\"p\">;</span>\n</pre>\n</div><!--  --><div class=\"action\">\n<p>\nUse the <code>color</code> function to create a color object and assign it to the <code>backgroundColor</code> inside of <code>setup</code>.</p>\n<pre><span class=\"nx\">backgroundColor</span> <span class=\"o\">=</span> <span class=\"nx\">color</span><span class=\"p\">(</span><span class=\"mi\">0</span><span class=\"p\">);</span>\n</pre>\n<p>Be sure to update your color to use 3 values - for Red, Green, Blue - not just a single grayscale value.</p>\n</div><!--  --><div class=\"action\">\n<p>\nPass your newly created color variable to the <code>background</code> function instead of <code>200</code></p>\n</div><p>Be sure to update your color to use 3 values - for Red, Green, Blue - so that your background is no longer grey.</p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P02-Variables/assets/background.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P02-Variables/assets/background.png\" alt=\"custom background color\" title=\"custom background color\">\n        </a></p><div class=\"info\">\n<p>\nThe <code>color</code> function doesn't work before the <code>setup</code> function, you will get an error if you try to use it at the top when you declare your variable.</p>\n</div>"},{"id":"T0E6OlNlY3Rpb24tMTIwMjU=","title":"Challenge 4: Create a creature that moves across the screen at a constant speed","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><div class=\"action\">\n<p>\nDraw a creature made of at least 2 shapes and 2 colors.</p>\n</div><!--  --><div class=\"action\">\n<p>\nDeclare a custom variable <code>moveX</code> at the top of sketch.js and assign a starting value of <code>10</code></p>\n</div><!--  --><div class=\"info\">\n<p> For numbers you can assign the starting value at the top because numbers are always available and don't need to wait until the <code>setup</code> function</p>\n</div><!--  --><div class=\"action\">\n<p>\nUse your custom <code>moveX</code> variable as the <code>x</code> location for drawing your custom creature</p>\n</div><p>Example of converting your creature to use an <code>moveX</code> variable:</p><div class=\"solution\">\n<p></p>\n<pre><span class=\"c1\">// change this:</span>\n<span class=\"n\">rect</span><span class=\"p\">(</span><span class=\"mi\">100</span><span class=\"p\">,</span> <span class=\"mi\">100</span><span class=\"p\">,</span> <span class=\"mi\">50</span><span class=\"p\">,</span> <span class=\"mi\">75</span><span class=\"p\">);</span>\n<span class=\"n\">circle</span><span class=\"p\">(</span><span class=\"mi\">120</span><span class=\"p\">,</span> <span class=\"mi\">30</span><span class=\"p\">,</span> <span class=\"mi\">80</span><span class=\"p\">,</span> <span class=\"mi\">75</span><span class=\"p\">);</span>\n\n<span class=\"c1\">// to this:</span>\n<span class=\"n\">rect</span><span class=\"p\">(</span><span class=\"n\">moveX</span><span class=\"p\">,</span> <span class=\"mi\">100</span><span class=\"p\">,</span> <span class=\"mi\">50</span><span class=\"p\">,</span> <span class=\"mi\">75</span><span class=\"p\">);</span>\n<span class=\"n\">circle</span><span class=\"p\">(</span><span class=\"n\">moveX</span> <span class=\"o\">+</span> <span class=\"mi\">20</span><span class=\"p\">,</span> <span class=\"mi\">30</span><span class=\"p\">,</span> <span class=\"mi\">80</span><span class=\"p\">,</span> <span class=\"mi\">75</span><span class=\"p\">);</span>\n</pre>\n</div><!--  --><div class=\"action\">\n<p>\nIncrement <code>moveX</code> by <code>1</code> inside of the <code>draw</code> function so that your creature moves across the screen.\nPlease use only 1 variable for your entire creature.</p>\n</div><p>Ensure you keep the <code>background</code> function at the top of <code>draw</code>, we want the creature to move, not for it to smear color across the canvas (also do not move it to the <code>mousePressed</code> function)</p><p>Creature moving from left to right across the canvas:</p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P02-Variables/assets/moving_creature.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P02-Variables/assets/moving_creature.png\" alt=\"moving creature\" title=\"moving creature\">\n        </a></p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P02-Variables/assets/moving_creature_2.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P02-Variables/assets/moving_creature_2.png\" alt=\"moving creature 2\" title=\"moving creature 2\">\n        </a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwMjY=","title":"Bonus 1: Colors that change as you move the mouse","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><div class=\"challenge\">\n<p>\nCreate another creature and use creature colors that change based on mouse location</p>\n</div><p>The creature does not need to move, but it's color should change dynamically as you move the mouse around the canvas.</p><p>The colors should not change if the mouse is not moving, and should not flash rapidly (don't use the <code>random</code> function).</p>"}]},"next":{"id":"T0E6OlBhZ2UtMjQwNw==","slug":"objects","title":"0.3 Objects"},"previous":{"id":"T0E6OlBhZ2UtMjQwNw==","slug":"objects","title":"0.3 Objects"}},{"id":"T0E6OlBhZ2UtMjQwNw==","title":"0.3 Objects","slug":"objects","sections":{"nodes":[{"id":"T0E6OlNlY3Rpb24tMTIwMjc=","title":"0.3 Objects","htmlContent":"<div class=\"action\">\n<p>\nAccess the assignment <a href=\"https://repl.it/@MakeSchoolRAMP/03-Objects\" target=\"_blank\">0.3 Objects</a>.</p>\n</div><p>Remember to view the p5.js documentation as needed: <a href=\"http://p5js.org/reference/\" target=\"_blank\">http://p5js.org/reference/</a>.</p><h2>Watch <a href=\"https://www.youtube.com/watch?v=-e5h4IGKZRY\" target=\"_blank\">Video 2.3 - Javascript Objects</a>\n</h2><p><iframe width=\"640\" height=\"360\" src=\"https://www.youtube.com/embed/-e5h4IGKZRY\" frameborder=\"0\" allowfullscreen></iframe></p><p>Follow along with the <a href=\"https://repl.it/@MakeSchoolRAMP/p5js-Video-Guide-23-JavaScript-Objects\" target=\"_blank\">video guide</a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwMjg=","title":"Watch Video 2.5 - The random() Function","htmlContent":"<p><iframe width=\"640\" height=\"360\" src=\"https://www.youtube.com/embed/nfmV2kuQKwA\" frameborder=\"0\" allowfullscreen></iframe></p><p>Follow along with the <a href=\"https://repl.it/@MakeSchoolRAMP/p5js-Video-Guide-25-The-random-Function\" target=\"_blank\">video guide</a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwMjk=","title":"Challenge 1: Add your name","htmlContent":"<p><strong>in <code>index.html</code></strong></p><div class=\"action\">\n<p>\nFind the <code>h1</code> tags in <code>index.html</code> and add your name so that it says <code>YOURNAME's...</code></p>\n</div>"},{"id":"T0E6OlNlY3Rpb24tMTIwMzA=","title":"Challenge 2: Declare and assign two creature objects","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><div class=\"action\">\n<p>\nDeclare 2 vars called <code>rightCreature</code> and <code>leftCreature</code> at the top of the file.</p>\n</div><!--  --><div class=\"action\">\n<p>\nIn <code>setup</code>, assign <code>rightCreature</code> and <code>leftCreature</code> to objects with the following 5 properties inside of them:</p>\n\n<ul>\n<li><code>color1</code></li>\n<li><code>color2</code></li>\n<li><code>height</code></li>\n<li><code>width</code></li>\n<li><code>xOffset</code></li>\n</ul>\n</div><!--  --><div class=\"action\">\n<p>\nGive <code>rightCreature</code> a positive <code>xOffset</code> number and <code>leftCreature</code> a negative <code>xOffset</code></p>\n</div><!--  --><div class=\"info\">\n<p>\nRemember, the <code>color</code> function doesn't work before the <code>setup</code> function, you will get an error if you try to declare and assign values to the objects all at the top.</p>\n</div>"},{"id":"T0E6OlNlY3Rpb24tMTIwMzE=","title":"Challenge 3: Draw both creatures on the cloud","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><div class=\"action\">\n<p>\nUse <code>mouseX</code> and <code>xOffset</code> so that <code>rightCreature</code> and <code>leftCreature</code> both follow the mouse but to the left/right side by a distance of <code>xOffset</code></p>\n</div><p>When drawing the creatures, be sure to:</p><ul>\n<li>Use 2 or more shapes for each creature</li>\n<li>Use all 5 properties on each creature</li>\n<li>Make the creatures stay with the cloud in both the <code>x</code> and <code>y</code> directions.</li>\n</ul><p>It should look like your two creatures are staying in the same place on the cloud as you move the mouse around:</p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P03-Objects/assets/cloud_creatures.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P03-Objects/assets/cloud_creatures.png\" alt=\"cloud creatures\" title=\"cloud creatures\">\n        </a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwMzI=","title":"Challenge 4: Click to change the sky color","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><div class=\"action\">\n<p>\nAdd the <code>mousePressed</code> function at the bottom of the file.\nAdd <code>print(\"clicked\")</code> inside so that you can see evidence in the console that your function was correctly called.</p>\n</div><!--  --><div class=\"info\">\n<p>\nAlways double check that you are adding new functions in the correct location.\nIf you accidentally create it inside of another function, then the program may not be able to correctly locate and use it and you may get an error.</p>\n</div><!--  --><div class=\"action\">\n<p>\nInside of <code>mousePressed</code>, add a variable called <code>randomRed</code> and use the <code>random</code> function to assign a random number between 0 and 255.</p>\n</div><!--  --><div class=\"action\">\n<p>\nInside of <code>mousePressed</code>, call the <a href=\"https://p5js.org/reference/#/p5.Color/setRed\" target=\"_blank\"><code>setRed</code> function</a> on <code>skyColor</code> to change it's red amount to <code>randomRed</code>.\n(Note: don't use the exact example code, just use it as a guide)</p>\n</div><p>The redness of the sky should now change color each time you click the mouse:</p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P03-Objects/assets/sky_color_1.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P03-Objects/assets/sky_color_1.png\" alt=\"sky color 1\" title=\"sky color 1\">\n        </a></p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P03-Objects/assets/sky_color_2.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P03-Objects/assets/sky_color_2.png\" alt=\"sky color 2\" title=\"sky color 2\">\n        </a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwMzM=","title":"Bonus 1: Explain the difference","htmlContent":"<div class=\"challenge\">\n<p></p>\n\n<p>Use <code>print()</code> inside of <code>setup</code> to answer:</p>\n\n<ol>\n<li>What is the difference between <code>value == 5</code> and <code>value = 5</code>?</li>\n<li>Which one is used in conditional statements?</li>\n</ol>\n</div>"},{"id":"T0E6OlNlY3Rpb24tMTIwMzQ=","title":"Bonus 2: Make it a dance party!","htmlContent":"<div class=\"challenge\">\n<p>\nMake your creatures dance back and forth when you click the mouse</p>\n</div><p><strong><em>Untz untz untz!</em></strong></p>"}]},"next":{"id":"T0E6OlBhZ2UtMjQwOA==","slug":"conditionals","title":"0.4 Conditionals"},"previous":{"id":"T0E6OlBhZ2UtMjQwOA==","slug":"conditionals","title":"0.4 Conditionals"}},{"id":"T0E6OlBhZ2UtMjQwOA==","title":"0.4 Conditionals","slug":"conditionals","sections":{"nodes":[{"id":"T0E6OlNlY3Rpb24tMTIwMzU=","title":"0.4 Conditionals","htmlContent":"<div class=\"action\">\n<p>\nAccess the assignment <a href=\"https://repl.it/@MakeSchoolRAMP/04-Conditionals\" target=\"_blank\">0.4 Conditionals</a>.</p>\n</div><p>Remember to view the p5.js documentation as needed: <a href=\"http://p5js.org/reference/\" target=\"_blank\">http://p5js.org/reference/</a>.</p><h2>Watch <a href=\"https://www.youtube.com/watch?v=1Osb_iGDdjk\" target=\"_blank\">Video 3.1 - Introduction to Conditional Statements</a>\n</h2><p><iframe width=\"640\" height=\"360\" src=\"https://www.youtube.com/embed/1Osb_iGDdjk\" frameborder=\"0\" allowfullscreen></iframe></p><p>Follow along with the <a href=\"https://repl.it/@MakeSchoolRAMP/p5js-Video-Guide-31-Intro-to-Conditional-Statements\" target=\"_blank\">video guide</a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwMzY=","title":"Watch Video 3.2 - The Bouncing Ball","htmlContent":"<p><iframe width=\"640\" height=\"360\" src=\"https://www.youtube.com/embed/LO3Awjn_gyU\" frameborder=\"0\" allowfullscreen></iframe></p><p>Follow along with the <a href=\"https://repl.it/@MakeSchoolRAMP/p5js-Video-Guide-32-The-Bouncing-Ball\" target=\"_blank\">video guide</a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwMzc=","title":"Watch Video 3.3 - Else and Else if, AND and OR","htmlContent":"<p><iframe width=\"640\" height=\"360\" src=\"https://www.youtube.com/embed/r2S7j54I68c\" frameborder=\"0\" allowfullscreen></iframe></p><p>Follow along with the <a href=\"https://repl.it/@MakeSchoolRAMP/p5js-Video-Guide-33-Else-and-Else-if-AND-and-OR\" target=\"_blank\">video guide</a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwMzg=","title":"Watch Video 3.4 - Boolean Variables","htmlContent":"<p><iframe width=\"640\" height=\"360\" src=\"https://www.youtube.com/embed/Rk-_syQluvc\" frameborder=\"0\" allowfullscreen></iframe></p><p>Follow along with the <a href=\"https://repl.it/@MakeSchoolRAMP/p5js-Video-Guide-34-Boolean-Variables\" target=\"_blank\">video guide</a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwMzk=","title":"Challenge 1: Add your name","htmlContent":"<p><strong>in <code>index.html</code></strong></p><div class=\"action\">\n<p>\nFind the <code>h1</code> tags in <code>index.html</code> and add your name so that it says <code>YOURNAME's...</code></p>\n</div>"},{"id":"T0E6OlNlY3Rpb24tMTIwNDA=","title":"Challenge 2: Make the beast bounce horizontally","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><p>Your <code>beast</code> should move right until it reaches the edge of the canvas, then change direction and move left until it reaches the edge of the canvas, then change direction again, etc.</p><div class=\"action\">\n<p>\nFirst, modify <code>beast.x</code> in the <code>draw</code> loop to get the <code>beast</code> moving from left to right.</p>\n</div><!--  --><div class=\"action\">\n<p>\nUse an if statement to update <code>beast.speed</code> to create bouncing behavior</p>\n</div><p>Beast bouncing:</p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P04-Conditionals/assets/bounce_0.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P04-Conditionals/assets/bounce_0.png\" alt=\"bounce 0\" title=\"bounce 0\">\n        </a></p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P04-Conditionals/assets/bounce_1.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P04-Conditionals/assets/bounce_1.png\" alt=\"bounce 1\" title=\"bounce 1\">\n        </a></p><div class=\"challenge\">\n<p>\nTry to use only a single if statement, using <code>&amp;&amp;</code> and/or <code>||</code> as needed.</p>\n</div>"},{"id":"T0E6OlNlY3Rpb24tMTIwNDE=","title":"Challenge 3: Create color-changing camouflage","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><p>Dynamically change <code>beast.color</code> to match the color of the background as it moves.</p><div class=\"action\">\n<p>\nCreate an if statement to correctly update <code>beast.color</code></p>\n</div><p><code>beast.color</code> should be:</p><ul>\n<li>\n<code>color1</code> while crossing the first third of the background</li>\n</ul><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P04-Conditionals/assets/camo_0.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P04-Conditionals/assets/camo_0.png\" alt=\"camo 0\" title=\"camo 0\">\n        </a></p><ul>\n<li>\n<code>color2</code> in the middle third</li>\n</ul><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P04-Conditionals/assets/camo_1.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P04-Conditionals/assets/camo_1.png\" alt=\"camo 1\" title=\"camo 1\">\n        </a></p><ul>\n<li>\n<code>color3</code> in the last third</li>\n</ul><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P04-Conditionals/assets/camo_2.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P04-Conditionals/assets/camo_2.png\" alt=\"camo 2\" title=\"camo 2\">\n        </a></p><div class=\"challenge\">\n<p>\nFormat your logic so that colors update correctly even if the canvas is resized to be more or less wide. Would your code above still work if you did <code>createCanvas(200, 800)</code> or <code>createCanvas(500, 100)</code>?</p>\n</div>"},{"id":"T0E6OlNlY3Rpb24tMTIwNDI=","title":"Challenge 4: Determine relative motion of the beast to the mouse","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><p>To prepare for Challenge 5, you will need to find out when the <code>beast</code> is moving <em>towards</em> the mouse and when it is moving <em>away</em> from the mouse.</p><p>This can be done using two pieces of information:</p><ol>\n<li>Is the beast moving to the left or to the right?</li>\n<li>Is the mouse to the left or the right of the mouse?</li>\n</ol><p>There are four possible combinations of these two pieces of information.</p><p>Beast moving right and mouse on right:\n<a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P04-Conditionals/assets/chasing_right.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P04-Conditionals/assets/chasing_right.png\" alt=\"chasing right\" title=\"chasing right\">\n        </a></p><p>Beast moving right and mouse on left:\n<a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P04-Conditionals/assets/fleeing_right.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P04-Conditionals/assets/fleeing_right.png\" alt=\"fleeing right\" title=\"fleeing right\">\n        </a></p><p>Beast moving left and mouse on left:\n<a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P04-Conditionals/assets/chasing_left.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P04-Conditionals/assets/chasing_left.png\" alt=\"chasing left\" title=\"chasing left\">\n        </a></p><p>Beast moving left and mouse on right:\n<a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P04-Conditionals/assets/fleeing_left.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P04-Conditionals/assets/fleeing_left.png\" alt=\"fleeing left\" title=\"fleeing left\">\n        </a></p><p>In two of the four combinations the beast is moving towards the mouse (\"chasing\") and in two the beast is not (\"fleeing\").</p><div class=\"action\">\n<p>\nCreate a boolean variable called <code>movingTowardsMouse</code>.</p>\n</div><p><code>movingTowardsMouse</code> should be set to <code>true</code> when:</p><ul>\n<li>\n<code>beast</code> is moving to the right <strong>AND</strong> the mouse is to the right of the <code>beast</code> <strong>OR</strong> <code>beast</code> is moving to the left <strong>AND</strong> the mouse is to the left of the <code>beast</code>\n</li>\n<li>\n<strong>else</strong> it should be set to <code>false</code>\n</li>\n</ul><div class=\"action\">\n<p>\nUse an if statement to assign a boolean value to <code>movingTowardMouse</code></p>\n</div><p>Hint: you can tell which direction <code>beast</code> is moving based on it's speed!</p>"},{"id":"T0E6OlNlY3Rpb24tMTIwNDM=","title":"Challenge 5: Display if the beast is chasing or fleeing","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><ul>\n<li>If <code>movingTowardsMouse</code> is <code>true</code>, the message should say \"Chasing\"</li>\n<li>If <code>movingTowardsMouse</code> is <code>false</code>, the message should say \"Fleeing\"</li>\n</ul><div class=\"action\">\n<p>\nUse an if statement to update <code>beast.message</code> to say whether it is chasing or fleeing the mouse</p>\n</div><p>(Review the images in Challenge 4 to see how the message should appear in each situation.)</p>"},{"id":"T0E6OlNlY3Rpb24tMTIwNDQ=","title":"Bonus 1: Add vertical movement to the beast","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><div class=\"challenge\">\n<p>\nUpdate your code so that <code>beast</code> bounces both vertically and horizontally across the canvas.</p>\n</div><p>Ensure that <code>beast</code> still bounces horizontally across the entire width of the canvas.</p>"}]},"next":{"id":"T0E6OlBhZ2UtMjQwOQ==","slug":"loops","title":"0.5 Loops"},"previous":{"id":"T0E6OlBhZ2UtMjQwOQ==","slug":"loops","title":"0.5 Loops"}},{"id":"T0E6OlBhZ2UtMjQwOQ==","title":"0.5 Loops","slug":"loops","sections":{"nodes":[{"id":"T0E6OlNlY3Rpb24tMTIwNDU=","title":"0.5 Loops","htmlContent":"<div class=\"action\">\n<p>\nAccess the assignment <a href=\"https://repl.it/@MakeSchoolRAMP/05-Loops\" target=\"_blank\">0.5 Loops</a>.</p>\n</div><p>Remember to view the p5.js documentation as needed: <a href=\"http://p5js.org/reference/\" target=\"_blank\">http://p5js.org/reference/</a>.</p><h2>Watch <a href=\"https://www.youtube.com/watch?v=cnRD9o6odjk\" target=\"_blank\">Video 4.1 - While and For Loops</a>\n</h2><p><iframe width=\"640\" height=\"360\" src=\"https://www.youtube.com/embed/cnRD9o6odjk\" frameborder=\"0\" allowfullscreen></iframe></p><p>Follow along with the <a href=\"https://repl.it/@MakeSchoolRAMP/p5js-Video-Guide-41-while-and-for-Loops\" target=\"_blank\">video guide</a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwNDY=","title":"Watch Video 4.2 - Nested Loops","htmlContent":"<p><iframe width=\"640\" height=\"360\" src=\"https://www.youtube.com/embed/1c1_TMdf8b8\" frameborder=\"0\" allowfullscreen></iframe></p><p>Follow along with the <a href=\"https://repl.it/@MakeSchoolRAMP/p5js-Video-Guide-42-Nested-Loops\" target=\"_blank\">video guide</a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwNDc=","title":"Challenge 1: Add your name","htmlContent":"<p><strong>in <code>index.html</code></strong></p><div class=\"action\">\n<p>\nFind the <code>h1</code> tags in <code>index.html</code> and add your name so that it says <code>YOURNAME's...</code></p>\n</div>"},{"id":"T0E6OlNlY3Rpb24tMTIwNDg=","title":"Challenge 2: Make the marcher march back and forth","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><div class=\"action\">\n<p>\nUse <code>marcher.speed</code> to update <code>marcher.x</code></p>\n</div><!--  --><div class=\"action\">\n<p>\nUpdate <code>marcher.speed</code> so that <code>marcher</code> changes directions at the edges of the canvas</p>\n</div><p>Marcher moving:</p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P05-Loops/assets/marcher_1.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P05-Loops/assets/marcher_1.png\" alt=\"marcher 1\" title=\"marcher 1\">\n        </a></p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P05-Loops/assets/marcher_2.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P05-Loops/assets/marcher_2.png\" alt=\"marcher 2\" title=\"marcher 2\">\n        </a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwNDk=","title":"Challenge 3: Draw clones of the marcher in a vertical row","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><p>Use a <code>while</code> loop to create a squad of clones that will along with <code>marcher</code>.</p><div class=\"action\">\n<p>\nDefine a new var named <code>cloneY</code> for the loop to use, and assign it a starting value of <code>marcher.y</code> plus some spacing.</p>\n</div><!--  --><div class=\"action\">\n<p>\nIn the <code>while</code> loop, draw clones that are spaced out until the end of the canvas. Make them a different color than the <code>marcher</code>.</p>\n</div><p>Clones should all be evenly spaced and moving back and forth together:</p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P05-Loops/assets/clones.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P05-Loops/assets/clones.png\" alt=\"clones\" title=\"clones\">\n        </a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwNTA=","title":"Challenge 4: Draw a tile floor","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><div class=\"action\">\n<p>\nUse a <strong>nested</strong> <code>for loop</code> to draw colored tiles across the whole screen.</p>\n</div><p>Use the same size for spacing and drawing your tiles so that there are no gaps between tiles where the <code>backgroundColor</code> can show through:</p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P05-Loops/assets/tile_floor.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P05-Loops/assets/tile_floor.png\" alt=\"tile floor\" title=\"tile floor\">\n        </a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwNTE=","title":"Bonus 1: Make gradient tile colors","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><div class=\"challenge\">\n<p>\nGive your tiles a gradient color effect.</p>\n</div><p>Each tile should have a unique non-changing color different from the others around it.</p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P05-Loops/assets/gradient_colors.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P05-Loops/assets/gradient_colors.png\" alt=\"gradient tile floor\" title=\"gradient tile floor\">\n        </a></p>"}]},"next":{"id":"T0E6OlBhZ2UtMjQxMA==","slug":"functions0","title":"0.6 Functions"},"previous":{"id":"T0E6OlBhZ2UtMjQxMA==","slug":"functions0","title":"0.6 Functions"}},{"id":"T0E6OlBhZ2UtMjQxMA==","title":"0.6 Functions","slug":"functions0","sections":{"nodes":[{"id":"T0E6OlNlY3Rpb24tMTIwNTI=","title":"0.6 Functions","htmlContent":"<div class=\"action\">\n<p>\nAccess the assignment <a href=\"https://repl.it/@MakeSchoolRAMP/06-Functions\" target=\"_blank\">0.6 Functions</a>.</p>\n</div><p>Remember to view the p5.js documentation as needed: <a href=\"http://p5js.org/reference/\" target=\"_blank\">http://p5js.org/reference/</a>.</p><h2>Watch <a href=\"https://www.youtube.com/watch?v=wRHAitGzBrg\" target=\"_blank\">Video 5.1 Function Basics</a>\n</h2><p><iframe width=\"640\" height=\"360\" src=\"https://www.youtube.com/embed/wRHAitGzBrg\" frameborder=\"0\" allowfullscreen></iframe></p><p>Follow along with the <a href=\"https://repl.it/@MakeSchoolRAMP/p5js-Video-Guide-51-Function-Basics\" target=\"_blank\">video guide</a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwNTM=","title":"Watch Video 5.2 Function Parameters and Arguments","htmlContent":"<p><iframe width=\"640\" height=\"360\" src=\"https://www.youtube.com/embed/zkc417YapfE\" frameborder=\"0\" allowfullscreen></iframe></p><p>Follow along with the <a href=\"https://repl.it/@MakeSchoolRAMP/p5js-Video-Guide-52-Function-Parameters-and-Arguments\" target=\"_blank\">video guide</a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwNTQ=","title":"Watch Video 5.3 Functions and Return","htmlContent":"<p><iframe width=\"640\" height=\"360\" src=\"https://www.youtube.com/embed/qRnUBiTJ66Y\" frameborder=\"0\" allowfullscreen></iframe></p><p>Follow along with the <a href=\"https://repl.it/@MakeSchoolRAMP/p5js-Video-Guide-53-Functions-and-Return\" target=\"_blank\">video guide</a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwNTU=","title":"Challenge 1: Add your name","htmlContent":"<p><strong>in <code>index.html</code></strong></p><div class=\"action\">\n<p>\nFind the <code>h1</code> tags in <code>index.html</code> and add your name so that it says <code>YOURNAME's...</code></p>\n</div>"},{"id":"T0E6OlNlY3Rpb24tMTIwNTY=","title":"Challenge 2: Add grow or reset functionality","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><p>The <code>growOrReset</code> function calls other functions depending on the situation.</p><div class=\"action\">\n<p>\nThe <code>growOrReset</code> function should call <code>plantGrow()</code> if the mouse is on the right half of the canvas, and should call <code>plantReset()</code> if the mouse is on the left side.</p>\n</div><!--  --><div class=\"action\">\n<p>\nUncomment <code>growOrReset();</code> inside of <code>draw</code></p>\n</div><p>You can check in the console to see if <code>plant.size</code> is changing correctly:</p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P06-Functions/assets/console.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P06-Functions/assets/console.png\" alt=\"console\" title=\"console\">\n        </a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwNTc=","title":"Challenge 3: Display the plants","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><p>The <code>drawPlant</code> function needs to pass down it's <code>x</code> and <code>y</code> parameters to the other functions it calls.</p><div class=\"action\">\n<p>\nInside of <code>drawPlant</code>, if <code>plant.size</code> is 0, call <code>drawSeed</code>, otherwise call both <code>drawSprout</code> and <code>drawBloom</code>. Don't forget to pass the required parameters!</p>\n</div><!--  --><div class=\"action\">\n<p>\nUncomment the two lines calling <code>drawPlant()</code> inside of <code>draw</code> .</p>\n</div><p>Watch the two plants grow and bloom:</p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P06-Functions/assets/draw_plant.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P06-Functions/assets/draw_plant.png\" alt=\"draw plant\" title=\"draw plant\">\n        </a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwNTg=","title":"Challenge 4: Implement the label function","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><p>The <code>plantLabel</code> function needs to <code>return</code> a string label.</p><div class=\"action\">\n<p>\nBased on <code>plant</code>'s current properties, return the correct string: <code>\"seed\"</code>, <code>\"growing\"</code>, or <code>\"blooming\"</code></p>\n</div><!--  --><div class=\"action\">\n<p>\nUncomment <code>text(plantLabel(), 10, 20);</code> inside of <code>draw</code></p>\n</div><p>You should now see correct labels in the upper left corner:</p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P06-Functions/assets/seed.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P06-Functions/assets/seed.png\" alt=\"seed\" title=\"seed\">\n        </a></p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P06-Functions/assets/growing.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P06-Functions/assets/growing.png\" alt=\"growing\" title=\"growing\">\n        </a></p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P06-Functions/assets/blooming.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P06-Functions/assets/blooming.png\" alt=\"blooming\" title=\"blooming\">\n        </a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwNTk=","title":"Bonus 1: Display a field of plants","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><div class=\"challenge\">\n<p>\nDisplay a whole field of plants instead of just two.</p>\n</div><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P06-Functions/assets/field.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P06-Functions/assets/field.png\" alt=\"field\" title=\"field\">\n        </a></p>"}]},"next":{"id":"T0E6OlBhZ2UtMjQxMQ==","slug":"classes","title":"0.7 Classes"},"previous":{"id":"T0E6OlBhZ2UtMjQxMQ==","slug":"classes","title":"0.7 Classes"}},{"id":"T0E6OlBhZ2UtMjQxMQ==","title":"0.7 Classes","slug":"classes","sections":{"nodes":[{"id":"T0E6OlNlY3Rpb24tMTIwNjA=","title":"0.7 Classes","htmlContent":"<div class=\"action\">\n<p>\nAccess the assignment <a href=\"https://repl.it/@MakeSchoolRAMP/07-Classes\" target=\"_blank\">0.7 Classes</a>.</p>\n</div><p>Remember to view the p5.js documentation as needed: <a href=\"http://p5js.org/reference/\" target=\"_blank\">http://p5js.org/reference/</a>.</p><h2>Watch <a href=\"https://www.youtube.com/watch?v=T-HGdc8L-7w\" target=\"_blank\">Video 6.2 Classes in Javascript</a>\n</h2><p><iframe width=\"640\" height=\"360\" src=\"https://www.youtube.com/embed/T-HGdc8L-7w\" frameborder=\"0\" allowfullscreen></iframe></p><p>Follow along with the <a href=\"https://repl.it/@MakeSchoolRAMP/p5js-Video-Guide-62-Classes-in-JavaScript\" target=\"_blank\">video guide</a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwNjE=","title":"Watch Video 6.3 Constructor Arguments with Classes in Javascript","htmlContent":"<p><iframe width=\"640\" height=\"360\" src=\"https://www.youtube.com/embed/rHiSsgFRgx4\" frameborder=\"0\" allowfullscreen></iframe></p><p>Follow along with the <a href=\"https://repl.it/@MakeSchoolRAMP/p5js-Video-Guide-63-Constructor-Arguments-with-Classes\" target=\"_blank\">video guide</a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwNjI=","title":"Challenge 1: Add your name","htmlContent":"<p><strong>in <code>index.html</code></strong></p><div class=\"action\">\n<p>\nFind the <code>h1</code> tags in <code>index.html</code> and add your name so that it says <code>YOURNAME's...</code></p>\n</div>"},{"id":"T0E6OlNlY3Rpb24tMTIwNjM=","title":"Challenge 2: Create a new flower class","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><div class=\"action\">\n<p>\nAdd a new <code>FancyFlower</code> class with the same <code>constructor</code> arguments: <code>x</code>, <code>y</code>, and <code>petalColor</code>.</p>\n</div><p>Use the <code>PlainFlower</code> class as a guide. Ensure that you are including all of the same properties in your <code>FancyFlower</code> class.</p><div class=\"action\">\n<p>\nAdjust the values of the default and random default properties to your liking.</p>\n</div>"},{"id":"T0E6OlNlY3Rpb24tMTIwNjQ=","title":"Challenge 3: Add two flower objects","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><div class=\"action\">\n<p>\nIn <code>draw</code>, call <code>new FancyFlower()</code> to create two new flower objects - <code>flowerThree</code> and <code>flowerFour</code>.\nPass in unique colors and good <code>x</code>, <code>y</code> values so that they will be nicely spaced out.</p>\n</div><!--  --><div class=\"action\">\n<p>\nUncomment <code>garden = [flowerOne, flowerTwo, flowerThree, flowerFour];</code> in <code>draw</code> to include your new flowers in the <code>garden</code> array.</p>\n</div><p>You should now see two new flowers growing alongside the original flowers:</p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P07-Classes/assets/new_flowers.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P07-Classes/assets/new_flowers.png\" alt=\"new flowers\" title=\"new flowers\">\n        </a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwNjU=","title":"Challenge 4: Design a custom bloom","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><p>Right now your <code>FancyFlower</code> class doesn't have a custom <code>drawBloom</code> function like the <code>PlainFlower</code> class does. If you look inside the <code>drawPlant</code> function you can see that it will call <code>drawDefaultBloom(flower)</code> instead, which just draws a simple ellipse.</p><pre><span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"nx\">flower</span><span class=\"p\">.</span><span class=\"nx\">drawBloom</span><span class=\"p\">)</span> <span class=\"p\">{</span> <span class=\"c1\">// check if the function exists</span>\n  <span class=\"nx\">flower</span><span class=\"p\">.</span><span class=\"nx\">drawBloom</span><span class=\"p\">();</span> <span class=\"c1\">// call the function</span>\n<span class=\"p\">}</span> <span class=\"k\">else</span> <span class=\"p\">{</span>\n  <span class=\"nx\">drawDefaultBloom</span><span class=\"p\">(</span><span class=\"nx\">flower</span><span class=\"p\">);</span> <span class=\"c1\">// call the default helper instead</span>\n<span class=\"p\">}</span>\n</pre>\n<div class=\"action\">\n<p>\nAdd a custom <code>drawBloom</code> function to <code>FancyFlower</code> so that it can create it's own custom bloom shape.</p>\n\n<ul>\n<li>Don't forget to use <code>this.x</code>, <code>this.y</code>, and <code>this.bloomSize</code> to properly place the bloom relative to the sprout.</li>\n<li>Don't draw a bloom when <code>bloomSize</code> is 0.</li>\n<li>Your new bloom must be fancier than just another ellipse - be sure that it looks different from the <code>PlainFlower</code>!</li>\n</ul>\n</div><p>You should now have a garden with 4 flowers, all different colors, and with two different overall appearances:</p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P07-Classes/assets/custom_bloom.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P07-Classes/assets/custom_bloom.png\" alt=\"custom bloom\" title=\"custom bloom\">\n        </a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwNjY=","title":"Bonus 1: Custom sprouts and blooms","htmlContent":"<div class=\"challenge\">\n<p>\nNow that you have custom blooms for each class, make changes that give both classes custom seeds and custom sprouts in the same way.</p>\n</div><p>This challenge requires making updates to some of the existing functions.</p>"}]},"next":{"id":"T0E6OlBhZ2UtMjQxMg==","slug":"arrays","title":"0.8 Arrays"},"previous":{"id":"T0E6OlBhZ2UtMjQxMg==","slug":"arrays","title":"0.8 Arrays"}},{"id":"T0E6OlBhZ2UtMjQxMg==","title":"0.8 Arrays","slug":"arrays","sections":{"nodes":[{"id":"T0E6OlNlY3Rpb24tMTIwNjc=","title":"0.8 Arrays","htmlContent":"<div class=\"action\">\n<p>\nAccess the assignment <a href=\"https://repl.it/@MakeSchoolRAMP/08-Arrays\" target=\"_blank\">0.8 Arrays</a>.</p>\n</div><p>Remember to view the p5.js documentation as needed: <a href=\"http://p5js.org/reference/\" target=\"_blank\">http://p5js.org/reference/</a>.</p><h2>Watch <a href=\"https://www.youtube.com/watch?v=VIQoUghHSxU\" target=\"_blank\">Video 7.1 What is an array?</a>\n</h2><p><iframe width=\"640\" height=\"360\" src=\"https://www.youtube.com/embed/VIQoUghHSxU\" frameborder=\"0\" allowfullscreen></iframe></p><p>Follow along with the <a href=\"https://repl.it/@MakeSchoolRAMP/p5js-Video-Guide-71-What-is-an-array\" target=\"_blank\">video guide</a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwNjg=","title":"Watch Video 7.2 Arrays and Loops","htmlContent":"<p><iframe width=\"640\" height=\"360\" src=\"https://www.youtube.com/embed/RXWO3mFuW-I\" frameborder=\"0\" allowfullscreen></iframe></p><p>Follow along with the <a href=\"https://repl.it/@MakeSchoolRAMP/p5js-Video-Guide-72-Arrays-and-Loops\" target=\"_blank\">video guide</a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwNjk=","title":"Watch Video 7.3 Arrays of Objects","htmlContent":"<p><iframe width=\"640\" height=\"360\" src=\"https://www.youtube.com/embed/fBqaA7zRO58\" frameborder=\"0\" allowfullscreen></iframe></p><p>Follow along with the <a href=\"https://repl.it/@MakeSchoolRAMP/p5js-Video-Guide-73-Arrays-of-Objects\" target=\"_blank\">video guide</a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwNzA=","title":"Challenge 1: Add your name","htmlContent":"<p><strong>in <code>index.html</code></strong></p><div class=\"action\">\n<p>\nFind the <code>h1</code> tags in <code>index.html</code> and add your name so that it says <code>YOURNAME's...</code></p>\n</div>"},{"id":"T0E6OlNlY3Rpb24tMTIwNzE=","title":"Challenge 2: Save new spots","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><p>The <code>mousePressed</code> function calls <code>saveSpot</code> but nothing happens yet. The goal is to save a spot that has the color that the canvas is when the mouse is clicked.</p><div class=\"action\">\n<p>\nInside of <code>saveSpot</code>, create a <code>new Spot</code> using the current mouse location and <code>currentColor()</code>.</p>\n</div><p>You can add the new spot to the <code>spots</code> array using either the <code>push</code> or <code>append</code> functions.</p><p>Click a few times and then check the results of <code>print(spots)</code> in the console to see if new <code>Spot</code> objects are being added:</p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P08-Arrays/assets/console.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P08-Arrays/assets/console.png\" alt=\"console\" title=\"console\">\n        </a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwNzI=","title":"Challenge 3: Draw the spots","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><p>Now you are saving spots, but not using them. Next, add code to display each one on the canvas.</p><div class=\"action\">\n<p>\nUse a <code>for loop</code> to get each spot in <code>spots</code> and then call the <code>show</code> function on it.</p>\n</div><p>Each time you click your mouse you should see a new colored spot where you just clicked:</p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P08-Arrays/assets/spot_0.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P08-Arrays/assets/spot_0.png\" alt=\"spot 0\" title=\"spot 0\">\n        </a></p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P08-Arrays/assets/spot_1.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P08-Arrays/assets/spot_1.png\" alt=\"spot 1\" title=\"spot 1\">\n        </a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwNzM=","title":"Challenge 4: Get the last color","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><p>Right now the <code>lastColor</code> function is just returning a default value of white, that is being used to color the box in the upper left corner.</p><div class=\"action\">\n<p>\nUpdate <code>lastColor</code> so that it returns the color of the most recently added spot. Return the default white when there are no spots yet.</p>\n</div><p>There are a few steps that you can break this challenge into:</p><ul>\n<li>check if there are any spots yet, if not, return white</li>\n<li>if there are spots, get the number of the last index in the array</li>\n<li>use the index to get the last spot object</li>\n<li>update <code>lastColor</code> to be the value of the color property of the last spot</li>\n</ul><div class=\"info\">\n<p>\nIn programming, <a href=\"https://en.wikipedia.org/wiki/Zero-based_numbering\" target=\"_blank\">counting often starts at 0</a>, especially when working with arrays.</p>\n</div><p>When your logic is working correctly, the upper left square should correctly match the color of the most recently added spot:</p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P08-Arrays/assets/last_color.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P08-Arrays/assets/last_color.png\" alt=\"last color\" title=\"last color\">\n        </a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwNzQ=","title":"Bonus 1: Add functionality","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><div class=\"challenge\">\n<p>\nUse 1 or more new array functions from <a href=\"https://p5js.org/reference/\" target=\"_blank\">https://p5js.org/reference/</a> to add new effects to your program.</p>\n</div>"}]},"next":{"id":"T0E6OlBhZ2UtMjQxMw==","slug":"io-api","title":"0.9 Input, Output, and APIs"},"previous":{"id":"T0E6OlBhZ2UtMjQxMw==","slug":"io-api","title":"0.9 Input, Output, and APIs"}},{"id":"T0E6OlBhZ2UtMjQxMw==","title":"0.9 Input, Output, and APIs","slug":"io-api","sections":{"nodes":[{"id":"T0E6OlNlY3Rpb24tMTIwNzU=","title":"0.9 Input, Output, and APIs","htmlContent":"<div class=\"action\">\n<p>\nAccess the assignment <a href=\"https://repl.it/@MakeSchoolRAMP/09-Input-Output-APIs\" target=\"_blank\">0.9 Input, Output, and APIs</a>.</p>\n</div><p>Remember to view the p5.js documentation as needed: <a href=\"http://p5js.org/reference/\" target=\"_blank\">http://p5js.org/reference/</a>.</p><h2>Watch <a href=\"https://www.youtube.com/watch?v=lAtoaRz78I4\" target=\"_blank\">Video 8.2 Creating HTML Elements with JavaScript</a>\n</h2><p><iframe width=\"640\" height=\"360\" src=\"https://www.youtube.com/embed/lAtoaRz78I4\" frameborder=\"0\" allowfullscreen></iframe></p><h2>Watch <a href=\"https://www.youtube.com/watch?v=NcCEzzd9BGE\" target=\"_blank\">Video 8.4  Handling DOM Events with Callbacks</a>\n</h2><p><iframe width=\"640\" height=\"360\" src=\"https://www.youtube.com/embed/NcCEzzd9BGE\" frameborder=\"0\" allowfullscreen></iframe></p><h2>Watch <a href=\"https://www.youtube.com/watch?v=587qclhguQg\" target=\"_blank\">Video 8.5 Interacting with the DOM using Sliders, Buttons and Text Inputs</a>\n</h2><p><iframe width=\"640\" height=\"360\" src=\"https://www.youtube.com/embed/587qclhguQg\" frameborder=\"0\" allowfullscreen></iframe></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwNzY=","title":"Challenge 1: Add your name","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><div class=\"action\">\n<p>\nModify the <code>displayTitle</code> function in <code>sketch.js</code> and add your name so that it says `YOURNAME's Joke Generator</p>\n</div>"},{"id":"T0E6OlNlY3Rpb24tMTIwNzc=","title":"Challenge 2: Allow user to input colors","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><p>The <code>assignColors</code> function currently assigns <code>backgroundColor</code> and <code>textColor</code> to default starting values. The goal is to allow the user to type in color names or hex codes to assign colors to the background and text so we&rsquo;ll need to add input fields for the user to type their preferred colors. </p><p>A helper function is already setup to create the first input - look through the starter code to find the function that you&rsquo;ll need to call during setup.</p><div class=\"action\">\n<p>\n2A Inside of <code>setup</code>, call the helper function that will add the color input elements to the page.</p>\n</div><p>Once you re-run you should see the new text and input added below the canvas. You can type in it but the value is not being used. To access the value of the user&rsquo;s input, you can reference it using dot notation <code>value()</code>.</p><div class=\"action\">\n<p>\n2B In the <code>assignColors</code> function, modify the first line so that the background color is set to <code>inputBGColor.value()</code>.</p>\n</div><p>Now you should see that the background color will change to match the color name or hex value that you type. Don&rsquo;t forget to include the <code>#</code> at the start of your hex codes.</p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P09-Input-Output-APIs/assets/color_input.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P09-Input-Output-APIs/assets/color_input.png\" alt=\"color_input\" title=\"color_input\">\n        </a></p><p>HINT: Right now, if there&rsquo;s no user input for the color it will default to white. Can you think of how to give it your own custom color when there isn&rsquo;t any user input yet?</p><p>Once you have things working for the background color, use it as your example and add another input for the user to enter a text color.</p><div class=\"action\">\n<p>\n2C Uncomment the global variable <code>inputTextColor</code>, then use it to modify <code>createColorInputs()</code> to add another text and input element, finally update <code>assignColors()</code> to assign <code>textColor</code> to the new input value.</p>\n</div><p>Confirm that you can now change both colors using the inputs:</p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P09-Input-Output-APIs/assets/check_colors.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P09-Input-Output-APIs/assets/check_colors.png\" alt=\"check_colors\" title=\"check_colors\">\n        </a></p><p>HINT: Remember, it will default to white when there isn&rsquo;t any user input at the start of the program. You can use || (or) to give a backup value to variables when the first option might be empty or null: <code>var exampleVariable = checkForValue() || &ldquo;defaultValue&rdquo;</code>.</p>"},{"id":"T0E6OlNlY3Rpb24tMTIwNzg=","title":"Challenge 3: Display and save jokes","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><p>Now that the page looks nice, let&rsquo;s get to the jokes. Soon we&rsquo;ll implement calling the Jokes API for random jokes, but first we&rsquo;ll add a sample joke for the page to load with. </p><div class=\"action\">\n<p>\n3A Uncomment the global variable <code>jokeInfo</code>, then assign it in the <code>setup</code> function to an object with two properties <code>category</code> and <code>joke</code>. </p>\n</div><p>You can use your own starting joke values, or this one from the &ldquo;Pun&rdquo; category - \"Oysters hate to give away their pearls because they are shellfish.\" xD</p><div class=\"action\">\n<p>\n3B Find the two uses of the <code>text</code> function insides of <code>displayJoke()</code> and change it to use the new values on the  <code>jokeInfo</code> object. </p>\n</div><p>Check that your page is now Laugh-Out-Loud hilarious...</p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P09-Input-Output-APIs/assets/first_joke.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P09-Input-Output-APIs/assets/first_joke.png\" alt=\"first_joke\" title=\"first_joke\">\n        </a></p><p>It&rsquo;s looking so good, let&rsquo;s give the user the ability to save the joke! Check out the <code>save</code> function in the p5.js reference.</p><div class=\"action\">\n<p>\n3C Find the helper function that creates the &ldquo;Save Joke&rdquo; button and call it in <code>setup</code>. Then find the function called <code>saveJoke</code> and implement the p5.js <code>save</code> function to save the current canvas as a JPG.</p>\n</div><p>NOTE: This function only works when website opened in another tab, not inside of the replit editor. Naviate to the public url located in the top of the output window:</p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P09-Input-Output-APIs/assets/public_url.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P09-Input-Output-APIs/assets/public_url.png\" alt=\"public_url\" title=\"public_url\">\n        </a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwNzk=","title":"Challenge 4: Call the Jokes API to generate new jokes on demand","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><p>The sample joke is of course toooootally hilarious, but just in case the user has a different sense of humor, let&rsquo;s connect our page up to JokeAPI for more joke diversity.</p><div class=\"action\">\n<p>\n4A Uncomment global variable <code>jokeURL</code> and assign a valid value to it in <code>setup()</code>.</p>\n</div><p>What's a valid URL?</p><div class=\"info\">\n<p>\nTo get a valid URL, visit <a href=\"https://v2.jokeapi.dev/#try-it\" target=\"_blank\">https://v2.jokeapi.dev/#try-it</a>\nUse &ldquo;default (json)&rdquo; as the format\nCheck &ldquo;single&rdquo; for joke type (handling &ldquo;twopart&rdquo; jokes is a stretch challenge!)\nOnly get 1 joke at a time</p>\n</div><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P09-Input-Output-APIs/assets/try_it.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P09-Input-Output-APIs/assets/try_it.png\" alt=\"try_it\" title=\"try_it\">\n        </a></p><p>Next we will use the <code>httpGet</code> function to call the API at the URL and get our joke response. The response is in JSON format, and you can see that it also has <code>joke</code> and <code>category</code> properties (in addition to others we aren&rsquo;t using), so we&rsquo;ll be able to save it directly to the <code>jokeInfo</code> object and the <code>displayJoke</code> function will work correctly.</p><div class=\"action\">\n<p>\n4B Find the <code>getNewJoke</code> function. Inside of the <code>httpGet</code> code block, add code between the { and } to set <code>jokeInfo</code> equal to <code>response</code>. Then add a <code>print(response)</code> so that you can see the full return value in the console.</p>\n</div><p>Re-run your program - you&rsquo;ll see your starter joke still. Test your new function by calling it in the console and checking that it prints out the return value from calling the JokeAPI:</p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P09-Input-Output-APIs/assets/console_check_2.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P09-Input-Output-APIs/assets/console_check_2.png\" alt=\"console_check_2\" title=\"console_check_2\">\n        </a></p><p>As the final final step we need 1 more button so that the user can click it to call the API for a new joke.</p><div class=\"action\">\n<p>\n4C Modify the <code>createButtons</code> function to add a second button for calling the JokeAPI.</p>\n</div><p>Enjoy generating and saving your favorite jokes!</p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P09-Input-Output-APIs/assets/jokes.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P09-Input-Output-APIs/assets/jokes.png\" alt=\"jokes\" title=\"jokes\">\n        </a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwODA=","title":"Bonus 1: Explore other user inputs for colors","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><div class=\"challenge\">\n<p>\nUse 1 or more other ways to collect user input for the color values. (Example: Check out <a href=\"https://p5js.org/reference/#/p5/createColorPicker\" target=\"_blank\">ColorPickers</a> ).</p>\n</div>"},{"id":"T0E6OlNlY3Rpb24tMTIwODE=","title":"Bonus 2: Explore more interactions with users and the JokeAPI","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><div class=\"challenge\">\n<p>\nExample: Update &lsquo;displayJoke&rsquo; to handle &ldquo;twopart&rdquo; jokes.\nExample: Allow the user to select which category of jokes they want to generate.</p>\n</div>"}]},"next":{"id":"T0E6OlBhZ2UtMjQxNA==","slug":"hello-oop","title":"1.0 Hello OOP"},"previous":{"id":"T0E6OlBhZ2UtMjQxNA==","slug":"hello-oop","title":"1.0 Hello OOP"}},{"id":"T0E6OlBhZ2UtMjQxNA==","title":"1.0 Hello OOP","slug":"hello-oop","sections":{"nodes":[{"id":"T0E6OlNlY3Rpb24tMTIwODI=","title":"1.0 Hello OOP","htmlContent":"<p>Note:\nStart here if you are already comfortable with the fundamentals of programming (variables, objects, functions, etc) and are ready to take on the challenge of building a larger object-oriented programming (OOP) project.</p><p>If you need a refresher on coding fundamentals, or are less comfortable working with JavaScript and the p5.js library, you are encouraged to start at Level 0 instead (assignment 0.0 Hello World).</p><p>If you just completed Level 0, <em>a hearty congratulations to you!</em> There is a big jump in difficulty between Level 0 and Level 1, but you've got this. :)</p><p>Happy coding!</p><div class=\"action\">\n<p>\nAccess the assignment <a href=\"https://repl.it/@MakeSchoolRAMP/10-Hello-OOP\" target=\"_blank\">1.0 Hello OOP</a>.</p>\n</div><p>Remember to view the p5.js documentation as needed: <a href=\"http://p5js.org/reference/\" target=\"_blank\">http://p5js.org/reference/</a>.</p><div class=\"info\">\n<p>\nYou can also always go back and refer to your previous assignments to remind yourself of how to do things!</p>\n</div>"},{"id":"T0E6OlNlY3Rpb24tMTIwODM=","title":"Challenge 1: Add your name","htmlContent":"<p><strong>in <code>index.html</code></strong></p><div class=\"action\">\n<p>\nFind the <code>h1</code> tags in <code>index.html</code> and add your name so that it says <code>YOURNAME's...</code></p>\n</div>"},{"id":"T0E6OlNlY3Rpb24tMTIwODQ=","title":"Challenge 2: Answer a question using the print function","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><div class=\"action\">\n<p>\nType your answer using the <code>print</code> function:</p>\n\n<p>Question: What is the difference between a class and an instance?</p>\n</div><p>View the console tab in the results panel to see your answer.</p>"},{"id":"T0E6OlNlY3Rpb24tMTIwODU=","title":"Challenge 3: Modify the Avatar constructor to take parameters","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><div class=\"action\">\n<p>\nModify the Avatar constructor to take the following parameters\n- <code>name</code>\n- <code>height</code>\n- <code>width</code>\n- <code>eyeColor</code>\n- <code>hairColor</code>\n- <code>hatColor</code></p>\n</div><p>Remember that your constructor also needs to <em>use</em> the parameters to assign values.</p>"},{"id":"T0E6OlNlY3Rpb24tMTIwODY=","title":"Challenge 4: Create an instance of the Avatar class","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><p>Now you can create an instance of your <code>Avatar</code> class.</p><div class=\"action\">\n<p>\nCreate an instance of your <code>Avatar</code> class.</p>\n</div><p>Ensure that:\n- the instance is assigned to a global variable so you can access it in later steps.\n- you are passing in ALL of the required parameters.</p>"},{"id":"T0E6OlNlY3Rpb24tMTIwODc=","title":"Challenge 5: Add a show() function to the Avatar class","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><p>Add code so that your Avatar is visible on the canvas.</p><div class=\"action\">\n<p>\nAdd a <code>show()</code> function to the <code>Avatar</code> class</p>\n</div><p>Ensure that:\n- the <code>show()</code> function is using all 8 of the Avatar properties to control the appearance\n- you call <code>show()</code> on your avatar instance in the <code>draw</code> function</p>"},{"id":"T0E6OlNlY3Rpb24tMTIwODg=","title":"Challenge 6: Add an updateLocation() function to the Avatar class","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><div class=\"action\">\n<p>\nAdd an <code>updateLocation()</code> function to the <code>Avatar</code> class that takes two parameters: <code>newX</code> and <code>newY</code></p>\n</div><p>Ensure that you:\n- Update the avatar's <code>x</code> and <code>y</code> values from the passed in parameters</p><div class=\"action\">\n<p>\nCall your new <code>updateLocation()</code> function with parameter values so that your avatar is always at the mouse location</p>\n\n<p>-</p>\n</div>"},{"id":"T0E6OlNlY3Rpb24tMTIwODk=","title":"Bonus 1: Make your avatar speak when the mouse is pressed","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><div class=\"challenge\">\n<p>\n- Give your avatar a catchphrase\n- Display the catchphrase on the canvas when the mouse is pressed\n- Use OOP to think about where your new code makes the most sense!</p>\n</div>"},{"id":"T0E6OlNlY3Rpb24tMTIwOTA=","title":"Bonus 2: Make your avatar speak random phrases","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><div class=\"challenge\">\n<p>\n- Modify your code so that avatars can have more than one catchphrase\n- Modify your code so that when the mouse is pressed, they speak one of their phrases at random</p>\n</div>"}]},"next":{"id":"T0E6OlBhZ2UtMjQxNQ==","slug":"game-of-life","title":"1.1 Build the Game of Life"},"previous":{"id":"T0E6OlBhZ2UtMjQxNQ==","slug":"game-of-life","title":"1.1 Build the Game of Life"}},{"id":"T0E6OlBhZ2UtMjQxNQ==","title":"1.1 Build the Game of Life","slug":"game-of-life","sections":{"nodes":[{"id":"T0E6OlNlY3Rpb24tMTIwOTE=","title":"1.1 Build the Game of Life","htmlContent":"<div class=\"action\">\n<p>\nAccess the assignment <a href=\"https://repl.it/@MakeSchoolRAMP/11-Build-the-Game-of-Life\" target=\"_blank\">1.1 Build the Game of Life</a>.</p>\n</div><p>Remember to view the p5.js documentation as needed: <a href=\"http://p5js.org/reference/\" target=\"_blank\">http://p5js.org/reference/</a>.</p><div class=\"info\">\n<p>\nYou can also always go back and refer to your previous assignments to remind yourself of how to do things!</p>\n</div>"},{"id":"T0E6OlNlY3Rpb24tMTIwOTI=","title":"Access the Instructions","htmlContent":"<p>Instructions will be ported over to live on this page in the future, but for now you can <a href=\"https://github.com/extrajordanary/p5js-game-of-life\" target=\"_blank\">read the instructions here</a>.</p>"}]},"next":null,"previous":null}]}},"page":{"id":"T0E6OlBhZ2UtMjQxMw==","title":"0.9 Input, Output, and APIs","slug":"io-api","sections":{"nodes":[{"id":"T0E6OlNlY3Rpb24tMTIwNzU=","title":"0.9 Input, Output, and APIs","htmlContent":"<div class=\"action\">\n<p>\nAccess the assignment <a href=\"https://repl.it/@MakeSchoolRAMP/09-Input-Output-APIs\" target=\"_blank\">0.9 Input, Output, and APIs</a>.</p>\n</div><p>Remember to view the p5.js documentation as needed: <a href=\"http://p5js.org/reference/\" target=\"_blank\">http://p5js.org/reference/</a>.</p><h2>Watch <a href=\"https://www.youtube.com/watch?v=lAtoaRz78I4\" target=\"_blank\">Video 8.2 Creating HTML Elements with JavaScript</a>\n</h2><p><iframe width=\"640\" height=\"360\" src=\"https://www.youtube.com/embed/lAtoaRz78I4\" frameborder=\"0\" allowfullscreen></iframe></p><h2>Watch <a href=\"https://www.youtube.com/watch?v=NcCEzzd9BGE\" target=\"_blank\">Video 8.4  Handling DOM Events with Callbacks</a>\n</h2><p><iframe width=\"640\" height=\"360\" src=\"https://www.youtube.com/embed/NcCEzzd9BGE\" frameborder=\"0\" allowfullscreen></iframe></p><h2>Watch <a href=\"https://www.youtube.com/watch?v=587qclhguQg\" target=\"_blank\">Video 8.5 Interacting with the DOM using Sliders, Buttons and Text Inputs</a>\n</h2><p><iframe width=\"640\" height=\"360\" src=\"https://www.youtube.com/embed/587qclhguQg\" frameborder=\"0\" allowfullscreen></iframe></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwNzY=","title":"Challenge 1: Add your name","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><div class=\"action\">\n<p>\nModify the <code>displayTitle</code> function in <code>sketch.js</code> and add your name so that it says `YOURNAME's Joke Generator</p>\n</div>"},{"id":"T0E6OlNlY3Rpb24tMTIwNzc=","title":"Challenge 2: Allow user to input colors","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><p>The <code>assignColors</code> function currently assigns <code>backgroundColor</code> and <code>textColor</code> to default starting values. The goal is to allow the user to type in color names or hex codes to assign colors to the background and text so we&rsquo;ll need to add input fields for the user to type their preferred colors. </p><p>A helper function is already setup to create the first input - look through the starter code to find the function that you&rsquo;ll need to call during setup.</p><div class=\"action\">\n<p>\n2A Inside of <code>setup</code>, call the helper function that will add the color input elements to the page.</p>\n</div><p>Once you re-run you should see the new text and input added below the canvas. You can type in it but the value is not being used. To access the value of the user&rsquo;s input, you can reference it using dot notation <code>value()</code>.</p><div class=\"action\">\n<p>\n2B In the <code>assignColors</code> function, modify the first line so that the background color is set to <code>inputBGColor.value()</code>.</p>\n</div><p>Now you should see that the background color will change to match the color name or hex value that you type. Don&rsquo;t forget to include the <code>#</code> at the start of your hex codes.</p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P09-Input-Output-APIs/assets/color_input.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P09-Input-Output-APIs/assets/color_input.png\" alt=\"color_input\" title=\"color_input\">\n        </a></p><p>HINT: Right now, if there&rsquo;s no user input for the color it will default to white. Can you think of how to give it your own custom color when there isn&rsquo;t any user input yet?</p><p>Once you have things working for the background color, use it as your example and add another input for the user to enter a text color.</p><div class=\"action\">\n<p>\n2C Uncomment the global variable <code>inputTextColor</code>, then use it to modify <code>createColorInputs()</code> to add another text and input element, finally update <code>assignColors()</code> to assign <code>textColor</code> to the new input value.</p>\n</div><p>Confirm that you can now change both colors using the inputs:</p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P09-Input-Output-APIs/assets/check_colors.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P09-Input-Output-APIs/assets/check_colors.png\" alt=\"check_colors\" title=\"check_colors\">\n        </a></p><p>HINT: Remember, it will default to white when there isn&rsquo;t any user input at the start of the program. You can use || (or) to give a backup value to variables when the first option might be empty or null: <code>var exampleVariable = checkForValue() || &ldquo;defaultValue&rdquo;</code>.</p>"},{"id":"T0E6OlNlY3Rpb24tMTIwNzg=","title":"Challenge 3: Display and save jokes","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><p>Now that the page looks nice, let&rsquo;s get to the jokes. Soon we&rsquo;ll implement calling the Jokes API for random jokes, but first we&rsquo;ll add a sample joke for the page to load with. </p><div class=\"action\">\n<p>\n3A Uncomment the global variable <code>jokeInfo</code>, then assign it in the <code>setup</code> function to an object with two properties <code>category</code> and <code>joke</code>. </p>\n</div><p>You can use your own starting joke values, or this one from the &ldquo;Pun&rdquo; category - \"Oysters hate to give away their pearls because they are shellfish.\" xD</p><div class=\"action\">\n<p>\n3B Find the two uses of the <code>text</code> function insides of <code>displayJoke()</code> and change it to use the new values on the  <code>jokeInfo</code> object. </p>\n</div><p>Check that your page is now Laugh-Out-Loud hilarious...</p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P09-Input-Output-APIs/assets/first_joke.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P09-Input-Output-APIs/assets/first_joke.png\" alt=\"first_joke\" title=\"first_joke\">\n        </a></p><p>It&rsquo;s looking so good, let&rsquo;s give the user the ability to save the joke! Check out the <code>save</code> function in the p5.js reference.</p><div class=\"action\">\n<p>\n3C Find the helper function that creates the &ldquo;Save Joke&rdquo; button and call it in <code>setup</code>. Then find the function called <code>saveJoke</code> and implement the p5.js <code>save</code> function to save the current canvas as a JPG.</p>\n</div><p>NOTE: This function only works when website opened in another tab, not inside of the replit editor. Naviate to the public url located in the top of the output window:</p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P09-Input-Output-APIs/assets/public_url.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P09-Input-Output-APIs/assets/public_url.png\" alt=\"public_url\" title=\"public_url\">\n        </a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwNzk=","title":"Challenge 4: Call the Jokes API to generate new jokes on demand","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><p>The sample joke is of course toooootally hilarious, but just in case the user has a different sense of humor, let&rsquo;s connect our page up to JokeAPI for more joke diversity.</p><div class=\"action\">\n<p>\n4A Uncomment global variable <code>jokeURL</code> and assign a valid value to it in <code>setup()</code>.</p>\n</div><p>What's a valid URL?</p><div class=\"info\">\n<p>\nTo get a valid URL, visit <a href=\"https://v2.jokeapi.dev/#try-it\" target=\"_blank\">https://v2.jokeapi.dev/#try-it</a>\nUse &ldquo;default (json)&rdquo; as the format\nCheck &ldquo;single&rdquo; for joke type (handling &ldquo;twopart&rdquo; jokes is a stretch challenge!)\nOnly get 1 joke at a time</p>\n</div><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P09-Input-Output-APIs/assets/try_it.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P09-Input-Output-APIs/assets/try_it.png\" alt=\"try_it\" title=\"try_it\">\n        </a></p><p>Next we will use the <code>httpGet</code> function to call the API at the URL and get our joke response. The response is in JSON format, and you can see that it also has <code>joke</code> and <code>category</code> properties (in addition to others we aren&rsquo;t using), so we&rsquo;ll be able to save it directly to the <code>jokeInfo</code> object and the <code>displayJoke</code> function will work correctly.</p><div class=\"action\">\n<p>\n4B Find the <code>getNewJoke</code> function. Inside of the <code>httpGet</code> code block, add code between the { and } to set <code>jokeInfo</code> equal to <code>response</code>. Then add a <code>print(response)</code> so that you can see the full return value in the console.</p>\n</div><p>Re-run your program - you&rsquo;ll see your starter joke still. Test your new function by calling it in the console and checking that it prints out the return value from calling the JokeAPI:</p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P09-Input-Output-APIs/assets/console_check_2.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P09-Input-Output-APIs/assets/console_check_2.png\" alt=\"console_check_2\" title=\"console_check_2\">\n        </a></p><p>As the final final step we need 1 more button so that the user can click it to call the API for a new joke.</p><div class=\"action\">\n<p>\n4C Modify the <code>createButtons</code> function to add a second button for calling the JokeAPI.</p>\n</div><p>Enjoy generating and saving your favorite jokes!</p><p><a href=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P09-Input-Output-APIs/assets/jokes.png\" target=\"_blank\">\n          <img src=\"https://cdn.jsdelivr.net/gh/MakeSchool-Tutorials/Ramp-Level-0@24e7e91f056c670434bd8a208ec378fca605ca5b/P09-Input-Output-APIs/assets/jokes.png\" alt=\"jokes\" title=\"jokes\">\n        </a></p>"},{"id":"T0E6OlNlY3Rpb24tMTIwODA=","title":"Bonus 1: Explore other user inputs for colors","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><div class=\"challenge\">\n<p>\nUse 1 or more other ways to collect user input for the color values. (Example: Check out <a href=\"https://p5js.org/reference/#/p5/createColorPicker\" target=\"_blank\">ColorPickers</a> ).</p>\n</div>"},{"id":"T0E6OlNlY3Rpb24tMTIwODE=","title":"Bonus 2: Explore more interactions with users and the JokeAPI","htmlContent":"<p><strong>in <code>sketch.js</code></strong></p><div class=\"challenge\">\n<p>\nExample: Update &lsquo;displayJoke&rsquo; to handle &ldquo;twopart&rdquo; jokes.\nExample: Allow the user to select which category of jokes they want to generate.</p>\n</div>"}]},"next":{"id":"T0E6OlBhZ2UtMjQxNA==","slug":"hello-oop","title":"1.0 Hello OOP"},"previous":{"id":"T0E6OlBhZ2UtMjQxNA==","slug":"hello-oop","title":"1.0 Hello OOP"}}}},"staticQueryHashes":[]}