<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Harry Banda on Medium]]></title>
        <description><![CDATA[Stories by Harry Banda on Medium]]></description>
        <link>https://medium.com/@harrybanda?source=rss-1520ee9d7361------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*NQnBIJ5oQcqKSeZS2pg5Zw.jpeg</url>
            <title>Stories by Harry Banda on Medium</title>
            <link>https://medium.com/@harrybanda?source=rss-1520ee9d7361------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 23:17:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@harrybanda/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[What I Learned Building a Spatial AR Memory Game for Spectacles.]]></title>
            <link>https://medium.com/@harrybanda/what-i-learned-building-a-spatial-ar-memory-game-for-spectacles-b177b0d7648a?source=rss-1520ee9d7361------2</link>
            <guid isPermaLink="false">https://medium.com/p/b177b0d7648a</guid>
            <category><![CDATA[augmented-reality]]></category>
            <category><![CDATA[game-design]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[spectacles]]></category>
            <category><![CDATA[mixed-reality]]></category>
            <dc:creator><![CDATA[Harry Banda]]></dc:creator>
            <pubDate>Sun, 15 Feb 2026 15:17:15 GMT</pubDate>
            <atom:updated>2026-02-15T15:17:15.539Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B4sVxbIypz0x6jmb7Axr3w.png" /></figure><p>When you build a game where people memorize a path on a floor grid and then walk it from memory, you run into a few things: a clear view of the whole grid and reliable knowledge of where the player is standing. This is the story of how I worked around those limits and what I’d do differently next time.</p><p><strong>The project is open source:</strong> <a href="https://github.com/harrybanda/memory-grid">https://github.com/harrybanda/memory-grid</a>. Clone it, open it in Lens Studio, and explore.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/420/1*ncP1te4Dfk5TFacsCFrLHg.gif" /><figcaption>Memory Grid on Spectacles</figcaption></figure><h3>Where It Started</h3><p>The Cube, a British game show I used to watch with my family a few years ago, stuck with me. One of its challenges was a memory path: contestants studied a sequence of tiles on the floor, then had to walk it from memory. The tension of watching someone hesitate, step wrong, and get eliminated made for great TV. I kept thinking it would translate well to AR: you’re already in physical space, you’re already moving. Why not put the grid on your floor?</p><figure><img alt="The Cube UK — TV Show" src="https://cdn-images-1.medium.com/max/480/1*-cAY8DsfLSo3hIIwtEJDEg.gif" /><figcaption>The Cube UK — TV Show</figcaption></figure><p>I didn’t want to copy it exactly. The show’s version was a single high-stakes round. I wanted something you could <em>live in</em> with progression, variety, and room to improve. So I expanded it to 11 levels, with path length increasing as you advance, and added 12 unlockable achievements. The result is a full game with its own rhythm and feel, but the core idea: memorize, then walk still comes from that family living room and The Cube.</p><h3>You Can’t See the Whole Grid So Don’t Show It</h3><p>Spectacles have a tight field of view. A 5×5 grid of half-meter tiles spans more floor than you can comfortably take in at once. Early on, I tried revealing the full path in one go. Playtesters would stare at the grid, pan their head, miss tiles, then fail. The memorize phase felt like a race against a clock they couldn’t win.</p><p>The fix was to stop competing with the FOV and work with it. Instead of showing everything at once, the path <em>reveals itself</em> tile by tile. The yellow start tile appears first right where the player is looking after they place the grid. Then tile two, then three, each with a bounce animation and an arrow pointing to the next. The path draws itself from the player’s perspective. They don’t have to scan; they follow.</p><p>That only works if the start is where they expect it. The grid is placed with Snap’s Surface Placement package pinch to drop a tracker on the floor. The grid extends <em>away</em> from that point, and the path always starts on the near edge, the row closest to them. So the first thing they see after “go” is the yellow tile, front and center.</p><p>Paths use orthogonal moves only up, down, left, right. No diagonals. It matches how people actually walk and keeps the flow readable. For the longest levels (23+ tiles on a near-full grid), random path generation kept painting into corners and failing. I switched to Warnsdorff’s heuristic: when choosing the next step, prefer the neighbor with fewer unvisited neighbors. It’s an old trick for avoiding dead ends, and it made the hard levels generate reliably.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*AgLuQw1qpwtSDoV84dzEbQ.gif" /><figcaption>FOV Fix: Follow the next tile</figcaption></figure><h3>The Head Isn’t the Feet</h3><p>With Spectacles, you can track the user’s position by checking the translation value of the device. The device doesn’t really have a way to track your feet, your body, or your skeleton. For a walking game, that’s a problem. The obvious approach: project the camera position straight down onto the floor and treat that as where the player is standing. Works fine on paper. In practice, it broke constantly.</p><p>People lean. They lean forward to look at a tile. They lean to the side. A typical lean moves your head 15-40 centimeters without your feet moving. In a 50 cm tile grid, a 25 cm lean is enough to shift the projected point from one tile into another. The game would trigger the wrong tile, or no tile, or two tiles in a row. Playtesters would step correctly and get “wrong step.” Or they’d lean to read a tile and suddenly “complete” a step they never took.</p><p>I tried tightening the detection radius. I tried requiring a minimum distance moved before registering a new tile. I tried raycasting down from the camera. Same fundamental issue: everything was derived from head position, and head position lies when you lean.</p><p>The solution was to stop estimating and start measuring. Instead of projecting position and doing distance checks, I put a <em>trigger collider</em> at each tile center a vertical plane, about 40 cm wide and 60 cm tall, thin in depth. I added a small collider to the camera. A tile activates only when the camera collider *<em>enters</em>* that trigger. Walking moves your head through space; the collider passes through the plane. Leaning rotates your head in place; the collider doesn’t move far enough to cross into the next tile’s narrow zone. Physics does the work. Overlap or no overlap no guesswork.</p><p>There were a few gotchas. UI and buttons can have colliders too; if you’re not careful, looking at a menu can trigger a tile. The trigger script checks that the overlapping collider belongs to the camera object itself, not a child. And each trigger needs to reset between rounds so it can fire again.</p><p>This pattern is built for grid-based layouts tight, evenly spaced tiles. For open-world zones or sparse triggers, you’d use something else. But for this kind of game, it was the difference between <strong>frustrating and fun</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i24dxKcVLAmTR6yX3svJ2Q.png" /></figure><h3>In Retrospect</h3><p>Memory Grid came together when I stopped fighting the hardware. The FOV is small so the path reveals itself instead of demanding a panorama. Head tracking isn’t foot tracking so physics overlap replaces position projection. Each piece solves a real problem I hit while building; none of it was theoretical.</p><p>If you’re working on a similar Spectacles experience, grid-based, step-based, or anything where “where am I standing?” matters the collider approach is worth a look. The full project is on GitHub. Fork it, break it, make it yours.</p><p><strong>The project is open source:</strong> <a href="https://github.com/harrybanda/memory-grid">https://github.com/harrybanda/memory-grid</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b177b0d7648a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Behind the Prompt: Why Taste and Creativity Still Matter in the Age of AI]]></title>
            <link>https://medium.com/@harrybanda/behind-the-prompt-why-taste-and-creativity-still-matter-in-the-age-of-ai-102eb43a264e?source=rss-1520ee9d7361------2</link>
            <guid isPermaLink="false">https://medium.com/p/102eb43a264e</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[creativity]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[vibe-coding]]></category>
            <dc:creator><![CDATA[Harry Banda]]></dc:creator>
            <pubDate>Mon, 31 Mar 2025 19:36:21 GMT</pubDate>
            <atom:updated>2025-03-31T19:36:21.576Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*24iU_Di6DIjeiKTS" /><figcaption>Photo by <a href="https://unsplash.com/@jannerboy62?utm_source=medium&amp;utm_medium=referral">Nick Fewings</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Over the past week, I’ve been deep into what people call <em>“vibe coding”</em> which is using AI to generate code from natural language prompts. At first, it felt like I’d unlocked a cheat code. Describe a feature, and boom working code, ready to test and tweak.</p><p>But after a few days of riding that wave, I had a realization:</p><blockquote><strong><em>AI can generate code, but it can’t generate taste and creativity.</em></strong></blockquote><h4><strong>What Is Taste?</strong></h4><p>Before we dive deeper, let’s clarify something important: What do I mean by “taste” and “creativity”?</p><p>At its core, <strong>taste</strong> is your ability to recognize what’s <em>good</em>, what <em>feels right</em>, and what <em>works </em>not just technically but aesthetically, emotionally, and experientially. <strong>Creativity</strong> is your ability to come up with new ideas, solutions, or expressions that are original and valuable. It’s the act of bringing something into existence that didn’t exist before</p><p><strong>An Example of Taste and Creativity in UI/UX design: The iPhone’s “Rubber Band” Effect</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*FrBrqUoCgfaO1OYeItlgwg.gif" /></figure><p>When Steve Jobs introduced the first iPhone in 2007, there were a lot of revolutionary things: multi-touch, fluid gestures, a full-screen interface. But one tiny detail stood out to anyone paying close attention:</p><blockquote><strong><em>When you scrolled to the end of a page, it bounced.</em></strong></blockquote><p>Not because it had to.</p><p>Not because it was functionally necessary.</p><p>But because it felt <em>right</em>.</p><p><strong>An Example of Taste and Creativity in Game Development: </strong><a href="https://www.davetech.co.uk/gamedevscreenshake"><strong>Screen Shake</strong></a><strong>!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*qSjmfUhGG0JmaWAJjgZWqg.gif" /></figure><p>It’s just a small camera movement. But when you land a hit or trigger an explosion and the screen <em>shakes</em> you <em>feel</em> it. It adds weight, energy, chaos. It makes a basic mechanic feel <strong>visceral</strong> and <strong>satisfying</strong>.</p><p>No game engine requires it. No AI would add it by default If it was not thought out first by a human. A game developer with <em>taste</em> and <em>experience</em> knows that just 5 pixels of camera jiggle can elevate a moment from meh to <em>f*** yeah</em>.</p><blockquote><em>These are just a few examples of sparks of human creativity AI can’t generate unless it’s already been trained on them.</em></blockquote><p>It became clear after vibe coding that all the AI does is assemble pieces of what already exists. Useful? Absolutely. But to build something that <em>feels</em> good, something fun, creative, or meaningful, you still need to show up with <strong>skill</strong>, <strong>intuition</strong>, <strong>imagination, </strong>and an obsession over<strong> attention to detail.</strong></p><p>Let me explain.</p><h4><strong>1. Prompts Are a Reflection of Experience</strong></h4><p>The more software you’ve built, the better your prompts become.</p><p>When you’ve been in the trenches writing code, shipping features, fixing bugs, and rewriting things from scratch, you develop a kind of sixth sense. You know what to ask the AI. You can picture the architecture in your head before typing a single word. You understand tradeoffs, edge cases, and when to override the AI’s suggestions.</p><p>Prompting isn’t just <em>talking to the AI </em>it’s design thinking disguised as text. And that only clicks when you’ve got real-world context.</p><h4><strong>2. Game Development Needs Creativity, Not Just Code</strong></h4><p>I’ve built a number of game projects 2D, 3D, and XR. You’d think generating the core logic would be the hardest part.</p><p>Nope.</p><p>The real challenge? Making the game <strong>feel</strong> good.</p><p>Game development is 80% intuition. You tweak a mechanic because something feels off. You add an animation or delay because the rhythm isn’t right. Sometimes, you even break your own rules because it makes the game more fun.</p><p>That kind of instinct doesn’t come from code. It comes from <strong>playing</strong>, <strong>experimenting</strong>, and <strong>caring</strong> about the experience.</p><p>AI doesn’t have that.</p><h4><strong>3. AI Mirrors the Past, You Remix the Future</strong></h4><p>AI is incredible at repeating what it’s seen. Want to build a flight simulator? It can do that. A simple platformer? No problem.</p><p>But what about a surreal puzzle game that blends the flow of <a href="https://en.wikipedia.org/wiki/Journey_(2012_video_game)"><em>Journey</em></a>, the loop of <a href="https://en.wikipedia.org/wiki/Loop_Hero"><em>Loop Hero</em></a>, and the physics of <a href="https://en.wikipedia.org/wiki/Katamari"><em>Katamari</em></a>? or a completely new experience. That’s where <strong>you</strong> come in.</p><p>Creative ideas don’t emerge from autocomplete. They come from <strong>cross-pollination, </strong>from playing a weird indie game last night, remembering a mechanic from a childhood favorite, and wondering:</p><p><em>“What if I combined these?”</em></p><p>That’s not something AI can do. Not yet. And maybe never.</p><h4><strong>4. Creativity Drives the Future, Not Just the Present</strong></h4><p>Now think about the new frontier: <strong>AR glasses, spatial computing, neural interfaces</strong>. These platforms don’t just need code they need <strong>new ideas</strong>.</p><p>And those ideas won’t come from a trained dataset. They’ll come from <strong>experimentation</strong>, <strong>imagination</strong>, and the willingness to try weird, unproven stuff just to see how it <em>feels</em>.</p><blockquote><em>AI is evolving fast. But the real advantage isn’t automation it’s imagination.</em></blockquote><p>The most groundbreaking experiences of the next era will come from people bold enough to invent things <strong>AI has never seen before</strong>, that it has <strong>no context</strong> for, and <strong>no training data</strong> to draw from.</p><p>That’s the human edge.</p><h4><strong>Final Thoughts: Taste Can’t Be Faked</strong></h4><p>AI is here, and it’s here to stay. It’s becoming a powerful part of our creative workflows, and I fully embrace it.</p><p>But it’s not magic. It doesn’t replace <strong>deep thinking</strong>, <strong>creative risk-taking</strong>, or <strong>personal taste</strong>.</p><p>Once you’ve built that foundation, AI becomes a superpower.</p><p>But without taste or creativity?</p><p>You’re just vibe coding with no rhythm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*zkBkJT7vkIXhWrRKZBh8rw.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=102eb43a264e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Will AI Take the Joy Out of Learning to Code?]]></title>
            <link>https://medium.com/@harrybanda/will-ai-take-the-joy-out-of-learning-to-code-fe77bbf5ccfb?source=rss-1520ee9d7361------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe77bbf5ccfb</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[programing]]></category>
            <category><![CDATA[problem-solving]]></category>
            <category><![CDATA[coding-skills]]></category>
            <category><![CDATA[future-of-coding]]></category>
            <dc:creator><![CDATA[Harry Banda]]></dc:creator>
            <pubDate>Sun, 23 Feb 2025 23:11:19 GMT</pubDate>
            <atom:updated>2025-02-23T23:11:19.101Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ucO68TMKPfDeP71l" /><figcaption>Photo by <a href="https://unsplash.com/@theshubhamdhage?utm_source=medium&amp;utm_medium=referral">Shubham Dhage</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>In 2015, I embarked on a journey to create my first game, <a href="https://play.google.com/store/apps/details?id=com.harrybanda.spinblaster&amp;pcampaignid=web_share"><em>Spin Blaster</em></a><em>.</em> It wasn’t a clone of an existing title, it was an original idea born from sketches on paper before a single line of code was written. The premise was simple yet unique: an object spins around the circumference of a circle, shooting enemies that spawn inside. The goal? Prevent those enemies from escaping the circle’s boundary.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/458/1*N9tWJnPKLnBKeENFuz1WFg.png" /><figcaption>Original sketch of Spin Blaster</figcaption></figure><p>Bringing <em>Spin Blaster</em> to life using Java and <a href="https://libgdx.com/">LibGDX</a> was a grueling yet rewarding experience. Unlike modern engines with drag-and-drop functionality, LibGDX required everything to be coded manually. Every bug fixed, feature implemented, and mechanic fine-tuned felt like a personal achievement.</p><p>Fast forward to 2025, and advancements in AI have transformed game development. What once took months can now be done in minutes. But does this progress come at a cost? Will AI strip away the joy of learning and problem-solving that made game development so fulfilling?</p><h3>The Struggles of Game Development before AI tools</h3><h4>Hitting the First Roadblock: Making an Object Rotate Around a Circle</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*HJ27p3yz2IXnhME9O-5I9w.gif" /></figure><p>After deciding on the core mechanic of <em>Spin Blaster</em>, my first challenge was coding an object to rotate around a circle’s circumference “How hard could it be?” I thought. With limited experience, I instinctively Googled the problem:</p><blockquote>“How to make a sprite rotate around the circumference of a circle in LibGDX”</blockquote><p>Unfortunately, the search yielded no relevant results. I found solutions for Unity and other engines, but not for Java and LibGDX. Determined, I reverse-engineered solutions from other engines and adapted the logic to Java.</p><h4>The Deep Dive into Trigonometry and Math</h4><p>I soon realized that understanding the math behind rotation was crucial. After hours of research, I learned that a point on a circle with radius <em>r</em>, centered at the origin, is calculated as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/271/1*sXn5aVz0VQFlQ0pRpbptOA.png" /></figure><p>Implementing this in Java seemed straightforward, but my initial attempts failed. Sometimes the sprite disappeared off-screen or glitched unpredictably. Days of debugging revealed three critical mistakes:</p><ol><li>Angles needed to be converted to radians.</li><li>Using integers instead of floats caused precision issues.</li><li>The sprite’s center point needed proper alignment.</li></ol><p>After addressing these issues, the final code worked perfectly:</p><pre>x = (float) ((Constants.CENTER_X - Constants.PLAYER_SIZE / 2) -<br>    (Constants.PERIMETER_RADIUS - 5) * Math.cos(Math.toRadians(angle)));<br>y = (float) ((Constants.CENTER_Y - Constants.PLAYER_SIZE / 2) -<br>    (Constants.PERIMETER_RADIUS - 5) * Math.sin(Math.toRadians(angle)));</pre><p>The sense of accomplishment was immense not just because the code worked, but because I understood the math behind it.</p><h3>The Joy of the Struggle</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/266/1*_jfwNmyTIV0zTolJJU69qw.gif" /><figcaption>Spin Blaster Final Game</figcaption></figure><p>That was just one piece of the puzzle. I still had to code enemy spawns, collision detection, and memory optimization. Each challenge required research, experimentation, and persistence. By the time <em>Spin Blaster</em> was finished, I had significantly improved my skills in:</p><ul><li>Game development concepts</li><li>Java and LibGDX</li><li>Trigonometry and physics</li><li>Memory management and optimization</li><li>Even C# and Unity through cross-referencing solutions</li></ul><p>Looking back, if AI tools like ChatGPT had existed, I could have asked:</p><blockquote>“Write LibGDX code to make a sprite rotate around a circle.”</blockquote><p>And in seconds, I would’ve had a working solution.</p><p>Would it have saved time? Absolutely.</p><p>Would I have truly understood what was happening? Probably not.</p><h3>Will AI Kill the Fun?</h3><h4>The Joy of Problem-Solving</h4><p>Solving a problem after hours of frustration is incredibly rewarding. The struggle forced me to dig deep, read documentation, analyze code, and experiment until I found a solution. Each victory boosted my confidence and deepened my understanding.</p><p>Today, AI changes that dynamic. When faced with a coding challenge, a developer can simply type a prompt into a chatbot and receive a perfect solution in seconds. While this saves time, it also removes the process of trial and error that leads to real learning.</p><h4>Is AI Robbing Developers of the Joy of Learning?</h4><p>I worry that AI might deprive developers of the joy that comes from overcoming challenges. When AI provides instant answers, there’s less incentive to explore, experiment, and truly understand the underlying concepts. The struggle that once led to growth and mastery is now bypassed.</p><h4>Does “Understanding the Code” Even Matter Anymore?</h4><p>With AI handling technical complexity, future developers might not need to understand how things work under the hood. This raises an important question: Is deep understanding still necessary?</p><p>Personally, I believe it is. Understanding the fundamentals of coding makes developers better problem-solvers. But as AI continues to evolve, the need for this deep knowledge might diminish.</p><h3>My Personal Reflection</h3><p>I still enjoy the process of building and learning. I often avoid using AI just to challenge myself and deepen my understanding. There’s something special about sketching an algorithm on paper and figuring it out through trial and error.</p><p>At the same time, I recognize AI’s benefits. It speeds up development, allows faster prototyping, and frees us from tedious coding tasks. Moving forward, developers may no longer need to struggle because AI can handle those challenges instantly.</p><p>So, is this a good thing or a bad thing?</p><h4>Should People Still Learn to Build from Scratch?</h4><p>Yes. Struggling through problems teaches critical thinking, problem-solving, and creativity. It helps developers understand the solutions they implement, making them more capable and confident.</p><h4>Will Future Developers Miss Out on Valuable Learning Experiences?</h4><p>Most likely, yes. As AI takes over the more difficult aspects of coding, future developers may miss out on the sense of accomplishment that comes from solving problems on their own.</p><h4>Is There Still a Place for Hand-Crafted Problem-Solving?</h4><p>For now, yes. Human creativity and problem-solving are still essential. While AI can assist with coding, it lacks the originality and intuition that humans bring to the table. However, as AI continues to improve, its role in the development process will only grow.</p><h3>Final Thoughts</h3><p>I encourage developers to embrace AI as a tool, not a crutch. Use it to save time and streamline your workflow, but don’t skip the learning process. Solve problems on your own first, then use AI to refine your solutions.</p><p>Most importantly, keep building, learning, and challenging yourself. Because no matter how advanced AI becomes, the joy of creating something with your own hands will always be unmatched.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe77bbf5ccfb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build a book management app with Forge.]]></title>
            <link>https://medium.com/@harrybanda/build-a-book-management-app-with-forge-8b2f4e1e9092?source=rss-1520ee9d7361------2</link>
            <guid isPermaLink="false">https://medium.com/p/8b2f4e1e9092</guid>
            <dc:creator><![CDATA[Harry Banda]]></dc:creator>
            <pubDate>Sun, 30 Oct 2022 10:03:19 GMT</pubDate>
            <atom:updated>2025-02-23T22:17:30.494Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qO6n_R8nz_VIMZiD" /><figcaption>Photo by <a href="https://unsplash.com/@inakihxz?utm_source=medium&amp;utm_medium=referral">Iñaki del Olmo</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>In this tutorial you will build a <a href="https://developer.atlassian.com/platform/forge/">Forge</a> application that works on the <a href="https://www.atlassian.com/software/confluence">Confluence</a> page. You will learn how to use the <a href="https://developer.atlassian.com/platform/forge/ui-kit/">Forge UI Kit</a> to create user interfaces and learn how to use the <a href="https://developer.atlassian.com/platform/forge/runtime-reference/storage-api/">Storage API</a> to store information.</p><h4>What is Forge?</h4><p>If you are new to Atlassian products you might be asking “what is Forge?”. Forge is an app development platform designed to revolutionize how Atlassian cloud products are customized, extended, and integrated. Atlassian announced Forge at the beginning of 2020. With Forge, you don’t need to have your own infrastructure for building Atlassian applications.</p><h4>Tutorial Key Concepts</h4><p>This tutorial will cover the following key concepts:</p><ul><li>How to build UI with <a href="https://developer.atlassian.com/platform/forge/ui-kit/">Forge UI KIT</a></li><li>How to manage information with the <a href="https://developer.atlassian.com/platform/forge/runtime-reference/storage-api/">Forge Storage API</a></li></ul><h4>What You’ll Build</h4><p>This tutorial will guide you in a step-by-step process to create a book management application with Forge. By the end of the tutorial, we should have an application running on a Confluence page that is able to save, read, update and delete book information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*lrmWOkc5RfpRKUPsDoZtvQ.png" /><figcaption>Book Management Forge Application</figcaption></figure><h3>Getting Started</h3><p>Before you begin building the book management application you need to set up your development environment, to do that follow this quick G<a href="https://developer.atlassian.com/platform/forge/getting-started/">etting started guide</a> before working through this tutorial.</p><h4>Create your app</h4><p>Navigate to the directory where you want to create the app. A new subdirectory with the app’s name will be created there. Create your app by running:</p><pre>forge create</pre><ol><li>Enter a name for your app as <em>forge-app-crud.</em></li><li>Select the <em>UI kit</em> category.</li><li>Select the <em>confluence-macro</em> template.</li><li>Change to the app subdirectory to see the app files:</li></ol><pre>cd forge-app-crud</pre><h4>Install your app</h4><ol><li>Navigate to the app’s top-level directory and deploy your app by running:</li></ol><pre>forge deploy</pre><p>2. Install your app by running:</p><pre>forge install</pre><p>3. Select your Atlassian product using the arrow keys and press the enter key.</p><p>4. Enter the URL for your development site. For example, <em>example.atlassian.net</em>.</p><p>Once the <em>successful installation</em> message appears, your app is installed and ready to use on the specified site. You can always delete your app from the site by running the forge uninstall command.</p><p>With your app installed, it’s time to see the app on a page.</p><ol><li>Edit a Confluence page on your development site.</li><li>Open the quick insert menu by typing <em>/your macro title</em> on the page. Once you start typing the title <em>/Forge app for</em>, the macro with your name will appear in the quick insert menu.</li><li>Select your macro from the menu to add it to the page.</li><li>Publish the page.</li></ol><p>Your hello world app is now installed on your development site. The app should display on the page like the image below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/967/1*ZzTZ2hnihshfWDepyFks-w.png" /></figure><h3>Building UI with UI Kit</h3><p>Once your Forge application has been installed we can start witing some code first let’s create 2 files in the src directory <em>BooksTable.jsx and BookDialog.jsx. </em>Your directory should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/245/1*-WMhggUIvrDWFYYDZ5Vavw.png" /><figcaption>Added 2 files</figcaption></figure><p>Open <em>BooksTable.jsx </em>and add the following code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f34248aa90cf4c478adb11bff479c195/href">https://medium.com/media/f34248aa90cf4c478adb11bff479c195/href</a></iframe><p>In the code above we have created a component called <em>BooksTable </em>that returns Forge UI components, we have <a href="https://developer.atlassian.com/platform/forge/ui-kit-components/button/">Buttons</a> to add, edit, delete Books and a <a href="https://developer.atlassian.com/platform/forge/ui-kit-components/table/">Table</a> to display book information.</p><p>Next, open the <em>BookDialog.jsx </em>file and add the following code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4bb7166f44103a99dfbd71b317ce100d/href">https://medium.com/media/4bb7166f44103a99dfbd71b317ce100d/href</a></iframe><p>From the code above we have created a component called <em>BookDialog </em>that returns a <a href="https://developer.atlassian.com/platform/forge/ui-kit-components/modal-dialog/">ModalDialog</a> with a <a href="https://developer.atlassian.com/platform/forge/ui-kit-components/form/">Form</a>. In the <em>onSubmit</em> function, we save the book information from the form to the <em>books</em> array.</p><p>Next open <em>index.jsx</em> and add the following code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/07452949fe44dae64551e393038e238f/href">https://medium.com/media/07452949fe44dae64551e393038e238f/href</a></iframe><p>In the code above we import <em>BooksTable </em>and<em> BookDialog </em>into the<em> index </em>file, we then create the <em>isOpenModal</em> state to keep track of the modal and the <em>books</em> array to store our book information.</p><p>Next run forge deploy in your terminal to deploy your changes, once deployment completes refresh your Confluence page and you should see an empty table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/1*2vEoKe-Y_Bbn6hGxiZX2Tw.png" /><figcaption>Empty table</figcaption></figure><p>Next click the <em>Add Book button, </em>you should see a modal open with a form.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*ODSq0448xh4JK1mKe5tdig.png" /><figcaption>Add book modal</figcaption></figure><p>Enter some book information in the text field and hit the submit button, you should see the table gets populated with the information you entered.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*cAu9-Lsu-hew3q1aVrf6Kw.png" /><figcaption>Updated table</figcaption></figure><p>Currently, we are able to save the information to an array, However, this information is not persisted when we refresh the page the information will be lost. This brings us to the next part of this tutorial.</p><h3>Managing Information with the Storage API</h3><p>The app <a href="https://developer.atlassian.com/platform/forge/runtime-reference/storage-api/">Storage API</a> is an untyped key-value storage API that allows your app to store data. The app storage API stores data partitioned by Atlassian product and site and is accessible only to your app.</p><p>To use the Storage API you first need to install <em>forge/api, </em>in the root directory of your app run the following command<em>.</em></p><pre>npm i @forge/api</pre><p>Next, we will need to install an npm package called uuid-random this will allow us to generate a unique key for each book we save in our Storage API.</p><pre>npm i uuid-random</pre><h4>Setting up the Storage API</h4><p>The App storage API requires your app to have the storage:app scope. App scopes must be defined in the manifest file prior to deploying the app. Navigate to the top-level directory of your app, open the manifest.yml file and add the following code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3ea039e00366f0c77b2751cedd617335/href">https://medium.com/media/3ea039e00366f0c77b2751cedd617335/href</a></iframe><p>Changes to the app’s scopes won’t take effect until the app is upgraded. If you’ve previously deployed your app, and you change the scopes in your manifest file, you also need to redeploy your app before installing it. To do that navigate to your app’s top-level directory and run:</p><pre>forge deploy</pre><p>Start the upgrade by running:</p><pre>forge install — upgrade</pre><p>Once the upgrade completes we are ready to start using the App Storage API!</p><h4>Saving information to the Storage API</h4><p>Now that our Storage API is all set up we are going to save a new book to the Storage API using the <a href="https://developer.atlassian.com/platform/forge/runtime-reference/storage-api/#storage-set">storage.set</a> method. Open BookDialog.jsxand update the code like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/19800cb0a84728bcb7a9d5bb40480501/href">https://medium.com/media/19800cb0a84728bcb7a9d5bb40480501/href</a></iframe><p>From the updated code above we have imported <em>storage </em>and<em> uuid, storage.set</em> on line 8 is used to save the book information from the form to the Storage API and on line 7 we create a book ID using <em>uuid</em> and pass it to the <em>storage.set</em> method.</p><p>Next, let’s update BooksTable.jsxwith the following code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4af81db6ac4c2e6229762ba9cba81b34/href">https://medium.com/media/4af81db6ac4c2e6229762ba9cba81b34/href</a></iframe><p>From the code above we have imported <em>storage</em> and <em>startsWith</em> from <em>@forge/api. </em>The <em>startsWith</em> method allows us to find keys that start with a specific string, in our app all the book IDs start with <em>“book_”. </em>On line 18 we have a <em>useEffect</em> hook that runs the <em>storage.query </em>method, this enables you to query the app storage API and returns filtered results. On line 23 we set the returned results in the <em>setBooks</em> state, lastly from lines 54 to 63 we update the code by adding <em>value </em>before each attribute.</p><p>Next, let’s update the <em>index.jsx</em> file like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/54a4507a0ab666848a10226a8555db13/href">https://medium.com/media/54a4507a0ab666848a10226a8555db13/href</a></iframe><p>We have just cleaned up the code a bit, next run:</p><pre>forge deploy</pre><p>On your Confluence page, you should see that after adding a new book and refreshing the page the information is persisted.</p><h4>Updating information</h4><p>Now let’s see how we can update the book information, when the user clicks the <em>update</em> button a dialog should open with the selected book information filled in. First let’s add two states to the <em>index.jsx</em> file like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/74662d0952724c12289339fffc3ac661/href">https://medium.com/media/74662d0952724c12289339fffc3ac661/href</a></iframe><p>Next, in the <em>index.jsx</em> file update the props with the states we just created like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9f30cccac91ff3f1dfb8d941a0baf0da/href">https://medium.com/media/9f30cccac91ff3f1dfb8d941a0baf0da/href</a></iframe><p>Next open <em>BooksTable.jsx</em> and update the code like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fbeba428cfbe4c51b77fae72427acd76/href">https://medium.com/media/fbeba428cfbe4c51b77fae72427acd76/href</a></iframe><p>From the code above we have included the props we passed down from <em>index.js</em> on lines 18 &amp; 19. On line 38 we set <em>isUpdating</em> to false when the user clicks the <em>add book</em> button, on line 80 we set <em>isUpdating</em> to true when the user clicks the <em>update</em> button, we also set <em>setSelectedBook </em>with the current book information.</p><p>Next open <em>BookDialog.jsx</em> add update the code like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0e10f8fdc411e9119f1d319535542760/href">https://medium.com/media/0e10f8fdc411e9119f1d319535542760/href</a></iframe><p>From lines 12 to 17 in the code above we first check the value of <em>isUpdating</em>, it is true we use the selected book’s id as the <em>bookID</em> otherwise we create a new <em>bookID. </em>Finally on lines 31 to 49 we set the default value of each field to the selected book’s information if <em>isUpdating</em> is true. Now lets run :</p><pre>forge deploy</pre><p>Go back to your Confluence page and refresh it, when you click the edit button you should see a modal with information of the selected book already filled in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*Rn8GJ0UGQOWyZaT4mqj7bA.png" /><figcaption>Update Modal</figcaption></figure><p>If you change any of the text and click submit you should see that the book is updated in the table.</p><p><strong>Deleting Books</strong></p><p>Now let’s see how we can delete a book, when the user clicks the <em>delete</em> button the book should be removed from the App Storage API and from the table. First open BooksTable.jsx and update the delete button like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/afb116d0eca82e1cd28917711190377d/href">https://medium.com/media/afb116d0eca82e1cd28917711190377d/href</a></iframe><p>From the code above we have added an <em>onClick</em> listener that calls the <em>storage.delete</em> method to delete the current book from the Storage API and on line 10 we update the <em>setBooks </em>state.</p><p>That’s it! if you click a delete button you should see that the book is deleted.</p><h3>Learning Resources</h3><p>Looking for more ways to develop your Forge skills Check out the <a href="https://developer.atlassian.com/platform/forge/tutorials-and-guides/#tutorials">official Forge Tutorials</a> you can also take a look at some <a href="https://developer.atlassian.com/platform/forge/example-apps/#example-apps">example apps</a> built with forge.</p><p><strong><em>Thanks for reading! Happy coding!</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8b2f4e1e9092" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Spark AR Tutorial: Building an AR Puzzle Game]]></title>
            <link>https://medium.com/@harrybanda/spark-ar-tutorial-building-an-ar-puzzle-game-2127752f00f?source=rss-1520ee9d7361------2</link>
            <guid isPermaLink="false">https://medium.com/p/2127752f00f</guid>
            <category><![CDATA[game-design]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[spark-ar]]></category>
            <category><![CDATA[ar]]></category>
            <category><![CDATA[augmented-reality]]></category>
            <dc:creator><![CDATA[Harry Banda]]></dc:creator>
            <pubDate>Wed, 01 Jun 2022 14:45:21 GMT</pubDate>
            <atom:updated>2022-06-01T14:45:21.822Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/333/1*PpthA1w_KmA2H9rSFBdefQ.png" /></figure><h3>Introduction</h3><p>In this tutorial, you will build a Spark AR World Effect. You will learn how to use scripting to add logic and interactivity to your effects.</p><h3>Key Concepts</h3><p>This tutorial will cover the following key concepts:</p><ul><li>Writing game logic with the scripting module</li><li>Working with reactive programming in Spark AR</li><li>Creating animations with the scripting module</li></ul><h3>Spark AR Features</h3><p>We’ll implement the following Spark AR features in the project:</p><ul><li><a href="https://sparkar.facebook.com/ar-studio/learn/reference/scripting/summary/">Spark AR Scripting API</a></li><li><a href="https://sparkar.facebook.com/ar-studio/learn/articles/particles/particle-systems">Spark AR Particle System</a></li><li><a href="https://sparkar.facebook.com/ar-studio/learn/articles/audio/audio-playback-controller/">Audio Playback Controller</a></li><li><a href="https://sparkar.facebook.com/ar-studio/learn/articles/animation/2d-texture-animation/">2D Texture Animations</a></li></ul><h3>What We’ll Build</h3><p>This tutorial will guide you in a step-by-step process to create an augmented reality puzzle game called <a href="https://devpost.com/software/rabbit-coder">Rabbit Coder</a>. I created this game for the first Facebook AR hackathon and the project won first place. You can try out the game <a href="https://www.facebook.com/fbcameraeffects/tryit/208527660353698/">here</a>. By the end of this tutorial, you should have learned how to build this game in Spark AR, you can then use this as a template to build other awesome games.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/415/1*ETycPnlpvFABp9PfGLknfw.gif" /></figure><p>Note: To make this tutorial easier and shorter, we will not include all the features of Rabbit Coder. The following features will not be included:</p><ul><li>Obstacle and switch levels</li><li>Loop levels</li></ul><h3>Understanding the Game</h3><p>The objective of the game is to get the rabbit to the carrot using commands such as forward, left, and right, you need to insert these commands in the game and press the play button to execute them. The image below shows an example of one of the levels. The player must pass through the path to reach the goal without falling into the danger zone.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*uYYwQ0wMJizs63GHoeOH1w.png" /></figure><p>In the game, commands are represented by blocks, these commands are executed from top to bottom, the executor will iterate through each command, and if the command is equal to forward then the rabbit will move one step forward, if the command is equal to left or right the rabbit will turn 90 degrees in the respective direction. The image below shows a simplified example of the command blocks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*weEUF5nlRi7RBuv5PEC_kg.png" /></figure><p>In the commands above the rabbit will move 2 steps forward turn left and move one step forward.</p><h4>Knowledge Prerequisites</h4><p>Make sure you meet the following knowledge prerequisites before starting the tutorial:</p><ul><li>You must have basic knowledge of JavaScript</li><li>You must have a basic understanding of Spark AR studio</li></ul><h3>Getting Started</h3><h4>Software Prerequisites</h4><p>For this tutorial you will need:</p><ul><li><a href="https://sparkar.facebook.com/ar-studio/learn/downloads/">Spark AR Studio</a> v102 and above</li><li><a href="https://code.visualstudio.com/download">Visual Studio Code</a></li></ul><h4>Downloading the Project</h4><p>To follow this tutorial:</p><ol><li><a href="https://github.com/harrybanda/Rabbit-Coder-Sample-Starter">Download the unfinished sample project</a>.</li><li>Open the sample project in Spark AR Studio.</li></ol><p>I have already imported the required game assets you need to help you get started.</p><h3>Setting Up the Scene</h3><p>Before we start writing the game logic, we need to set up the scene. In Spark AR game objects cannot be created dynamically with a script so we need to add them to the scene before we can access them in the script.</p><h4>Understanding the Assets</h4><p>Within the Assets Panel you’ll find five folders and four 3D assets:</p><ul><li>Bunny represents the main character in the game</li><li>Carrot is the objective that the rabbit needs to reach</li><li>tile is the platform the rabbit will hop on</li><li>Wall surrounds the water in the game</li><li>Textures contain the 2D images required by the game</li><li>Animation Sequences contains the water animation</li><li>Audio contains all the sound effects our game will need</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/271/1*JCetHFbjDRLjWyR6uplcog.jpeg" /></figure><p>Within the Scene panel of the starter project, you’ll find a plane tracker with an empty null object inside it called “container”. In Spark AR Studio, a plane tracker is used to create world effects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/266/1*F11kH1bEntwzDciuSOg0vA.jpeg" /></figure><h4>Adding Null Objects</h4><p>Null objects act as empty groups and are a great way of grouping objects together, In this project, we’ll group our objects into two groups called level and UI.</p><p>To add a null object:</p><ol><li>Right-click container</li><li>Select Add &gt; Null Object</li><li>Rename the null object to level</li><li>Create another null object inside container and rename it to UI</li></ol><p>The level null object will contain all our game objects and the UI null object will contain our 3D user interface elements as shown in the game. Next:</p><ol><li>Create a null object called platforms in level.</li><li>Create a null object named buttons in UI</li><li>Create another null object named blocks in UI</li></ol><p>The platforms null object will contain all the platforms that the rabbit will hop on. While buttons will contain 3D planes that will act as buttons in the game and blocks will contain 3D planes that will act as command blocks. In Spark AR, a Plane is a flat 3D object that can be positioned at any depth within the scene.</p><p>Your Scene Panel should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/264/1*FjIY-g_pchGne9scihiRDA.jpeg" /></figure><p>Next, click and drag the bunny asset into level to add it as a child. Do the same for the carrot and the wall.</p><p>We’re also going to update the scale values of the 3D objects so that they fit the plane tracker.</p><ol><li>Select the bunny object in the Scene Panel.</li><li>Change the x, y, and z-axis scale to 0.15 in the Inspector Panel.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/275/1*OZZtuueOtDp7CHz26nsVvw.jpeg" /></figure><p>And for the carrot use the following values:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/278/1*uE-jomsbjxwuvhLYTJZOLA.jpeg" /></figure><h4>Adding Platforms</h4><p>In this game, the rabbit needs to hop on platforms to reach the carrot. Usually, when creating games in any tool, we can dynamically create objects with a script, the Spark AR scripting module does not allow us to create objects dynamically so we are going to duplicate the platform object from the Scene Panel manually.</p><ol><li>Select and drag the tile from the Assets Panel into the platforms null object.</li><li>Change the x, y, z scale to 0.1 in the Inspector Panel</li><li>Rename tile to platform0</li><li>Right-click on plaform0 and Click Duplicate this will create another platform object called plaform1.</li><li>Go to the next platform object and repeat the duplication process until you have plaform9</li></ol><p>Your Scene Panel should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/215/1*MgLyeC2T_xuYey7pUTIPLA.jpeg" /></figure><h3>Adding Water</h3><p>In the game when we enter a wrong command the rabbit will fall from a platform into the water, so the next thing we’ll add is a Plane with an animated texture to represent water.</p><ol><li>Right-click level.</li><li>Select Add &gt; Plane</li><li>Rename the plane to “water”</li><li>Change the scale and rotation of the water plane to look like this:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/278/1*3qTvJfT1NpzJm03ECyn7fg.jpeg" /></figure><p>Your 3D scene should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/859/1*siXA5ZdoEbX6ifCcgJXrNw.jpeg" /></figure><p>Now to add the animated water texture:</p><ol><li>Select the water plane</li><li>In the Inspector panel click the + button next to “materials”</li><li>Select the water material in the drop-down</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/261/1*yqdT1_OS56Qe5TZDzalaRA.jpeg" /></figure><p>In Spark AR Studio you can use <a href="https://sparkar.facebook.com/ar-studio/learn/articles/animation/2d-texture-animation/">2D textures to create animations</a>. You’ll add your own textures and then turn them into an animation using an asset included in Spark AR Studio called an Animation Sequence.</p><p>From the screenshot above we apply a looped animation sequence with 32 frames. I created this animation by attaching the texture named frame_[1–32] to the water_animation sequence and attaching that animation sequence to the water material. Originally the animation texture was a gif file, I had to convert it to frames before importing it to Spark AR Studio. You should have an animated pool of water that looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*OXZRlwGpz_ff-l9sRlW57A.gif" /></figure><h4>Adding a 3D User Interface</h4><p>Next, we are going to add a 3D user interface, this user interface will allow us to insert commands into the game, first let’s add the buttons:</p><ol><li>Right-click the buttons null object then Add &gt; Plane to create a new plane</li><li>Name the plane btn0</li><li>Duplicate the button so that we have btn0 to btn3</li></ol><p>Each button will have its own functionality, material, and transform values:</p><ol><li>btn0 → this will add the command to move forward</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/273/1*mU2RwaT1lEUEOeKWVloFtg.jpeg" /></figure><ol><li>btn1 → this will add the command to turn left</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/274/1*RpU4sjWxL2OoiXXEZ8DV2A.jpeg" /></figure><ol><li>btn2 → this will add the command to turn right</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/273/1*YGOrne3gjC7mUJ6i0iO_Vw.jpeg" /></figure><ol><li>btn3 → this is the play buttons that will execute the commands</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/280/1*oD3bdkuJSrIb4pIuLfceUQ.jpeg" /></figure><p>Add one more plane in the UI null object and name it commands_ui this will act as the background of the user interface. Give it the following transform and material values:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/282/1*-oI7GHv_U5lXIiAJzW6SZA.jpeg" /></figure><p>You should see this in your scene:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*B3mABaIke9k59W93UqR-Vw.jpeg" /></figure><p>Next, the UI needs to be properly arranged click the UI null object and add the following transform values:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/361/1*eSFa3ru2-zXLSeGy5o9ltA.jpeg" /></figure><p>Next, add the following transform values to the “buttons” null object:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/276/1*PiPKMYLNTr0dmsnDuN8Fgg.jpeg" /></figure><p>Add this to the “blocks” null object:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/275/1*a67Ll24rw9_1tZlRO-gWKA.jpeg" /></figure><p>Now we need to add the command blocks:</p><ol><li>Right-click blocks then Add &gt; Plane to create a new plane</li><li>Name the plane block0</li><li>Untick visible in the inspector panel</li><li>Give it the following transform values:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/361/1*QdSkpzEAwVmVTisrSeCnqA.jpeg" /></figure><p>Command blocks represent our commands visually in the game, initially we hide the blocks so that the player only sees the blocks when they are added.</p><ul><li>Next, duplicate the blocks so that we have block0 to block9.</li><li>Create one more plane under the UI null object and name it program_ui this will be the background for the command blocks, give it the following transform and material:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/398/1*YtZ98zFEcmMCLnc56NDE-A.jpeg" /></figure><p>We need to add one more button to the “buttons” null object:</p><ol><li>Right-click buttons &gt; Add &gt; Plane</li><li>Name the plane btn4</li><li>Give the plane the following transform and material values.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/372/1*gvg6e1kc-qTqjfoo7EQOxw.jpeg" /></figure><p>This button will allow us to remove blocks from the command window. Your final Scene Panel should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/223/1*Ql2jqAPA2Gcc-7di_ixF2Q.jpeg" /></figure><p>And your final scene should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HVD49ydzbyfs3HdhXHqRPg.jpeg" /></figure><h3>Scripting Rabbit Coder</h3><p>In this section, we are going to focus on writing game logic with the <a href="https://sparkar.facebook.com/ar-studio/learn/reference/scripting/summary/">Spark AR Scripting API</a>.</p><p>Spark AR Studio uses JavaScript for adding logic and interactivity to your effects. This part of the tutorial will show you how to use various Scripting modules from the Scripting API.</p><ol><li>Click on Add Asset &gt; Script to add a script.js file</li><li>Add another script file and name it levels.js</li><li>Open the script.js file and remove any code in there.</li></ol><p>The levels.js file will contain all the values for each level and the script.js file will contain all of the game logic.</p><h4>Importing Objects</h4><p>Add this code to your script.js:</p><pre>const Scene = require(&quot;Scene&quot;);</pre><p>In the code above the require() method tells the script we’re looking for a module, we pass in the name of the module as the argument to specify the one we want to load. The Scene variable now contains a reference to the <a href="https://sparkar.facebook.com/ar-studio/learn/reference/classes/scenemodule">Scene Module</a> that can be used to access the module’s properties, methods, classes, and enums. Now we are going to add the code below:</p><pre>(async function() {<br>  const [] = await Promise.all([]);<br>})();</pre><p>In the code above we have added an async function. Async and Await make promises easier to write, async makes a function return a Promise, and await makes a function wait for a Promise. The Promise.all takes an array of promises and returns a new promise. Next update your code to look like this:</p><pre>(async function () {<br>  const [] = await Promise.all([<br>    // Game Objects<br>    Scene.root.findFirst(&quot;bunny&quot;),<br>    Scene.root.findFirst(&quot;carrot&quot;),<br>    Scene.root.findByPath(&quot;**/blocks/*&quot;),<br>    Scene.root.findByPath(&quot;**/platforms/*&quot;),<br>    Scene.root.findByPath(&quot;**/buttons/*&quot;),<br>    Scene.root.findFirst(&quot;water_emitter&quot;),<br>    Materials.findUsingPattern(&quot;btn*&quot;),<br>    Materials.findUsingPattern(&quot;*block_mat&quot;),<br>    Textures.findUsingPattern(&quot;btn*&quot;),<br>  ]);<br><br>  })();</pre><p>In the code above we are accessing objects from the Scene using promise.all. We have added two 3D objects bunny and carrot and three null objects blocks, platforms, and buttons. water_emitter will be used later in the tutorial, we have also added Materials and Textures from the scene. We use findByPath to access multiple objects at once. We then specify a pattern for findByPath to match, for example findByPath(&quot;*/blocks/&quot;) will return us any object which is a child of any object called &quot;blocks&quot;. Next, we are going to import the audio files into the script:</p><p>First, add this line at the top of your script just before the async function:</p><pre>const Audio = require(&quot;Audio&quot;);</pre><p>Next, update your promise.all code to look like this:</p><pre>(async function () {<br>  const [<br>    // Game Objects<br>    bunny,<br>    carrot,<br>    blocks,<br>    platforms,<br>    buttons,<br>    waterEmitter,<br>    buttonMats,<br>    blockMats,<br>    buttonTextures,<br>    // Game Audio<br>    jumpSound,<br>    dropSound,<br>    failSound,<br>    completeSound,<br>    clickSound,<br>    removeSound,<br>  ] = await Promise.all([<br>    // Game Objects<br>    Scene.root.findFirst(&quot;bunny&quot;),<br>    Scene.root.findFirst(&quot;carrot&quot;),<br>    Scene.root.findByPath(&quot;**/blocks/*&quot;),<br>    Scene.root.findByPath(&quot;**/platforms/*&quot;),<br>    Scene.root.findByPath(&quot;**/buttons/*&quot;),<br>    Scene.root.findFirst(&quot;water_emitter&quot;),<br>    Materials.findUsingPattern(&quot;btn*&quot;),<br>    Materials.findUsingPattern(&quot;*block_mat&quot;),<br>    Textures.findUsingPattern(&quot;btn*&quot;),<br>    // Game Audio<br>    Audio.getAudioPlaybackController(&quot;jump&quot;),<br>    Audio.getAudioPlaybackController(&quot;drop&quot;),<br>    Audio.getAudioPlaybackController(&quot;fail&quot;),<br>    Audio.getAudioPlaybackController(&quot;complete&quot;),<br>    Audio.getAudioPlaybackController(&quot;click&quot;),<br>    Audio.getAudioPlaybackController(&quot;remove&quot;),<br>  ]);<br><br>  })();</pre><p>From the code, above we have imported the <a href="https://sparkar.facebook.com/ar-studio/learn/reference/classes/audiomodule">Audio module</a> and added getAudioPlaybackController, the <a href="https://sparkar.facebook.com/ar-studio/learn/articles/audio/audio-playback-controller/">audio playback controller</a> can be used to play sound continuously on a loop in your AR effect or add one-shot triggered audio in response to boolean signals. We have also added variables that correspond to the game and audio objects.</p><h4>Generating Levels</h4><p>In the game a level is represented by a 5 x 5 grid of coordinates, on this grid, we shall specify which coordinates are part of the path and which coordinates are part of the danger zones.</p><ul><li>Path → these are the coordinates that the rabbit can hop on</li><li>Danger Zone → the coordinates that the rabbit cannot hop on.</li></ul><p>Each level has a different path and danger zone coordinates the image below shows an example for a level, the green squares represent path coordinates while the red squares represent danger zone coordinates. In the image below the path coordinates are: [3,2] [3,3] [3,4].</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/413/1*a8fYZUEBa6i2xMTeOb8Qxw.png" /></figure><p>Now that we have an idea of how that path is going to be generated we are going to define the path coordinates for each level in the levels.js file.</p><ol><li>Open levels.js in your code editor and add the following code:</li></ol><pre>module.exports = [<br>  // level 1<br>  {<br>    path: [<br>      [2, 3],<br>      [3, 3],<br>      [4, 3],<br>    ],<br>    facing: &quot;east&quot;,<br>  },<br>  // level 2<br>  {<br>    path: [<br>      [2, 4],<br>      [2, 3],<br>      [3, 3],<br>      [4, 3],<br>    ],<br>    facing: &quot;north&quot;,<br>  },<br>  // level 3<br>  {<br>    path: [<br>      [4, 4],<br>      [3, 4],<br>      [3, 3],<br>      [3, 2],<br>      [2, 2],<br>    ],<br>    facing: &quot;west&quot;,<br>  },<br>];</pre><p>From the code above we are exporting an array of objects, each object in the array represents a level and each level has the following attributes:</p><ul><li>Path → These are the coordinates of the path as explained above.</li><li>facing → This is the direction in which the rabbit will face when the level loads.</li></ul><p>In script.js add this line of code to import the levels:</p><pre>const levels = require(&quot;./levels&quot;);</pre><p>Next, create a function called initLevel and call in below</p><pre>...<br><br>/*------------- Initialize level -------------*/<br><br>function initLevel() {<br><br>}<br><br>initLevel();</pre><p>The “initLevel” function will run when the effect is launched.</p><h4>Generating Grid Coordinates</h4><p>Before we can generate the path and danger zone coordinates we need to define a grid of all the coordinates.</p><p>Add the following variables to your code:</p><pre>const gridSize = 0.36;<br>  const gridInc = 0.12;<br>  let allCoordinates = createAllCoordinates();</pre><p>The default unit of measurement in Spark AR is Meters, so our values will be in meters. In the code above we use gridSize to represent the size of the grid in meters while gridInc is the increment value that is added to the position of each platform to form the grid. Each box in the grid has a size of 0.072 meters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*bCiKny3xmYZZDeK-g4_NrQ.png" /></figure><p>Next, create a function called createAllCoordinates and add the following code:</p><pre>function createAllCoordinates() {<br>    // Creates a grid of coordinates<br>    let coords = [];<br>    for (let i = -gridSize; i &lt;= gridSize; i += gridInc) {<br>      for (let j = -gridSize; j &lt;= gridSize; j += gridInc) {<br>        let x = Math.round(i * 1e4) / 1e4;<br>        let z = Math.round(j * 1e4) / 1e4;<br>        coords.push([x, z]);<br>      }<br>    }<br>    return coords;<br>  }</pre><p>The createAllCoordinates function has a nested for loop that generates a 7 X 7 grid, the generated coordinate values are then stored in the allCoordinates variable. In the second for loop, we set the x and z values for each coordinate. The code Math.round(i * 1e4) rounds the value to the nearest integer.</p><h4>Generating Path Coordinates</h4><p>Add the following variables to your code:</p><pre>let currentLevel = 0;<br>let pathCoordinates = createPathCoordinates();</pre><p>From the code above, currentLevel will represent the current level as a number, since we only have 3 levels, currentLevel can be 0, 1, or 2. pathCoordinates will hold the path coordinates. Next, add the following function:</p><pre>function createPathCoordinates() {<br>    let path = levels[currentLevel].path;<br>    let coords = [];<br>    for (let i = 0; i &lt; path.length; i++) {<br>      let x = allCoordinates[path[i][0]][1];<br>      let z = allCoordinates[path[i][1]][1];<br>      coords.push([x, z]);<br>    }<br>    return coords;<br>  }</pre><p>The code above will generate path coordinates from the values defined in the “currentLevel”. From the code, we can also see a for loop this loop iterates through the path array, we use this to obtain the path x and z values from “allCoordinates”.</p><h4>Generating Danger Zone Coordinates</h4><p>Add the following variable to your code</p><pre>let dangerCoordinates = createDangerCoordinates();</pre><p>The variable above will hold the danger zone coordinates. Next, add this code:</p><pre>function createDangerCoordinates() {<br>    let coords = allCoordinates;<br>    for (let i = 0; i &lt; pathCoordinates.length; i++) {<br>      for (let j = 0; j &lt; coords.length; j++) {<br>        let lvlCoordStr = JSON.stringify(pathCoordinates[i]);<br>        let genCoordStr = JSON.stringify(coords[j]);<br>        if (lvlCoordStr === genCoordStr) {<br>          coords.splice(j, 1);<br>        }<br>      }<br>    }<br>    return coords;<br>  }</pre><p>Just like with the path coordinates the code above generates the danger zone coordinates from “allCoordinates”, we do that by subtracting the pathCoordinates from allCoordinates using the JavaScript splice method leaves us with the danger coordinates, which the function returns.</p><h4>Placing Level Objects</h4><p>Next, we are going to focus on positioning the rabbit, carrot, and platforms using the coordinates we just generated. First, add the following variables to your code:</p><pre>let playerDir = levels[currentLevel].facing;<br>let platformsUsed = 0;<br>const numOfPlatforms = 10;<br>const playerInitY = 0.02;</pre><ul><li>playerDir gets the facing value from levels.js</li><li>platformsUsed holds the number of platforms that have been added.</li><li>playerInitY is the players initial position in the Y-axis</li></ul><p>Next in the initLevel() function add the following code:</p><pre>playerDir = levels[currentLevel].facing;<br><br>    // Set the player&#39;s initial position<br>    bunny.transform.x = pathCoordinates[0][0];<br>    bunny.transform.z = pathCoordinates[0][1];<br>    bunny.transform.y = playerInitY;<br><br>    // set carrot position<br>    let goalX = pathCoordinates[pathCoordinates.length - 1][0];<br>    let goalZ = pathCoordinates[pathCoordinates.length - 1][1];<br>    carrot.transform.x = goalX;<br>    carrot.transform.z = goalZ;<br>    carrot.transform.y = 0.03;<br>    carrot.hidden = false;<br><br>    // Set the player&#39;s initial direction<br>    if (playerDir === &quot;east&quot;) {<br>      bunny.transform.rotationY = 0;<br>    } else if (playerDir === &quot;north&quot;) {<br>      bunny.transform.rotationY = degreesToRadians(90);<br>    } else if (playerDir === &quot;west&quot;) {<br>      bunny.transform.rotationY = degreesToRadians(180);<br>    } else if (playerDir === &quot;south&quot;) {<br>      bunny.transform.rotationY = degreesToRadians(270);<br>    }<br><br>    // Add the path platforms<br>    for (let i = 0; i &lt; pathCoordinates.length; i++) {<br>      let path = pathCoordinates[i];<br>      let x = path[0];<br>      let z = path[1];<br>      let platform = platforms[i];<br>      platform.transform.x = x;<br>      platform.transform.z = z;<br>      platform.hidden = false;<br>    }</pre><p>The code above will first set the direction that the rabbit should face, next we set the player’s initial position. From the pathCoordinates the first coordinate is always the rabbit’s start position and the last coordinate is always the position of the carrot. After that, we transform the rabbit’s rotation based on the direction defined in the level. Lastly, we draw the path by iterating through pathCoordinates, getting each path, and applying it to a platform in the Scene. Save the code and check your scene, you should see that we have a level generated with three platforms.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*o0y2uwZhVk4QOZYgDohJaw.jpeg" /></figure><p>You can try changing the currentLevel value to 1 or 2 you should see that the level changes.</p><h4>Adding Commands</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/346/1*3DQsG_dO6FTASs22qPutoA.png" /></figure><p>Now that we can generate levels it’s time to make the rabbit move but before we do that let’s first set up the commands. In the game commands allow us to instruct the rabbit what to do, in this game we are going to have 3 commands, move forward, turn left and turn right. To add commands we need to tap the 3D planes that we added in the buttons null object, to do that add the following code at the top of your script.</p><pre>const TouchGestures = require(&quot;TouchGestures&quot;);<br>const Materials = require(&quot;Materials&quot;);</pre><p>The <a href="https://sparkar.facebook.com/ar-studio/learn/reference/classes/touchgesturesmodule">TouchGestures</a> module enables touch gesture detection, in our case we are going to use it to detect screen taps and the <a href="https://sparkar.facebook.com/ar-studio/learn/reference/classes/materialsmodule">Materials</a> module provides access to the materials in the effect.</p><p>Before we can add the commands we need to declare some variables that will be needed:</p><pre>const states = {<br>    start: 1,<br>    running: 2,<br>    complete: 3,<br>    failed: 4,<br>    uncomplete: 5,<br>  };<br>  let currentState = states.start;<br>  let commands = [];<br>  let blocksUsed = 0;<br>  const blockSlotInc = 0.1;<br>  const initBlockSlot = 0.6;<br>  const numOfBlocks = 10;<br>  const blockInitY = 0.9;<br>  let nextBlockSlot = initBlockSlot;</pre><p>In the code above state represents the current state of the game, in this game we have 5 states:</p><ul><li>start → this is the initial game state</li><li>running → this is when the game is running e.g the rabbit is moving</li><li>complete → this is when the when a level is successfully completed</li><li>failed → this is when the rabbit falls in the water</li><li>uncomplete this is when the rabbit does not reach the goal.</li></ul><p>The commands array stores all the commands that the player inserts e.g forward, left, Right.</p><p>BlocksUsed stores the number of blocks that the player has added, we use this to keep track of the number of blocks so that we do not go over the maximum number.</p><p>blockSlotInc is the value that the added blocks are offset by, e.g. when a user adds a new command block it will be placed 0.1 meters lower.</p><p>InitBlockSlot is the initial block position.</p><p>numOfBlock is the maximum number of blocks that we have in the blocks null object.</p><p>nextBlockSlot represents the next slot that is available for a block to be inserted.</p><p>Now that we have the variables its time to add the logic:</p><pre>function addCommand(move) {<br>    if (currentState === states.start) {<br>      if (blocksUsed &lt; numOfBlocks) {<br>        let block = blocks[blocksUsed];<br>        blocksUsed++;<br>        nextBlockSlot -= blockSlotInc;<br>        block.transform.y = nextBlockSlot;<br><br>        // Set the block material<br>        for (let i = 0; i &lt; blockMats.length; i++) {<br>          if (blockMats[i].name === move + &quot;_block_mat&quot;) {<br>            block.material = blockMats[i];<br>          }<br>        }<br><br>        block.hidden = false;<br>        commands.push({ command: move, block: block });<br>        clickSound.setPlaying(true);<br>        clickSound.reset();<br>      }<br>    }<br>  }</pre><p>The addCommand function above takes in a string argument called move this value can either be &quot;forward&quot;, &quot;left&quot; or &quot;right&quot;. On the next line, we check if currentState is equal to the initial state, if that’s the case then we can insert new blocks. In the second If statement we check if the blocks that have been used are greater than the max number of blocks, we have in our scene. In this case, if we run out of command blocks we prevent the game from trying to access blocks that do not exist in the scene. We set the position of the next slot and insert the block on that slot. we then apply the correct material based on the name of the block and make it visible. In the last 3 lines, we add the blocks to the commands array and play a sound effect.</p><p>Next, add the following code anywhere inside the promise then function:</p><pre>buttons.forEach((button, i) =&gt; {<br>    TouchGestures.onTap(button).subscribe(function () {<br>      switch (i) {<br>        case 0:<br>          addCommand(&quot;forward&quot;);<br>          break;<br>        case 1:<br>          addCommand(&quot;left&quot;);<br>          break;<br>        case 2:<br>          addCommand(&quot;right&quot;);<br>          break;<br>        case 3:<br>          break;<br>        case 4:<br>          break;<br>      }<br>    });<br>  });</pre><p>The for loop above iterates through all the buttons in our null object and assigns an onTap listener to each button. We then add a switch statement to call the addCommand function and pass a command.</p><p>Now we should be able to click the buttons and add the command blocks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/364/1*EIJwum83l5JIjK4rLKhuQw.gif" /></figure><p>Next, let’s add the code to remove added blocks in case 4 of the switch statement:</p><pre>case 4:<br>  removeSound.setPlaying(true);<br>  removeSound.reset();<br>  if (blocksUsed !== 0 &amp;&amp; currentState === states.start) {<br>    let popped = commands.pop();<br>    popped.block.transform.y = blockInitY;<br>    popped.block.hidden = true;<br>    nextBlockSlot += blockSlotInc;<br>    blocksUsed--;<br>  }<br>  break;</pre><p>The code above allows us to remove the bottom block, we do this by using the JavaScript pop method to remove the last command in the commands array, when we remove a command we are hiding the block and moving it to its initial position. You can try to click the Remove button after adding some blocks you should see them getting removed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*_3UZ8xx8vT1jNHSfLKjwGA.gif" /></figure><h4>Moving the Rabbit</h4><p>Now that we have the “commands” logic all set up it’s time to make the rabbit move. In order to make the rabbit move, we need to execute the commands that we have entered, to do that we need to write an execution function that iterates through each command in the commands array. Create a function called “executeCommands” and add the following code inside the function:</p><pre>function executeCommands() {<br>    currentState = states.running;<br>    let executionCommands = [];<br>    for (let i = 0; i &lt; commands.length; i++) {<br>      executionCommands.push(commands[i].command);<br>    }<br>    setExecutionInterval(<br>      function (e) {<br>        animatePlayerMovement(executionCommands[e]);<br>      },<br>      1000,<br>      executionCommands.length<br>    );<br>  }</pre><p>The function above iterates through each command, gets the command value e.g. forward, left or right, and sets an execution interval of 1 second. Next import the Time, Texture and Animation module then add a variable called exeIntervalID like this:</p><pre>const Time = require(&quot;Time&quot;);<br>const Textures = require(&quot;Textures&quot;);<br>const Animation = require(&quot;Animation&quot;);<br>...<br>let exeIntervalID;</pre><p>The <a href="https://sparkar.facebook.com/ar-studio/learn/reference/classes/timemodule">TimeModule</a> class we added above enables time-based events.</p><p>Next create the setExecutionInterval function:</p><pre>function setExecutionInterval(callback, delay, repetitions) {<br>    let e = 0;<br>    callback(0);<br>    exeIntervalID = Time.setInterval(function () {<br>      callback(e + 1);<br>      if (++e === repetitions) {<br>        Time.clearInterval(exeIntervalID);<br>        if (currentState === states.running) currentState = states.uncomplete;<br>        setTexture(&quot;btn_retry&quot;);<br>        failSound.setPlaying(true);<br>        failSound.reset();<br>      }<br>    }, delay);<br>  }</pre><p>The setExecutionInterval function takes in a callback, delay, and repetitions this will allow us to move the rabbit after 1 second. The callback function will contain the movement animation code. Next, add the setTexture function, we need this function to dynamically apply textures to objects:</p><pre>function setTexture(texture_name) {<br>    for (let i = 0; i &lt; buttonTextures.length; i++) {<br>      if (buttonTextures[i].name === texture_name) {<br>        let signal = buttonTextures[i].signal;<br>        buttonMats[3].setTextureSlot(&quot;DIFFUSE&quot;, signal);<br>      }<br>    }<br>  }</pre><h4>Adding Animations</h4><p>Now that our command execution code is all set up let us focus on Animations, to make the rabbit move forward and turn we are going to use Spark AR’s <a href="https://sparkar.facebook.com/ar-studio/learn/reference/classes/animationmodule">Animation Module</a>. Add the following function:</p><pre>function animatePlayerMovement(command) {<br>    const timeDriverParameters = {<br>      durationMilliseconds: 400,<br>      loopCount: 1,<br>      mirror: false,<br>    };<br><br>    const timeDriver = Animation.timeDriver(timeDriverParameters);<br>    const translationNegX = Animation.animate(<br>      timeDriver,<br>      Animation.samplers.linear(<br>        bunny.transform.x.pinLastValue(),<br>        bunny.transform.x.pinLastValue() - gridInc<br>      )<br>    );<br><br>    const translationPosX = Animation.animate(<br>      timeDriver,<br>      Animation.samplers.linear(<br>        bunny.transform.x.pinLastValue(),<br>        bunny.transform.x.pinLastValue() + gridInc<br>      )<br>    );<br><br>    const translationNegZ = Animation.animate(<br>      timeDriver,<br>      Animation.samplers.linear(<br>        bunny.transform.z.pinLastValue(),<br>        bunny.transform.z.pinLastValue() - gridInc<br>      )<br>    );<br><br>    const translationPosZ = Animation.animate(<br>      timeDriver,<br>      Animation.samplers.linear(<br>        bunny.transform.z.pinLastValue(),<br>        bunny.transform.z.pinLastValue() + gridInc<br>      )<br>    );<br><br>    const rotationLeft = Animation.animate(<br>      timeDriver,<br>      Animation.samplers.linear(<br>        bunny.transform.rotationY.pinLastValue(),<br>        bunny.transform.rotationY.pinLastValue() + degreesToRadians(90)<br>      )<br>    );<br><br>    const rotationRight = Animation.animate(<br>      timeDriver,<br>      Animation.samplers.linear(<br>        bunny.transform.rotationY.pinLastValue(),<br>        bunny.transform.rotationY.pinLastValue() - degreesToRadians(90)<br>      )<br>    );<br><br>    const jump = Animation.animate(<br>      timeDriver,<br>      Animation.samplers.sequence({<br>        samplers: [<br>          Animation.samplers.easeInOutSine(playerInitY, 0.1),<br>          Animation.samplers.easeInOutSine(0.1, playerInitY),<br>        ],<br>        knots: [0, 1, 2],<br>      })<br>    );<br><br>    timeDriver.start();<br><br>    switch (command) {<br>      case &quot;forward&quot;:<br>        bunny.transform.y = jump;<br>        jumpSound.setPlaying(true);<br>        jumpSound.reset();<br>        if (playerDir === &quot;east&quot;) {<br>          bunny.transform.x = translationPosX;<br>        } else if (playerDir === &quot;north&quot;) {<br>          bunny.transform.z = translationNegZ;<br>        } else if (playerDir === &quot;west&quot;) {<br>          bunny.transform.x = translationNegX;<br>        } else if (playerDir === &quot;south&quot;) {<br>          bunny.transform.z = translationPosZ;<br>        }<br>        break;<br>      case &quot;left&quot;:<br>        if (playerDir === &quot;east&quot;) {<br>          playerDir = &quot;north&quot;;<br>        } else if (playerDir === &quot;north&quot;) {<br>          playerDir = &quot;west&quot;;<br>        } else if (playerDir === &quot;west&quot;) {<br>          playerDir = &quot;south&quot;;<br>        } else if (playerDir === &quot;south&quot;) {<br>          playerDir = &quot;east&quot;;<br>        }<br>        bunny.transform.rotationY = rotationLeft;<br>        break;<br>      case &quot;right&quot;:<br>        if (playerDir === &quot;east&quot;) {<br>          playerDir = &quot;south&quot;;<br>        } else if (playerDir === &quot;south&quot;) {<br>          playerDir = &quot;west&quot;;<br>        } else if (playerDir === &quot;west&quot;) {<br>          playerDir = &quot;north&quot;;<br>        } else if (playerDir === &quot;north&quot;) {<br>          playerDir = &quot;east&quot;;<br>        }<br>        bunny.transform.rotationY = rotationRight;<br>        break;<br>    }<br>  }</pre><p>The code above will be responsible for the rabbit’s movement, first, we set timeDriverParameters and a timeDriver, this will allow us to animate the rabbit once for 400 milliseconds. The next lines of code simply transform the rabbits x, z, and y positions, next we have a Switch statement that executes the correct animation code based on the command, we also need to take note of the direction the rabbit is facing so that we move the rabbit in the direction it’s facing. The Time driver allows us to specify a duration in milliseconds for the animation along with optional parameters for looping and mirroring. The samplers property of the animation module gives us access to the SamplerFactory class, which we use to set the easing function. From the gif below you can see that the rabbit can hop forward, the rabbit will also be able to turn left or right.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/282/1*6WTZrzj0-UZk1dcybHmCFQ.gif" /></figure><p>Now that our animation code is all setup it’s time to run the commands, we need to do this on a button press, so lets update our commands switch statement we added earlier to look like this:</p><pre>buttons.forEach((button, i) =&gt; {<br>    TouchGestures.onTap(button).subscribe(function () {<br>      switch (i) {<br>        case 0:<br>          addCommand(&quot;forward&quot;);<br>          break;<br>        case 1:<br>          addCommand(&quot;left&quot;);<br>          break;<br>        case 2:<br>          addCommand(&quot;right&quot;);<br>          break;<br>        case 3:<br>          clickSound.setPlaying(true);<br>          clickSound.reset();<br>          switch (currentState) {<br>            case states.start:<br>              Time.setTimeout(function () {<br>                if (commands.length !== 0) executeCommands();<br>              }, 300);<br>              break;<br>            case states.failed:<br>              resetLevel();<br>              break;<br>            case states.uncomplete:<br>              resetLevel();<br>              break;<br>            case states.complete:<br>              nextLevel(&quot;next&quot;);<br>              break;<br>          }<br>          break;<br>        case 4:<br>          removeSound.setPlaying(true);<br>          removeSound.reset();<br>          if (blocksUsed !== 0 &amp;&amp; currentState === states.start) {<br>            let popped = commands.pop();<br>            popped.block.transform.y = blockInitY;<br>            popped.block.hidden = true;<br>            nextBlockSlot += blockSlotInc;<br>            blocksUsed--;<br>          }<br>          break;<br>      }<br>    });<br>  });</pre><p>In the switch statement above we have updated case 3, this case runs the executeCommands() function when the user presses the run button and we reset the level when the state is failed or incomplete. Let’s add the reset function:</p><pre>/*------------- Reset current level -------------*/<br><br>function resetLevel() {<br>    currentState = states.start;<br>    playerDir = levels[currentLevel].facing;<br>    commands = [];<br>    blocksUsed = 0;<br>    nextBlockSlot = initBlockSlot;<br><br>    bunny.hidden = false;<br><br>    setTexture(&quot;btn_play&quot;);<br>    Time.clearInterval(exeIntervalID);<br><br>    for (let i = 0; i &lt; numOfBlocks; i++) {<br>      let block = blocks[i];<br>      block.transform.y = blockInitY;<br>      block.hidden = true;<br>    }<br><br>    initLevel();<br>  }</pre><p>This function sets all the game values back to their initial values. We also need a function to take users to the next level:</p><pre>function nextLevel(state) {<br>    if (state === &quot;next&quot; &amp;&amp; currentLevel &lt; levels.length - 1) {<br>      currentLevel++;<br>    } else {<br>      currentLevel = 0;<br>    }<br><br>    allCoordinates = createAllCoordinates();<br>    pathCoordinates = createPathCoordinates();<br>    dangerCoordinates = createDangerCoordinates();<br><br>    for (let i = 0; i &lt; numOfPlatforms; i++) {<br>      let platform = platforms[i];<br>      platform.hidden = true;<br>    }<br><br>    resetLevel();<br>  }</pre><p>The function above will increase the current level and regenerate the level coordinates for the new level. We can now test the game, you should be able to see the rabbit moves based on the commands added.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/518/1*8TIE1BjtNmkPZjvQH4mHAQ.gif" /></figure><h4>Monitoring the Player’s Position</h4><p>Currently, the rabbit can move but we need a way to check if the rabbit has reached the goal or fallen off the path, to do that we are going to use the Spark AR <a href="https://sparkar.facebook.com/ar-studio/learn/reference/classes/reactivemodule">Reactive Module</a>.</p><p>Spark AR Studio’s implementation of reactive programming allows you to create relationships between objects, assets, and values. This means that the engine doesn’t have to execute JavaScript code every frame when performing common tasks such as animating content or looking for user input.</p><p>First let&#39;s import the reactive module like this:</p><pre>const Reactive = require(&quot;Reactive&quot;);</pre><p>Next, add the following code:</p><pre>Reactive.monitorMany({<br>    x: bunny.transform.x,<br>    z: bunny.transform.z,<br>  }).subscribe(({ newValues }) =&gt; {<br>    let playerX = newValues.x;<br>    let playerZ = newValues.z;<br>    let goalX = pathCoordinates[pathCoordinates.length - 1][0];<br>    let goalZ = pathCoordinates[pathCoordinates.length - 1][1];<br>    let collisionArea = 0.005;</pre><pre>    // Check if player is on the goal<br>    if (<br>      isBetween(playerX, goalX + collisionArea, goalX - collisionArea) &amp;&amp;<br>      isBetween(playerZ, goalZ + collisionArea, goalZ - collisionArea)<br>    ) {<br>      bunny.transform.x = goalX;<br>      bunny.transform.z = goalZ;<br>      commands = [];<br>      Time.clearInterval(exeIntervalID);<br>      changeState(states.complete, &quot;next&quot;);<br>      carrot.hidden = true;<br>      animateLevelComplete();<br>      completeSound.setPlaying(true);<br>      completeSound.reset();<br>    }</pre><pre>    // Check if player is on a danger zone<br>    for (let i = 0; i &lt; dangerCoordinates.length; i++) {<br>      let dx = dangerCoordinates[i][0];<br>      let dz = dangerCoordinates[i][1];<br>      if (<br>        isBetween(playerX, dx + collisionArea, dx - collisionArea) &amp;&amp;<br>        isBetween(playerZ, dz + collisionArea, dz - collisionArea)<br>      ) {<br>        bunny.transform.x = dx;<br>        bunny.transform.z = dz;<br>        commands = [];<br>        Time.clearInterval(exeIntervalID);<br>        changeState(states.failed, &quot;retry&quot;);<br>        animatePlayerFall();<br>        dropSound.setPlaying(true);<br>        dropSound.reset();<br>      }<br>    }<br>  });</pre><pre>  function isBetween(n, a, b) {<br>    return (n - a) * (n - b) &lt;= 0;<br>  }</pre><pre>  function changeState(state, buttonText) {<br>    Time.setTimeout(function () {<br>      currentState = state;<br>      setTexture(buttonText);<br>    }, 500);<br>  }</pre><p>In the code above we use monitorMany from the Reactive Module, it accepts the rabbit’s x and z transform values as arguments, we need to monitor these values in order to check if the player is on the goal coordinates or the “dangerzone” coordinates.</p><pre>if (<br>      isBetween(playerX, goalX + collisionArea, goalX - collisionArea) &amp;&amp;<br>      isBetween(playerZ, goalZ + collisionArea, goalZ - collisionArea)<br>    ) {<br>      bunny.transform.x = goalX;<br>      bunny.transform.z = goalZ;<br>      commands = [];<br>      Time.clearInterval(exeIntervalID);<br>      changeState(states.complete, &quot;next&quot;);<br>      carrot.hidden = true;<br>      animateLevelComplete();<br>      completeSound.setPlaying(true);<br>      completeSound.reset();<br>    }</pre><p>The code above checks if the player’s X and Z values are on the goal coordinates, if that happens change our game state to complete. This means the player has completed the level.</p><pre>for (let i = 0; i &lt; dangerCoordinates.length; i++) {<br>      let dx = dangerCoordinates[i][0];<br>      let dz = dangerCoordinates[i][1];<br>      if (<br>        isBetween(playerX, dx + collisionArea, dx - collisionArea) &amp;&amp;<br>        isBetween(playerZ, dz + collisionArea, dz - collisionArea)<br>      ) {<br>        bunny.transform.x = dx;<br>        bunny.transform.z = dz;<br>        commands = [];<br>        Time.clearInterval(exeIntervalID);<br>        changeState(states.failed, &quot;retry&quot;);<br>        animatePlayerFall();<br>        dropSound.setPlaying(true);<br>        dropSound.reset();<br>      }<br>    }<br>  });</pre><p>From the code above we iterate through all the danger coordinates and check if the player’s X and Z values match any of them, if that happens we set the game’s state to failed. This means the player has fallen off the path and failed to complete the level.</p><h3>Adding More Animations</h3><h4>Player Idle animation</h4><pre>function animatePlayerIdle() {<br>    const timeDriverParameters = {<br>      durationMilliseconds: 400,<br>      loopCount: Infinity,<br>      mirror: true,<br>    };<br>    const timeDriver = Animation.timeDriver(timeDriverParameters);</pre><pre>    const scale = Animation.animate(<br>      timeDriver,<br>      Animation.samplers.linear(<br>        bunny.transform.scaleY.pinLastValue(),<br>        bunny.transform.scaleY.pinLastValue() + 0.02<br>      )<br>    );</pre><pre>    bunny.transform.scaleY = scale;</pre><pre>    timeDriver.start();<br>  }</pre><pre>  animatePlayerIdle();</pre><p>In game design, <a href="https://en.wikipedia.org/wiki/Idle_animations">Idle animations</a> refer to animations within video games that occur when the player character does not do any action (hence being idle). The code above makes the rabbit scale up and down when idle. As you can see in the gif below the rabbit has a slight movement in the Y-axis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/150/1*9sNOGhEVLlM-iDuY68mjMg.gif" /></figure><h4>Carrot Animation</h4><pre>function animateCarrot() {<br>    const timeDriverParameters = {<br>      durationMilliseconds: 2500,<br>      loopCount: Infinity,<br>      mirror: false,<br>    };</pre><pre>    const timeDriver = Animation.timeDriver(timeDriverParameters);</pre><pre>    const rotate = Animation.animate(<br>      timeDriver,<br>      Animation.samplers.linear(<br>        carrot.transform.rotationY.pinLastValue(),<br>        carrot.transform.rotationY.pinLastValue() - degreesToRadians(360)<br>      )<br>    );</pre><pre>    carrot.transform.rotationY = rotate;</pre><pre>    timeDriver.start();<br>  }</pre><pre>  animateCarrot();</pre><p>The code above makes the carrot rotate in the Y-axis this is to make the game look more dynamic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/114/1*DTq4sPlsKLH1Lz5GU-wuNA.gif" /></figure><h4>Level Complete Animation</h4><pre>function animateLevelComplete() {<br>    const timeDriverParameters = {<br>      durationMilliseconds: 450,<br>      loopCount: 2,<br>      mirror: false,<br>    };</pre><pre>    const timeDriver = Animation.timeDriver(timeDriverParameters);</pre><pre>    const jump = Animation.animate(<br>      timeDriver,<br>      Animation.samplers.sequence({<br>        samplers: [<br>          Animation.samplers.easeInOutSine(playerInitY, 0.1),<br>          Animation.samplers.easeInOutSine(0.1, playerInitY),<br>        ],<br>        knots: [0, 1, 2],<br>      })<br>    );</pre><pre>    bunny.transform.y = jump;</pre><pre>    timeDriver.start();<br>  }</pre><p>The animation above makes the rabbit jump up and down when it reaches the goal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/238/1*fBr-T3xnvv5FoojdtTEV3w.gif" /></figure><h4>Level Failed Animation</h4><pre>function animatePlayerFall() {<br>    emmitWaterParticles();<br>    const timeDriverParameters = {<br>      durationMilliseconds: 100,<br>      loopCount: 1,<br>      mirror: false,<br>    };</pre><pre>    const timeDriver = Animation.timeDriver(timeDriverParameters);</pre><pre>    const moveY = Animation.animate(<br>      timeDriver,<br>      Animation.samplers.easeInOutSine(playerInitY - 0.1, -0.17)<br>    );</pre><pre>    bunny.transform.y = moveY;</pre><pre>    timeDriver.start();</pre><pre>    Time.setTimeout(function () {<br>      bunny.hidden = true;<br>    }, 200);<br>  }</pre><p>The animation code above makes the rabbit fall over a platform</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/342/1*Oh2KeJSzfvy8oXjly9Y8rQ.gif" /></figure><h4>Water Splash Animation</h4><p>The last animation we are going to add is the splash animation when the rabbit falls in the water, unlike the other animations this one uses particles. We need to create the particle effect in Spark AR studio first add the following function.</p><pre>function emmitWaterParticles() {<br>    const sizeSampler = Animation.samplers.easeInQuad(0.015, 0.007);<br>    waterEmitter.transform.x = bunny.transform.x;<br>    waterEmitter.transform.z = bunny.transform.z;<br>    waterEmitter.birthrate = 500;<br>    waterEmitter.sizeModifier = sizeSampler;</pre><pre>    Time.setTimeout(function () {<br>      bunny.hidden = true;<br>      waterEmitter.birthrate = 0;<br>    }, 200);<br>  }</pre><p>The code above will emit particles when the player falls into the water.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/420/1*M9pxlbVrrFJeS8jhMVLqfg.gif" /></figure><h4>Adding a Particle System</h4><p><a href="https://sparkar.facebook.com/ar-studio/learn/articles/particles/particle-systems">Particle systems</a> let you display and move large numbers of objects, called particles. You can apply force and drag to particles to mimic the effects of gravity.</p><p>To add a particle system to your scene:</p><ol><li>Click Add Object.</li><li>Select Particle System from the menu.</li><li>Name it water_emitter</li><li>Move it to the level null object</li></ol><p>In the Inspector panel give your particle emitter the following values:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/401/1*x9mr4FbGpKhlPZKsed-Czw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/398/1*_X86M2c_QMhs8KSh_V4nGQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/399/1*hnr74NtM8rDL4QE4abVe7w.jpeg" /></figure><p>That’s it! If we run our effect we should see the game working as expected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/514/1*pS8oixkItjlBIt-ucywJvQ.gif" /></figure><h3>What’s Next?</h3><p>The game that we created in the tutorial is a good template to create similar games with Spark AR, here are some game ideas:</p><ul><li>Board games such as Chess or Checkers</li><li>Turn-based RPG games</li></ul><p>If you’d like to continue building on Rabbit Coder, here are a few ideas:</p><ul><li>Add more commands such as loops and conditionals.</li><li>Design more levels</li><li>Add more game modes</li></ul><h3>Learning Resources</h3><p>Looking for more ways to develop your Spark AR skills Check out the <a href="https://sparkar.facebook.com/ar-studio/learn/tutorials/">official Spark AR Tutorials</a>.</p><ul><li><a href="https://sparkar.facebook.com/ar-studio/learn/articles/world-effects/world-effects-introduction/">World Effects</a></li><li><a href="https://sparkar.facebook.com/ar-studio/learn/scripting/scripting-basics">Scripting Basics</a></li><li><a href="https://sparkar.facebook.com/ar-studio/learn/scripting/reactive-programming">Reactive Programming</a></li><li><a href="https://sparkar.facebook.com/ar-studio/learn/tutorials/adding-particle-systems/">Particle Systems</a></li><li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promises</a></li></ul><p>Some of the free assets used in this game can be found at the following links:</p><ul><li><a href="https://www.kenney.nl/assets/platformer-kit">Kenney Platformer Kit</a></li><li><a href="https://www.kenney.nl/assets/food-kit">Kenney Food Kit</a></li><li><a href="https://www.kenney.nl/assets/interface-sounds">Kenney Interface Sounds</a></li><li><a href="https://freesound.org/">Free Sounds</a></li><li><a href="https://gifer.com/en/OVZK">2D Seamless Water Texutre</a></li><li><a href="https://poly.google.com/view/bFahur-ajA1">Bunny</a> (I made it with <a href="https://ephtracy.github.io/">MagicaVoxel</a>)</li></ul><p>You can find the full code sample on <a href="https://github.com/harrybanda/Rabbit-Coder-Sample-Full">GitHub</a>.</p><p>Thanks for reading! Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2127752f00f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tips on how to win an online hackathon on Devpost]]></title>
            <link>https://medium.com/developer-circles-lusaka/tips-on-how-to-win-an-online-hackathon-on-devpost-c548027e0eae?source=rss-1520ee9d7361------2</link>
            <guid isPermaLink="false">https://medium.com/p/c548027e0eae</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[devpost]]></category>
            <category><![CDATA[hackathons]]></category>
            <dc:creator><![CDATA[Harry Banda]]></dc:creator>
            <pubDate>Thu, 25 Mar 2021 08:34:26 GMT</pubDate>
            <atom:updated>2021-03-25T08:34:26.717Z</atom:updated>
            <content:encoded><![CDATA[<h3>Tips on how to Win an Online Hackathon on Devpost</h3><h4>Below I have written down some tips based on my experiences that will help you win your next online Devpost hackathon.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZaewJD8wklC4SFFytFIWmw.jpeg" /><figcaption>Photo of my Devpost portfolio</figcaption></figure><p>I have taken part in about 17 online hackathons and won 4 of them on <a href="https://devpost.com/">Devpost</a>. This article discusses what I’ve learned.</p><p><strong><em>My Devpost portfolio</em></strong><em>: </em><a href="https://devpost.com/harrybanda7"><em>https://devpost.com/harrybanda7</em></a></p><p>In case anyone reading this doesn&#39;t know what a hackathon is, It’s an event where you build a software project in a short time span (usually 1–2 days). Online hackathons on the other hand can go on for as long as 2 months. Devpost is a platform that helps developers participate in online and in-person hackathons.</p><h3>TIP #1: Read the hackathon rules</h3><p>A hackathon page on Devpost always has a “Rules” section that contains information on eligibility and requirements. You need to read that to make sure you and your team are eligible to take part in the hackathon.</p><h3>TIP #2: Take time to read the requirements</h3><p>After reading the rules and confirming eligibility, You should now take time to read the hackathon requirements. On the “Overview” tab of a hackathon page, you will find “Requirements” and “Judging criteria” sections. Those sections are very important, they provide information on what kind of project the hackathon judges expect you to build and what technologies you must use to build the project. Companies such as Facebook, Amazon, and Microsoft host hackathons on Devpost, and they usually require developers to build software with a specific set of technologies.</p><h3>TIP #3: Take time to plan your idea</h3><p>Unlike the 24-hour and 48-hour in-person hackathons, online hackathons give you more time to build your projects. With all that time the judges expect to see fully functional and well-built submissions. To have a great submission you need to take time to brainstorm and improve your ideas.</p><blockquote>“Constantly think about how you could be doing things better and questioning yourself” ― Elon Musk</blockquote><p>My submission that won first place in the 2020 Facebook AR hackathon was initially just a simple game to move a 3D character left, right, and forward. But after putting more thought into it, I decided it would be better for it to be some sort of educational game for a better chance of winning the hackathon. Eventually, I came to the conclusion of creating an educational game that helps people learn about the basic concepts of programming.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FaZ2peqwS09w&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DaZ2peqwS09w&amp;image=http%3A%2F%2Fi.ytimg.com%2Fvi%2FaZ2peqwS09w%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/4219dc4639d6cbaf1541a0cb8a20efa0/href">https://medium.com/media/4219dc4639d6cbaf1541a0cb8a20efa0/href</a></iframe><h3>TIP #4: Don’t wait until the last minute to submit</h3><p>Starting a submission early is a good way to make sure that your project meets the requirements. There’s nothing worse than getting to the deadline, only to realize that you’re missing a key component. And if the hackathon requires you to submit a video don’t wait until the last minute to record and upload the video. Due to file size, format, and your Internet connection, uploading a video to YouTube can take anywhere from a few minutes to several hours.</p><h3>TIP #5: Presentation is very important</h3><p>A great presentation is key to winning a hackathon. You might have a really good project but fail to get the message out to the judges. You need to take time to create a good presentation that describes your solution very well, keep it simple, highlight the key features and use diagrams. Explain what problem your solution is trying to solve. Explain which of the required technologies were used and how you integrated them in your solution.</p><h3>Final Thoughts</h3><p>Yes, it’s nice to win, but I believe the most important thing about hackathons is learning new things and improving your skills as a developer. After completing a submission you need to ask yourself whether you are proud of what you’ve built. The sense of accomplishment and the knowledge gained are more important than winning. I say this because I have taken part in over 17 hackathons and from those hackathons, I have learned how to use many technologies and improved my software development skills.</p><p>Thanks for reading and I hope you find this information useful. 😁</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c548027e0eae" width="1" height="1" alt=""><hr><p><a href="https://medium.com/developer-circles-lusaka/tips-on-how-to-win-an-online-hackathon-on-devpost-c548027e0eae">Tips on how to win an online hackathon on Devpost</a> was originally published in <a href="https://medium.com/developer-circles-lusaka">Developer Circle Lusaka</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I made a 3D/VR Educational Game Using Only a Web Browser.]]></title>
            <link>https://medium.com/developer-circles-lusaka/how-i-made-a-3d-vr-educational-game-using-only-a-web-browser-affd30a44e39?source=rss-1520ee9d7361------2</link>
            <guid isPermaLink="false">https://medium.com/p/affd30a44e39</guid>
            <category><![CDATA[hackathons]]></category>
            <category><![CDATA[amazon-sumerian]]></category>
            <category><![CDATA[education-technology]]></category>
            <category><![CDATA[virtual-reality]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Harry Banda]]></dc:creator>
            <pubDate>Sun, 24 Feb 2019 18:15:46 GMT</pubDate>
            <atom:updated>2019-04-23T06:23:41.679Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*8DPPvMsBd5-nT54cDArnuQ.jpeg" /></figure><iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fplay.ht%2Farticles%2Faffd30a44e39&amp;src=https%3A%2F%2Fplay.ht%2Fembed%2F%3Farticle_url%3Dhttps%3A%2F%2Fmedium.com%2F_p%2Fhow-i-made-a-3d-vr-educational-game-using-only-a-web-browser-affd30a44e39&amp;type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=play" width="700" height="185" frameborder="0" scrolling="no"><a href="https://medium.com/media/8cfd925b40425b444a115a3be8ecd1a9/href">https://medium.com/media/8cfd925b40425b444a115a3be8ecd1a9/href</a></iframe><p>Virtual Coder is an interactive puzzle game that teaches programming principles and introduces JavaScript using a block-based programming approach. It is designed for children and/or adults who don’t have any experience with coding.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fpqd5ExPWLo8%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dpqd5ExPWLo8&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fpqd5ExPWLo8%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/f5abb7a0b8331f4563687da8f5da9a3d/href">https://medium.com/media/f5abb7a0b8331f4563687da8f5da9a3d/href</a></iframe><h4>Purpose</h4><p><a href="https://devpost.com/software/virtual-coder">Virtual Coder</a> was an entry for the <a href="https://amazonsumerian.devpost.com/">Amazon Sumerian AR/VR Challenge</a>. Participants of this challenge were given 3 months to create a functional 3D, VR or AR application using <a href="https://aws.amazon.com/sumerian/">Amazon Sumerian</a>, a browser-based IDE which allows developers to quickly build 3D experiences.</p><p>The goal for Virtual Coder was to create an educational game that helps people learn to code in a fun, engaging and interactive way with VR. When I think of VR I think of fully immersive environments free from distractions, and I believe that Is the future of education. The original idea was to create some sort of virtual code editor that people can use to write code in V.R, but I realized that typing code on your keyboard with V.R headsets covering your eyes is a really bad idea.</p><p>I had to think of a different way to allow code input without using a physical keyboard, my next Idea was to implement some sort of virtual keyboard that would be floating around in V.R space, but I realized that going with that approach would be difficult and time-consuming, and there was only a month left to the submission deadline so I had to think of something simpler and also better.</p><p>While brainstorming I remembered a simple app built using <a href="http://ai2.appinventor.mit.edu/">App Inventor</a>, an open-source web application for creating Android Apps, App Inventor uses a block-based approach to coding which allows newcomers to computer programming to create simple Android Apps. So I decided to go with this approach as It would be perfect for V.R, users will drag blocks around in VR and manipulate the 3D environment.</p><h4>Building Virtual Coder</h4><p>The first thing I did was write down a development plan I gave my self 3 weeks to bring this idea to life.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/1*gcJ1G5faNGqF4gbuyU-eAA.png" /><figcaption>My schedule</figcaption></figure><p>I’m not that good at planning ahead or creating milestones but when I do I just list down some objectives in Google Keep. It feels great to tick checkboxes, it makes me feel like I’m actually getting things done 😁. I did not follow the development plan exactly as planned, it was a bumpy road trying to build this project but with the help of the Amazon Sumerian community, the Google Blockly community and StackOverflow I was able to continue with the project.</p><h4>The Game</h4><p>In Virtual Coder, players control a virtual robot using code blocks, the game has eleven levels, each level gets a bit more challenging and introduces the player to programming concepts such as functions, loops, and conditionals.</p><p>On the left side of the screen is an amazon Sumerian A.I host and a virtual screen to display information. The middle has the Blockly code editor that allows users to build and run a program and the right side shows the generated JavaScript code, as a user drags the blocks on the screen the corresponding JavaScript code is displayed up on the right.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*WVS7yi2EehRt9eODb_3mzA.jpeg" /></figure><p>Each time the user completes a level the A.I host will also explain the code and concepts. If a user takes a wrong turn the robot will stop and allow the user to try again.</p><h4>The Technical Part</h4><p>I used the Amazon Sumerian to build the whole game from scratch using only the Google Chrome web browser. It was pretty easy to get started with Amazon Sumerian, the best part about it is that you don’t really need any 3D or VR experience to get started, you can also build fully functional VR and AR apps without writing a single line of code, but for my idea to workout I had to write some code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hdhpS05mU3d1wx1db8vGZA.png" /><figcaption>Amazon Sumerian editor</figcaption></figure><p>With Amazon Sumerian, you can easily add objects or import your own 3D assets. Everything in Virtual Coder was made with the already provided assets, the only asset I imported was the little 3D orange robot, which I made using a 3D design tool called <a href="https://ephtracy.github.io/">MagicaVoxel</a>. Amazon Sumerian also comes with a State Machine that allows users to create dynamic and interactive scenes. It also comes with a script editor which lets developers write some code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SrL-cflm85lAEqfET1vqrA.png" /><figcaption>The robot I Made 👨‍🎨</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A21KrHdWJn9McGbXsQx2ng.png" /><figcaption>Amazon Sumerian State Machine</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CzntttZHFfK-5b2k5U5ycw.png" /><figcaption>Amazon Sumerian Code Editor</figcaption></figure><p>I used HTML and CSS to design the 3 Virtual screens that show the block editor, the lesson information, and the JS code. The virtual screens are basically 3D-HTML components meaning you can write any HTML code and style it with CSS. The Code below shows part the HTML used to create the code editor.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7051e5e1a262344fa8c8eb58d7425d56/href">https://medium.com/media/7051e5e1a262344fa8c8eb58d7425d56/href</a></iframe><p>And to make the robot move, make A.I host the talk and switch between levels I wrote some JavaScript code and also used the State Machine for simpler tasks, the Gist below show part of the JS code I used to handle the level complete and Game Over.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3228e543cd0bab7947c3f54255e34fa9/href">https://medium.com/media/3228e543cd0bab7947c3f54255e34fa9/href</a></iframe><p>That is not the complete code but If anyone is Interested in It I can put it all on GitHub. So that is how I built virtual coder it was a great learning experience and hope to see Amazon Sumerian Improve its web-based editor in the future.</p><p>Virtual Coder is still an experimental prototype but I hope to add more to It and improve it with more game modes, better visuals, and support for all V.R hardware.</p><p>Thank You for Reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=affd30a44e39" width="1" height="1" alt=""><hr><p><a href="https://medium.com/developer-circles-lusaka/how-i-made-a-3d-vr-educational-game-using-only-a-web-browser-affd30a44e39">How I made a 3D/VR Educational Game Using Only a Web Browser.</a> was originally published in <a href="https://medium.com/developer-circles-lusaka">Developer Circle Lusaka</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>