<?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 Akhyaan Kumar on Medium]]></title>
        <description><![CDATA[Stories by Akhyaan Kumar on Medium]]></description>
        <link>https://medium.com/@akhyaankumar?source=rss-ca9482b6e729------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*24nzVki5jGbhlA3F</url>
            <title>Stories by Akhyaan Kumar on Medium</title>
            <link>https://medium.com/@akhyaankumar?source=rss-ca9482b6e729------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 08:51:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@akhyaankumar/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[Simulating the End of the World]]></title>
            <link>https://medium.com/gdg-vit/simulating-the-end-of-the-world-41dc4829bca2?source=rss-ca9482b6e729------2</link>
            <guid isPermaLink="false">https://medium.com/p/41dc4829bca2</guid>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[biology]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Akhyaan Kumar]]></dc:creator>
            <pubDate>Sun, 31 May 2026 12:17:33 GMT</pubDate>
            <atom:updated>2026-05-31T15:45:28.386Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GVN_qANeVgDIZuuVVHSrvw.png" /></figure><p>Since Donald Trump couldn’t get it done, I decided to take matters into my own hands and <strong>wipe out a whole civilization</strong>. Let&#39;s just say, for <em>research purposes</em>, I created a digital city with a thousand people, infected five of them with a virus, and then watched the world <strong>burn</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JKkf9REasVVTre4u9UW02g.jpeg" /><figcaption>It’s called Science</figcaption></figure><p>Within a few days, things got interesting. A teacher unknowingly infected half a classroom, a commuter carried the virus across the transit network, a bartender triggered what epidemiologists politely call a <strong>super-spreader event,</strong> and what the simulator displayed as a terrifying spike in the infection graph. Hospitals started filling up, infections began doubling every few days, and the curve on the dashboard climbed in that now-familiar exponential way that makes epidemiologists sigh, and politicians cry.</p><p>Being the <em>merciful and kind</em> being that I am, I <strong>vaccinated thirty percent</strong> of the population and ran it once more. The infection curve changed again. Then twenty percent. Every time, the entire future of the city shifted. What if I applied a mask mandate? Or closed down schools?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*YbVeJvpb39q-o62iAjwN5A.png" /><figcaption>Actual pic of me btw</figcaption></figure><p>That’s when it hit me. A pandemic behaves less like a <strong>biological mystery</strong> and more like a giant <strong>distributed system</strong>. So, like any self-loathing CS major, <em>I decided to debug a pandemic</em>.</p><h4>Pandemic Modelling 101: SIR Models</h4><p>To understand why, we have to start with how pandemics are usually modeled. Traditional epidemiology often uses something called the <strong>SIR model</strong>: <em>Susceptible, Infected, Recovered.</em> It’s elegant and mathematically clean. The entire population is divided into three groups, and equations describe how people move between them over time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gro5h-qrMUahG-hjcPhNfQ.png" /><figcaption>SIR Models (unc’s version)</figcaption></figure><p>Conceptually, it looks like this:</p><pre>Susceptible → Infected → Recovered</pre><p>These models are great for understanding large-scale trends, but they make one very big assumption: the population is <em>“well mixed.”</em> In other words, everyone interacts with everyone equally.</p><p>Which means: Your religious grandma is just as likely to infect a DJ in a Goa nightclub as your roommate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/0*TPPuWzGgdlPg02ws.jpg" /><figcaption>Your grandma probably</figcaption></figure><p>Anyone who has ever tried to coordinate a group chat knows that humans absolutely do NOT behave like that.</p><h4>Not All Humans Are Equal</h4><p>Instead of everyone mixing evenly, humans form <strong>networks</strong>. We interact with coworkers, classmates, family members, and the occasional sweaty uncle riding the metro. Some people meet only a few others each day, while others seem to interact with <em>half the city</em>. Those highly connected individuals often become the infamous <strong>super-spreaders</strong> that drive outbreaks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kFazNRX2kp5FDgr3OR78dA.png" /></figure><p>So instead of modeling populations as averages, the simulator models people.</p><h4>From Populations to People: ABM</h4><p>This approach is called <strong>Agent-Based Modeling</strong>. Every individual is represented as an independent agent with their own characteristics: age, health risk, compliance with public health measures, and level of immunity. Instead of one big equation describing a population, thousands of small simulated people interact with each other, and large-scale patterns emerge naturally from those interactions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wSOqY3jfXmKV7S-hr-o-2A.png" /></figure><p>In code, a simplified version of a person in the simulation might look something like this:</p><pre>class PersonAgent:<br> def __init__(self, age, compliance, comorbidity):<br> self.state = &quot;S&quot;<br> self.age = age<br> self.compliance = compliance<br> self.comorbidity = comorbidity<br> self.immunity_level = 0</pre><p>Each simulated human moves through <em>disease states</em> as the outbreak progresses.</p><h4>The Disease Workflow</h4><p>Rather than thinking of disease as simply “being sick,” it’s helpful to treat it like a <strong>finite state machine.</strong> Every person starts as <em>Susceptible</em>. If they encounter the virus, they move into an <em>Exposed</em> state where the infection incubates. After the incubation period, they become <em>Infectious </em>and can spread the disease to others. Eventually, they either recover and gain temporary immunity or exit the system entirely, which is well… <em>death</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*riC2t8vpQKsYynUcUOnNsg.png" /></figure><p>Conceptually, the transitions look like this:</p><pre>S → E → I → R / D<br>Susceptible → Exposed → Infectious → Recovered or Dead.</pre><p>Each agent follows this sequence, but the exact timing depends on <strong>probabilistic biological parameters</strong> such as incubation periods and infectious durations. If that sounds like a <strong>network protocol state machine</strong>, that’s because <em>it basically is</em>.</p><p>Every agent transitions between these states over time.</p><pre>if self.state == &quot;E&quot;:<br>    self.incubation_timer -= 1<br>    if self.incubation_timer == 0:<br>        self.state = &quot;I&quot;</pre><h4>The Social Network</h4><p>But disease doesn’t spread through thin air alone. It spreads through <strong>connections between people</strong>.</p><p>To model those interactions, the simulator builds a <strong>social network graph</strong>. Each person is a <em>node</em>, and each interaction between people forms an <em>edge</em>. Not all edges are equal. A household interaction might involve long, close contact and therefore carry a high transmission risk, while a brief interaction on public transport might have a much lower probability of infection.</p><p>Instead of generating a completely random network, the simulation uses a <strong>scale-free network</strong>, a structure where most people/nodes have a few contacts, but a few people have hundreds. These are the infamous super-spreaders. Basically, that one friend who knows everyone on campus.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xenr6t98OHNxsUyU13QZ-Q.png" /><figcaption>Barabási-Albert graph</figcaption></figure><p>To model such <em>popular</em> individuals, we generate a Barabási-Albert graph.</p><pre>import networkx as nx<br>G = nx.barabasi_albert_graph(n=1000, m=4)</pre><p>This automatically creates <strong>super nodes</strong>. The virus doesn’t spread evenly; it uses these super nodes as highways, riding them to its next victims.</p><h4>The Fortune/Misfortune behind Infection</h4><p>When an <em>infectious node</em> interacts with a <em>susceptible</em> neighbour, the simulator calculates the <strong>probability</strong> of virus transmission. The probability is calculated using several factors, including how contagious (rate of transmission) the virus is, how intense (weight of the edge) the interaction is, how much virus the infected person is shedding, and how much immunity the other person has.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BnVyG5OS1JuJXGSzVvV_ww.png" /></figure><p>A simplified function that calculates the infection probability might look like this:</p><pre>def infection_probability(beta, weight, viral_load, immunity):<br>    return (1 - immunity) * (1 - math.exp(-beta * weight * viral_load))</pre><p>Every interaction becomes a <em>tiny probabilistic experiment</em>. Most contacts result in nothing. Occasionally, an <strong>infection occurs</strong>. Sometimes, the threads of the network align, and with a slight stroke of fate, a single spark catches, and one person becomes the start of a forest fire that engulfs hundreds.</p><h4>Programming Public Health: Policies</h4><p>While watching chaos get systemized is fun, this simulation has the potential to do something more useful: Assessing the <strong>effectiveness of policies</strong> and <strong>other counter-measures</strong> placed during a pandemic.</p><p>Public health interventions can be represented as modifications to the network or to the transmission probabilities. A <strong>lockdown</strong> reduces certain types of interactions by disabling edges representing workplaces, schools, or travel. <strong>Mask mandates</strong> reduce the effective transmission weight of edges without removing them entirely.<strong> Vaccination</strong> increases immunity levels for selected nodes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iUegHo65VIx6yK_TbYGaSw.png" /></figure><p>In other words,<em> policies are just runtime modifications to the system</em>.</p><p>For example, a <strong>lockdown</strong> might look something like this in code:</p><pre>if edge_type in [&quot;work&quot;, &quot;school&quot;, &quot;social&quot;]:<br>    edge[&quot;active&quot;] = False</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zdyw9YgodDbGnjCJIQmOkw.png" /><figcaption>Baseline vs Lockdown</figcaption></figure><p><strong>Mask mandates</strong>, instead of removing interactions, might simply reduce their transmission strength:</p><pre>edge[&quot;weight&quot;] *= 0.6</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EncoagcRqFro7sNgaIV67w.png" /><figcaption>Baseline vs Mask Mandate</figcaption></figure><p>And <strong>vaccination</strong> might update the immunity level of individuals directly:</p><pre>agent.immunity_level = 1.0<br>agent.state = &quot;R&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zu8AGhT3pzqM06ZkFwJVFA.png" /><figcaption>SEIRD post-immunity in 0.55% of the population</figcaption></figure><p>Just like that, <em>policies become code</em>.</p><h4>Worlds that don’t exist</h4><p>Like a real-world pandemic, every outbreak in this simulator is shaped by countless variables. How <em>contagious</em> is the disease? How <em>long can it spread</em> before symptoms appear? How <em>many people</em> interact each day? How <em>resilient</em> is the healthcare system? Are people vaccinated, cautious, or completely unaware? By tweaking these inputs, we can create <strong>entirely different worlds</strong> and explore the surprising realities that emerge from them, some expected, others <em>deeply counterintuitive</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QVHlr9yc5wpEVAVWnTsUtQ.png" /><figcaption>Inputs for our simulator</figcaption></figure><h4>The Walking Infected</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eOzyt88ql-VbP5shukI1tg.png" /></figure><p>For weeks, life in the city carried on as normal. Schools stayed open, offices stayed busy, and most people assumed there was little to worry about. The virus, however, had a <em>different plan</em>. With a long <strong>17.2-day incubation period</strong>, it moved quietly from person to person, spreading through neighborhoods before anyone could sense the danger looming around. By <strong>Day 56</strong>, only <strong>502 people </strong>appeared visibly<strong> sick</strong>, yet nearly <strong>3,000 </strong>more were<strong> already infected, </strong>but didn’t have any symptoms. The city thought it was facing a small outbreak when, in reality, the storm had already passed through.</p><p>The virus conquered the city in silence. By the time its presence became undeniable, <strong>99.9%</strong> of residents had already been <strong>infected</strong>, and the healthcare system was fighting a losing battle, which was decided weeks earlier. Active cases eventually peaked at <strong>1,179</strong>, overwhelming a healthcare system built to handle only <strong>100 patients at a time</strong>. By the end, <strong>92 people had died</strong>, and the outbreak had stolen <strong>593 years of life</strong> from the community. With the average lifespan set at 75 years, the numbers suggest that the virus drove its fangs deepest into older individuals, claiming victims who averaged around 68 years of age. Judging by the numbers, the <em>hottest</em> social scene wasn’t downtown; it was the yoga club all along.</p><h4>A War Nobody Won</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q8maeti5hipchYTCGc3Q7g.png" /></figure><p>This outbreak never achieved the near-total conquest of the previous scenario, but it was far more ruthless to those within its grasp. Despite infecting only <strong>2,579 of 5,000 residents (51.6%)</strong>, the virus claimed <strong>154 lives, </strong>nearly twice the death toll of their counterpart. The city’s hospitals bent under pressure but never completely collapsed, peaking at <strong>312 active cases</strong> against a capacity of <strong>175 beds</strong>. Instead of a <em>silent takeover</em>, it turned into a <em>war of attrition</em>. Every infection carried a heavier risk, and every outbreak cluster left deeper scars on the community.</p><p>The <strong>1,121 Years of Life Lost</strong> reveal where the real damage occurred. The retirement homes were still busy, but this time the virus wasn’t content with just the senior social circuit. It found its way into family gatherings, workplaces, and communities that still had decades left on the clock.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7lLiRDRp0xaS7WXRUgevOg.png" /></figure><p>The turning point came from the combination of <strong>lockdowns and social distancing</strong>. Together, they cut off many of the network connections the virus relied on to hop between communities. The effect is visible in the graph: after <strong>Day 47</strong>, active cases begin a steady decline rather than exploding into a second wave. It’s still a devastating outbreak, but it is dramatically smaller than what would have happened had transmission continued unchecked.</p><p>These worlds may be fictional, but the forces shaping them are very real. A slightly longer incubation period, a delayed lockdown, a more contagious virus, or a stronger healthcare system can completely change the story. Small changes snowball into dramatically different outcomes, creating entirely new realities from the same underlying model. If you’d like to experiment with those realities yourself, check out the project <a href="https://github.com/Akhyaan/pandemic-simulator">here</a>.</p><h4>The Pattern of Irregularity</h4><p>Once you run enough simulations, something strange happens. You stop looking at pandemics as singular events and start seeing patterns everywhere.</p><p>A single <strong>super-spreader</strong> can outweigh <strong>hundreds</strong> of normal interactions. Tiny delays in policy can shift the peak by weeks. Small changes in compliance can quietly decide whether hospitals cope or collapse.</p><p>But the most surprising part isn’t how <em>complex </em>the system is<em>.</em></p><p>It’s how <em>sensitive</em> it is.</p><p>Two runs that start almost identically can end in completely different outcomes, just because one person took a different path through the network at the <strong>wrong time</strong>. The difference between “manageable outbreak” and “full-blown crisis” often comes down to a handful of interactions that look insignificant in isolation.</p><p><strong>This begs the question: Can we actually debug a Pandemic?</strong></p><p>Of course, no model perfectly captures the complexity of the real world. Human behavior is <strong>unpredictable</strong>, data is<strong> incomplete</strong>, and real epidemics involve countless <strong>variables</strong> beyond any simulation. But models like these serve an incredibly valuable purpose. They allow us to <em>explore possible futures before we experience them.</em></p><h4>The Ultimate Distributed System</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rAqUf3puQ_8GUFeMfKw7zg.png" /><figcaption>DistributedSystemsDistributedSystemsDistributedSystems</figcaption></figure><p>In the end, a pandemic is really just a system that processes events, propagates signals, mutates parameters, and continuously reshapes a network of interactions. <em>Sounds familiar, right?</em> It’s because those are exactly the same dynamics that govern <strong>distributed computing systems.</strong></p><p>The difference is that when distributed systems fail, <em>websites go down</em>. When pandemic systems fail, <strong>entire societies shut down</strong>.</p><p>Maybe the future of public health will look a little more like software engineering. Maybe before policies are deployed to the real world, they’ll be tested in thousands of simulated worlds first.</p><p>Because if there’s one lesson programmers learn early, it’s this: <em>debugging systems in production is never a good idea</em>. So maybe instead of learning from pandemics, <strong>we should learn about them first</strong>. After all, history repeats itself, and pathogens seem committed to the bit.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=41dc4829bca2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/gdg-vit/simulating-the-end-of-the-world-41dc4829bca2">Simulating the End of the World</a> was originally published in <a href="https://medium.com/gdg-vit">GDG VIT Vellore</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Want your own Game before GTA 6?]]></title>
            <link>https://medium.com/gdg-vit/want-your-own-game-before-gta-6-c7a79c0a8e2a?source=rss-ca9482b6e729------2</link>
            <guid isPermaLink="false">https://medium.com/p/c7a79c0a8e2a</guid>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[design]]></category>
            <category><![CDATA[guides-and-tutorials]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[games]]></category>
            <dc:creator><![CDATA[Akhyaan Kumar]]></dc:creator>
            <pubDate>Sat, 09 Aug 2025 16:40:07 GMT</pubDate>
            <atom:updated>2025-10-19T17:23:27.120Z</atom:updated>
            <content:encoded><![CDATA[<h3>Want Your Own Game Before GTA 6?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T9CvbsxeHQkg7AMydUe1hQ.png" /></figure><p>While the world is busy trolling Rockstar Games for depriving us of GTA 6 for decades, how about you lock in and make your own?</p><p>You may not be interested in coding; perhaps you consider programming monotonous and tedious. But everyone loves a <em>good game</em>. Games are fun, exciting, and even relaxing; moreover, they allow one to access worlds that would otherwise not exist. But, <strong>Game Development</strong> is not just about coding; it’s an <em>art</em> where creativity, design, narrative, and code intersect. And even if you’ve never written a single line of code, knowing how games are made can provide you with a newfound appreciation for how code can turn imagination into something so alive.</p><p>So our goal for today? To explore how a simple <strong>2D platformer</strong>, <em>a forever classic</em>, is built from scratch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*ouXjgy54N9gxfgOERejTuw.jpeg" /></figure><h4><strong>What is a Platformer?</strong></h4><p>We all dream of creating the next <em>Elden Ring</em>, but first, we need to start with something that teaches us the fundamentals of game development. A platformer is the perfect starting choice due to its simple format and code, allowing you to get well-versed with both the design and programming elements of game development.</p><p>A platformer is a type of video game where the player navigates a world by jumping across platforms, avoiding traps, and may include elements like parkour and combat. Many of the most popular games of all time, such as <em>Super Mario Bros</em>. and <em>Hollow Knight</em>, were built on these concepts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*qF-C1WckKwg_c7olxc6kBQ.avif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x2HmE2-_KG2MKElXCE47Jg.jpeg" /><figcaption>Credits to Nintendo &amp; Team Cherry</figcaption></figure><h3><strong>Game Ideation</strong></h3><p>Like every project ever, a great game starts with an <em>idea</em>. We first need to define a core theme. It can be an adventurous world featuring forests and castles, or it could be an eerie world filled with darkness, but that’s your choice. Next, we decide the mechanisms that dictate the gameplay. I heavily recommend keeping it simple for your first game, so let’s focus on basic movement, jumping, and enemies. Now that you have an idea of the type of game you’re creating, it’s time to choose your tools.</p><p>Any game is brought to life by three components: A<strong> game engine,</strong> <strong>code scripts</strong>,<strong> </strong>and<strong> assets</strong>.</p><h4>Selecting The Proper Tools</h4><p>For this game, we will be using <strong>Unity </strong>as our game engine. <a href="https://unity.com/download">Unity</a> is widely used and supports <strong>C#</strong>, and is known for its community support.</p><p><strong>Assets</strong> are the elements that make up the game, such as the sprites, 3D models, textures, and even sound effects. <a href="https://assetstore.unity.com/?srsltid=AfmBOoqjP82aGh0mg3q7FDVnLaFZM5PlvkRLokIZlgqhMyX44pyc9neN"><strong>The Unity asset store</strong></a> features a wide array of free and paid assets that you can use, which allows you to make games without being skilled at design. Make sure you select an asset package that fits the theme of your game.</p><p>To write the C# scripts, <a href="https://code.visualstudio.com/download"><strong>Visual Studio Code</strong></a> is good enough.</p><h3><strong>Setting Up The Project</strong></h3><p>Now that you&#39;re locked and loaded, it&#39;s time to start.</p><ul><li>Step 1: After downloading Unity, start <strong>Unity Hub</strong> and open a new <strong>2D project</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4nkkxP3zqbEZ-QcvccNZyQ.png" /><figcaption>This is what it should look like</figcaption></figure><ul><li>Step 2: Within the Unity editor, we create a simple scene, maybe just a floor for starters. For that, we create a new game object by right-clicking the <strong>Hierarchy</strong> and selecting 2D Object. Then assign a simple rectangle sprite. Rename the sprite to “Floor”.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*26AK4GczNJ9E1tccRTqwyw.png" /></figure><ul><li>Step 3: Shape and move it using the tools on the left.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lHCuTmkNJcI3drFiXpej_w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t_vD3MmSLYPmHBC8vU1yXQ.png" /></figure><ul><li>Step 4: Then add a <em>BoxCollider2D</em> to the object by adding a component in the <strong>Inspector</strong> window, so that our character has something solid to stand or run on.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s3swppyIQDec2rNlcXdt4Q.png" /></figure><p>And just like that, we have a solid floor.</p><h4>Creating The Player</h4><p>Your first significant task is now ahead of you: constructing the player.</p><ul><li>Step 1: Create a new game object by right-clicking the <em>Hierarchy</em> window.</li><li>Step 2: Assign it a sprite so it’s visible. This can be done by the “Add Component” button in the <em>Inspector</em> window.</li><li>Step 3: Attach a <em>RigidBody2D</em> to the player object so that it can respond to gravity and motion.</li><li>Step 4: Attach a <em>BoxCollider2D</em> to allow it to interact with the game world physically.</li></ul><p>But as of now, without any movement script, it’s lifeless.</p><h3><strong>Implementing Movement</strong></h3><p>The movement script is the <em>essence</em> behind the player’s control system. It reads player input every frame using Unity’s input axis to identify horizontal movement, and then it applies physics-based velocity to the player object.</p><p>In the<em> Project</em> window, right-click the Assets folder to create a new <strong>“Scripts”</strong> folder for all <em>C# scripts</em>. Do the same for animations, sprites, etc. Inside the folder, create a <strong>MonoBehaviour Script </strong>named “PlayerMovement” and open it for editing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sURPRcey-3mTbfETqJmRug.png" /></figure><h4>Creating Our Variables</h4><p>We first start by declaring the variables:</p><pre>using UnityEngine;<br><br>public class PlayerMovement: MonoBehaviour<br>{   [SerializeField] private LayerMask groundLayer;<br>    [SerializeField] private LayerMask wallLayer;<br>    [SerializeField] private float speed;<br>    [SerializeField] private float jumpforce;<br>    private Rigidbody2D body;<br>    private Animator anim;<br>    private BoxCollider2D boxCollider;<br>    private float wallJumpCooldown;<br>    private float horizontalInput;</pre><p>But what do these variables <em>mean</em>?</p><p>The variables groundLayerand wallLayerlet Unity label and differentiate wall objects from floor objects.</p><ul><li>The bodyvariable is a reference to the <em>RigidBody2D</em> attached to our player object, used for physics-like movement and gravity.</li><li>The boxColliderhelps us check for collisions with the ground and walls.</li><li>To store the left/right input from the user, we make use of the horizontalInputvariable.</li><li>The float wallJumpCooldownwill act as a timer to prevent multiple wall jumps.</li></ul><h4>Basic Movement</h4><p>Next, we have to initialize the Awake()method, which will fetch the <em>RigidBody, BoxCollider</em>, and <em>Animator</em> attached to the player GameObject so that we can use them throughout the script.</p><pre> private void Awake()<br>    {   //Grab references for rigidbody to get animation<br>        body = GetComponent&lt;Rigidbody2D&gt;();<br>        anim = GetComponent&lt;Animator&gt;();<br>        boxCollider = GetComponent&lt;BoxCollider2D&gt;();<br><br>    }</pre><p>Now, we will create the Update()method, which will run every frame and read the input to control the player object and its movement.</p><pre>private void Update()<br>    {   <br>        horizontalInput=Input.GetAxis(&quot;Horizontal&quot;);<br><br>        //flipping code<br>        if(horizontalInput&gt;0.01f)<br>        {<br>            transform.localScale=Vector3.one;<br>        }<br>        else if(horizontalInput&lt;-0.01f)<br>        {<br>            transform.localScale=new Vector3(-1,1,1);<br>        }</pre><p>The first thing it does is read the player’s left/right input using Input.GetAxis(“Horizontal”), which returns a value between -1 and 1, i.e., left to right, based on the keyboard input.</p><p>Next, the character sprite is <em>flipped</em> to face the direction of movement. If the player presses right, the scale remains as (1, 1, 1), meaning the sprite is drawn normally. If the player moves left, the X scale is flipped to -1, which mirrors the sprite horizontally.</p><p>Now we add the <strong>movement</strong>:</p><pre>if (wallJumpCooldown&gt;0.2f)<br>        {<br>                body.velocity= new Vector2(Input.GetAxis(&quot;Horizontal&quot;)*speed,body.velocity.y);<br>                if (onWall() &amp;&amp; !isGrounded())<br>                {<br>                    body.gravityScale=0;<br>                    body.velocity= Vector2.zero;<br>                }<br>                else<br>                {<br>                    body.gravityScale=5 ;<br>                }<br>                <br>                if(Input.GetKey(KeyCode.Space))<br>                {<br>                    Jump();<br>                }<br>        }<br><br>        else<br>        {<br>            wallJumpCooldown += Time.deltaTime;<br>        }</pre><p>If the wallJumpCooldownis greater than 0.2 seconds, meaning we’re not in the middle of a wall jump, then we allow normal movement. The player’s velocity is updated using the <em>Rigidbody2D</em>. The X velocity is set to horizontalInput * speed, and the Y velocity is left unchanged.</p><p>This lets the player move left and right while still falling or jumping. If they’re on a wall but not grounded, gravity is <em>disabled</em> and movement stops, letting them prepare a <strong>wall jump</strong>. Otherwise, gravity returns to normal. Pressing space triggers a <em>jump</em>.</p><p>The <strong>jump</strong> logic is handled in the Jump()method, which we will define later. If the wall jump cooldown hasn’t yet passed 0.2 seconds, the timer is increased over time using Time.deltaTimeto ensure smooth wall jump timing.</p><p>To update the <em>animation</em> states:</p><pre>//set animator<br>        anim.SetBool(&quot;run&quot;,horizontalInput!=0);<br>        anim.SetBool(&quot;grounded&quot;,isGrounded());<br><br>        print(onWall());<br> }</pre><p>If the player is moving, i.e, the horizontal input isn&#39;t zero, we tell the <em>animator</em> to play the “run” animation. We also let it know whether the player is on the ground by checking isGrounded(). <em>These animations won’t work unless they have been set up in Unity, which we will do after completing this script.</em></p><h4>Creating Jump And Wall Jump Mechanisms</h4><p>To enable jumping, we will initialize the Jump()method, which was also used in the Update()method.</p><pre> private void Jump()<br>    {   <br>        if(isGrounded())<br>        {<br>            body.velocity = new Vector2(body.velocity.x,jumpforce);<br>            anim.SetTrigger(&quot;jump&quot;);<br>        }<br>        else if(onWall()&amp;&amp; !isGrounded())<br>        {   <br>            if (horizontalInput==0)<br>            {<br>                body.velocity=new Vector2(-Mathf.Sign(transform.localScale.x)*10,0);<br>                transform.localScale= new Vector2(-Mathf.Sign(transform.localScale.x),transform.localScale.y);<br>            }<br>            else<br>            {<br>                body.velocity=new Vector2(-Mathf.Sign(transform.localScale.x)*3,6);<br>            }<br>            wallJumpCooldown=0;<br>            <br>        }<br><br>    }</pre><p>If the player is on the ground, they jump up with jumpforce. If they’re grounded but on a wall, they do a wall jump. Without input, the jump is directly off the wall; with input, it’s diagonal. Mathf.Sign() looks at which direction the player is facing in order to determine the direction, and the cooldown is reset upon jump.</p><h4>Methods to Check Player State</h4><p>In both these blocks of code, we have used the onWall()and isGrounded()methods, which act as flags.</p><pre>private bool isGrounded()<br>    {<br>        RaycastHit2D raycastHit= Physics2D.BoxCast(boxCollider.bounds.center,boxCollider.bounds.size,0, Vector2.down, 0.01f, groundLayer);<br>        return raycastHit.collider != null;<br>    }<br><br>     private bool onWall()<br>    {<br>        RaycastHit2D raycastHit= Physics2D.BoxCast(boxCollider.bounds.center,boxCollider.bounds.size,0, new Vector2(transform.localScale.x,0), 0.01f, wallLayer);<br>        return raycastHit.collider != null;<br>    }</pre><p>This method uses a <strong><em>BoxCasting</em></strong> to detect if the player is touching the ground. It shoots a tiny box below the player’s collider and checks if it hits any object marked as part of the ground layer. If it does, the player is grounded and can jump.</p><h4><strong>Attaching Script to GameObject</strong></h4><p>Now that we are done writing the movement script, let’s attach it to our player object. In Unity, select the Player from the <em>Hierarchy </em>window, then drag the <strong>PlayerMovement</strong> script to the inspector window. With this, our player has been granted<em> motion</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K_rEkBNuC83pCNWAk3KUrA.png" /></figure><h3><strong>Building a Level</strong></h3><p>With the movement done now, let’s create a world for our player to move around in. Unity’s Tilemap system is like a digital canvas where you can paint your levels.</p><p>These tiles include platforms, walls, and obstacles. Each of them needs a collider so the player doesn’t go through them. Build your first level by arranging these tiles into a start, a middle with some difficulty, and an end.</p><p>Use multiple layers to arrange the background, platforms, player object, and UI. Place your player object at the start of the level, go to the game window, and hit play. You have now brought your game to a playable stage.</p><h3><strong>Implementing Design</strong></h3><p>Anything can be interesting if it’s <strong><em>pretty</em></strong> enough. It’s time to implement some art into our game, without which it’s just a bland world, not worth entering.</p><p>Import your own <em>sprites</em> or assets if you have any, or feel free to download some from the <strong>Unity Web Store.</strong> Start by assigning proper sprites to each object, i.e., the player and the environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iEQlzAqYqXFzOUWN3suOuA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sLUKXnDCPP8c7Ag_GkYx3Q.png" /><figcaption>Scene and Game window after implementing design using tilemap on imported assets</figcaption></figure><p>I have <a href="https://assetstore.unity.com/packages/2d/characters/dragon-warrior-free-93896">used</a> this asset set for this project.</p><h4>Setting Up Animations</h4><p>Next is the <em>animation</em>, which takes our game from just a simulation to a realistic experience. To animate our player object:</p><ul><li>Step 1: Select the Player object and add an <strong>“Animator”</strong> component in the <em>Inspector </em>window.</li><li>Step 2: Create a separate folder for animations in the <em>Assets</em> folder. In this folder, create and select <strong>Animator Controller</strong> and drag this to the <strong>Controller</strong> field in the <em>Animator component</em>.</li><li>Step 3: Next, we add the <strong>Animation</strong> and <strong>Animator </strong>windows, which are available in the <em>Animation</em> section in the top bar’s <strong>Window </strong>section.</li><li>Step 4: Now, in the added <em>Animation</em> window, press <em>Create</em> and name it “idle”.</li><li>Step 5: Press the red record button. In the Sprite Renderer, click the circle next to the Sprite field and select “Idle_01”. Now move to a different time where you want to add a keyframe, let’s say, 0:05, and add the sprite “Idle_02”. Repeat till you have all the keyframes, and then stop recording.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8yZIeHAT3MoZIUlP-jn8OQ.gif" /><figcaption>Idle Keyframes</figcaption></figure><ul><li>Step 6: To create the “Run” or “Jump” animation, repeat steps 4–5, but with the required sprites.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*it4WEtyNm2v8PwF8Mwv4kg.gif" /><figcaption>Run Keyframes</figcaption></figure><ul><li>Step 7: Now we can add <em>transitions</em> in the <em>animator</em> window. Right-click on the <em>Idle</em> animation and “Make Transition”; an arrow will now appear. Click on the <em>Run</em> animation to define the transition’s begin and end states.</li><li>Step 8: In the Animator window, under parameters, add a boolean <em>“run”</em>.</li><li>Step 9: Now, select the transition arrow, and add a condition in the <em>Inspector</em> window. Make sure the value is set to true.</li><li>Step 10: Now add a transition arrow from <em>run</em> to <em>idle</em>, but this time set the boolean <em>“run”</em> value to false.</li><li>Step 11: In both transitions, turn off the <em>exit time</em> in the Inspector window.</li><li>Step 12: Repeat for “Jump” or other animations and their transitions.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yeKM2OE1GUMj8UtINga5-Q.gif" /><figcaption>This is what the complete Animator should look like (ignore extra actions like Attack &amp; Hurt)</figcaption></figure><p>The <em>PlayerMovement</em> script should be fully working now. Go to the <strong>Game</strong> window, and press play to test the animations and the movement.</p><h4><strong>Dynamic Camera</strong></h4><p>Adding camera movement can drastically improve the gameplay, as it improves the previously static world. The aim is to have the camera follow the player object.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IVpklfb7b0-_sHqSyf-AQw.gif" /></figure><p>So we create a <strong><em>camera movement script</em></strong> and attach it to the <em>camera object</em>, which will constantly update the camera’s position based on the player’s location. To do this, click on the <strong>Main Camera</strong> in the <em>Hierarchy</em>, then drag the <em>camera movement script</em> from the <em>Project</em> window into the <em>Inspector</em>. We use Vector3.Lerp(), which can calculate the desired camera position and then gradually take the camera there. This makes the camera movement softer.</p><pre>using UnityEngine;<br><br>public class CameraController : MonoBehaviour<br>{<br>    //room camera<br>    [SerializeField] private float speed=0.1f;<br>    private float currentPosX;<br>    private Vector3 velocity= Vector3.zero;<br><br>    //follow player<br>    [SerializeField] private Transform Player;<br>    [SerializeField] private float aheadDistance;<br>    [SerializeField] private float camSpeed;<br>    private float lookAhead;<br><br><br><br>    private void Update()<br>    {   <br>        //room camera<br>       <br>        //follow player<br>        transform.position=new Vector3(Player.position.x+lookAhead, transform.position.y, transform.position.z );<br>        lookAhead=Mathf.Lerp(lookAhead,(aheadDistance*Player.localScale.x),Time.deltaTime*camSpeed);<br><br>    }<br><br><br>}</pre><h3><strong>Adding a Passive Enemy Object</strong></h3><p>What’s an adventure without some danger? There would be no <em>Subway Surfers</em> if it weren’t for the passionate connection between the <em>Cop</em> and <em>Jake</em>, and no <em>Temple Run</em> without a <em>monstrous monkey</em> chasing you. So let’s add a threat to the environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uXcqX8hPEu02_xFns2RfUQ.png" /></figure><p>We’ll add an object that traverses between two points, and contact with the player object will result in <strong>death</strong>, basically a reset. For this, we first create an enemy object and assign a basic movement script, <em>“Enemy_Sideways”</em>. And if the box colliders of the enemy object and player come in contact, the player’s position changes to the start point, i.e., <em>level reset</em>.</p><p>Additionally, a death animation can be set up for the same.</p><pre>using UnityEngine;<br>using UnityEngine.SceneManagement; // Needed to reload the scene<br><br>public class Enemy_Sideways : MonoBehaviour<br>{<br>    [SerializeField] private float movementDistance;<br>    [SerializeField] private float speed;<br><br>    private bool movingLeft;<br>    private float leftEdge;<br>    private float rightEdge;<br><br>    private void Awake()<br>    {<br>        leftEdge = transform.position.x - movementDistance;<br>        rightEdge = transform.position.x + movementDistance;<br>    }<br><br>    private void Update()<br>    {<br>        if (movingLeft)<br>        {<br>            if (transform.position.x &gt; leftEdge)<br>            {<br>                transform.position = new Vector3(<br>                    transform.position.x - speed * Time.deltaTime,<br>                    transform.position.y,<br>                    transform.position.z<br>                );<br>            }<br>            else<br>                movingLeft = false;<br>        }<br>        else<br>        {<br>            if (transform.position.x &lt; rightEdge)<br>            {<br>                transform.position = new Vector3(<br>                    transform.position.x + speed * Time.deltaTime,<br>                    transform.position.y,<br>                    transform.position.z<br>                );<br>            }<br>            else<br>                movingLeft = true;<br>        }<br>    }<br><br>    private void OnTriggerEnter2D(Collider2D collision)<br>    {<br>        if (collision.CompareTag(&quot;Player&quot;))<br>        {<br>            // Restart the level by reloading the current scene<br>            SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);<br>        }<br>    }<br>}</pre><h3><strong>Testing &amp; Publication</strong></h3><p>Now you can test. This is where you hone the experience. Jump too <em>floaty</em>? Fix gravity. Enemies too <em>brutal</em>? Modify speed or movement distance. Level feel too <em>brief</em> or too <em>long</em>? Change the layout. Your game is not complete until it feels <em>just right</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FPvvkfXIXXa783vFkT6gKA.gif" /></figure><p>Once you’re satisfied, export your build with <a href="https://youtu.be/8iApGVX--B0?si=CUssTwfjpJLS-R8G"><strong>Unity’s build </strong></a>tools. The build’s zipfile can be uploaded to platforms such as<a href="https://itch.io/"> <strong>itch.io</strong></a>, where the whole world can access and play your game.</p><h3><strong>Conclusion</strong></h3><p>With this, you can now flex a playable game to your friends. Any idea can be turned into a game by starting with a simple <em>concept</em>, choosing the right <em>tools</em>, and building solid <em>scripts</em> wrapped in good <em>design</em>. But this is just the beginning; add levels, parkour, shooting, combat, and more. And remember, game dev isn’t limited to platformers. Once you’ve built one, you’re just steps away from creating horror like <em>Five Nights at Freddy’s</em> or chaos like <em>Only Up</em>. Why limit yourself to one genre when <em>Roblox</em> itself has combat, fashion, RP, or anything you can think of. The choice is <strong><em>yours</em></strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c7a79c0a8e2a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/gdg-vit/want-your-own-game-before-gta-6-c7a79c0a8e2a">Want your own Game before GTA 6?</a> was originally published in <a href="https://medium.com/gdg-vit">GDG VIT Vellore</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>