<?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 Aourex on Medium]]></title>
        <description><![CDATA[Stories by Aourex on Medium]]></description>
        <link>https://medium.com/@avinashmurmu664?source=rss-1a9397833c26------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*3i3ElDRKPuAFLx5haLsvSw.jpeg</url>
            <title>Stories by Aourex on Medium</title>
            <link>https://medium.com/@avinashmurmu664?source=rss-1a9397833c26------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 13:50:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@avinashmurmu664/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[How to Build a Seamless Infinite Background Scroll in Vanilla JavaScript Canvas]]></title>
            <link>https://medium.com/@avinashmurmu664/how-to-build-a-seamless-infinite-background-scroll-in-vanilla-javascript-canvas-87350c794f71?source=rss-1a9397833c26------2</link>
            <guid isPermaLink="false">https://medium.com/p/87350c794f71</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[html5-canvas]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[game-development]]></category>
            <dc:creator><![CDATA[Aourex]]></dc:creator>
            <pubDate>Sun, 31 May 2026 05:26:50 GMT</pubDate>
            <atom:updated>2026-05-31T05:26:50.362Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="A professional developer workspace showing a laptop screen with code for an infinite background scroll loop in HTML5 Canvas, demonstrating the difference between a 1-pixel seam gap error and a seamless frame reset." src="https://cdn-images-1.medium.com/max/670/1*GtGrhnU7KeuEvFT7JVQNtw.png" /></figure><h3>Part 1 — Concept, Mathematics &amp; Environment Setup</h3><h3>Beyond the Static Screen: How to Code a Seamless Infinite Background Loop in HTML5 Canvas</h3><p>If you are building a 2D side-scroller, an endless runner (like the Google Dino game), or a space shooter, a static background is the easiest way to make your game look dead. Movement defines life in game design.</p><p>To create the illusion of a vast, never-ending world, you don’t need to load a massive, thousands-of-pixels-wide image asset that tanks your browser’s performance. Instead, you need <strong>mathematical deception</strong>: an infinite loop using just a single tiling background image.</p><p>In this comprehensive guide, we will break down the precise engineering logic behind an infinite horizontal background scroll using raw, dependency-free JavaScript and the HTML5 Canvas API.</p><h3>🧠 The Core Logic: The Illusion of Two Images</h3><p>How do you make a finite image stretch to infinity? <strong>By rendering it twice.</strong></p><p>Imagine two identical background images placed side-by-side on a conveyor belt moving toward the left at a constant speed ($V$):</p><ol><li><strong>Image A (Primary):</strong> Starts at an X-coordinate of 0.</li><li><strong>Image B (Secondary):</strong> Starts exactly where Image A ends, at an X-coordinate equal to the image’s width (W).</li></ol><pre>[   Screen Window   ]<br>+-------------------+-------------------+<br>|    Image A (x1)   |    Image B (x2)   |  &lt;-- Both move Left (-Speed)<br>+-------------------+-------------------+<br>x1 = 0              x2 = W</pre><p>As the game loop runs, both images move left by deducting the speed value from their X-coordinates (x1 -= speed and x2 -= speed).</p><p>The magic happens the exact millisecond Image A completely leaves the left edge of the screen (i.e., when its position becomes x1 &lt;= -W). Instead of letting it drift into digital oblivion, we instantly snap it back to the right side, positioning it perfectly behind Image B (x1 = x2 + W).</p><p>This cycle repeats indefinitely, creating a flawless, uninterrupted loop.</p><h3>🛠️ Step 1: The HTML &amp; CSS Environment Blueprint</h3><p>We want our digital playground to look highly professional. We will center our canvas perfectly on the screen with a modern dark aesthetics wrapper.</p><p>Create an index.html file and drop in the structural setup:</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot;&gt;<br>    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;<br>    &lt;title&gt;Infinite Background Scroll | HTML5 Canvas&lt;/title&gt;<br>    &lt;style&gt;<br>        * {<br>            margin: 0;<br>            padding: 0;<br>            box-sizing: border-box;<br>        }<br>        body {<br>            background-color: #0f172a; /* Sleek dark slate color */<br>            display: flex;<br>            justify-content: center;<br>            align-items: center;<br>            min-height: 100vh;<br>            overflow: hidden;<br>            font-family: system-ui, -apple-system, sans-serif;<br>        }<br>        #gameContainer {<br>            box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);<br>            border-radius: 8px;<br>            overflow: hidden;<br>            border: 2px solid #334155;<br>        }<br>        canvas {<br>            display: block;<br>            background: #1e293b; <br>        }<br>    &lt;/style&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br><br>    &lt;div id=&quot;gameContainer&quot;&gt;<br>        &lt;!-- We define standard 16:9 widescreen arcade proportions --&gt;<br>        &lt;canvas id=&quot;scrollCanvas&quot; width=&quot;800&quot; height=&quot;450&quot;&gt;&lt;/canvas&gt;<br>    &lt;/div&gt;<br><br>    &lt;script src=&quot;script.js&quot;&gt;&lt;/script&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><h3>Step 2: JavaScript Architecture &amp; Asset Management</h3><p>Now, let’s switch to script.js. Before rendering frames, we must safely initialize our canvas context and ensure our graphic asset is entirely loaded into memory. Trying to read image properties (like width) before loading completes is the number one cause of runtime crashes in browser games.</p><pre>const canvas = document.getElementById(&quot;scrollCanvas&quot;);<br>const ctx = canvas.getContext(&quot;2d&quot;);<br><br>// Configuration parameters<br>const GAME_SPEED = 3; <br><br>// Initializing the background asset<br>const backgroundImage = new Image();<br>backgroundImage.src = &quot;https://i.imgur.com/Q99M6rL.png&quot;; // A generic tiling parallax background layer<br><br>// State tracking object for our two shifting coordinates<br>const background = {<br>    x1: 0,<br>    x2: 0, // Will be set dynamically based on image asset width<br>    y: 0,<br>    width: 0,<br>    height: canvas.height // Scale image height to match canvas perfectly<br>};<br><br>// Guarantee asset availability before invoking the engine<br>backgroundImage.onload = function() {<br>    // Dynamically calculate aspect ratio to maintain image proportions<br>    const aspectRatio = backgroundImage.width / backgroundImage.height;<br>    background.width = background.height * aspectRatio;<br>    <br>    // Position the secondary image precisely adjacent to the primary image<br>    background.x2 = background.width;<br>    <br>    // Execute our engine loop (We will build this in Part 2)<br>    initEngine();<br>};</pre><p><strong>The 1-Pixel Seam Gap Warning:</strong> Most amateur tutorials teach developers to reset the image using integers like x1 = 0. This creates a flickering 1-pixel transparent line (seam gap) between the two images over time due to rounding decimals in game loops. In the next section, we will write mathematically precise seam-less logic to solve this entirely.</p><h3>Part 2 — The Animation Engine &amp; Mathematical Seamless Execution</h3><h3>Building the Engine: RequestAnimationFrame &amp; Drawing Logic</h3><p>To make the background move smoothly without causing CPU choking, we rely on requestAnimationFrame(). Unlike a primitive setInterval(), this API pauses when the user switches browser tabs, saving processing power and preserving hardware battery lifecycle.</p><p>Let’s complete our script.js architecture by building the animation loop and writing the exact math needed to eliminate the notorious 1-pixel rendering seam gap.</p><h3>⚙️ Step 3: Complete JavaScript Engine Blueprint</h3><p>Replace your execution phase in script.js or append this code block directly below the asset management section:</p><pre>function initEngine() {<br>    // Initiate the recursive loop<br>    gameLoop();<br>}<br><br>function gameLoop() {<br>    // Step 1: Clear the canvas viewport to prevent frame bleeding<br>    ctx.clearRect(0, 0, canvas.width, canvas.height);<br><br>    // Step 2: Render the background state<br>    drawBackground();<br><br>    // Step 3: Update positions for the next frame<br>    updateBackgroundPhysics();<br><br>    // Step 4: Synchronize with browser refresh rate (60fps/120fps)<br>    requestAnimationFrame(gameLoop);<br>}<br><br>function drawBackground() {<br>    // Draw Primary Image Instance<br>    ctx.drawImage(<br>        backgroundImage, <br>        background.x1, <br>        background.y, <br>        background.width, <br>        background.height<br>    );<br><br>    // Draw Secondary Image Instance immediately adjacent to it<br>    ctx.drawImage(<br>        backgroundImage, <br>        background.x2, <br>        background.y, <br>        background.width, <br>        background.height<br>    );<br>}<br><br>function updateBackgroundPhysics() {<br>    // Move both layout instances to the left based on custom game speed<br>    background.x1 -= GAME_SPEED;<br>    background.x2 -= GAME_SPEED;<br><br>    // CRITICAL MATH: The Seamless Reset Rule<br>    // If the primary image completely exits the left viewport boundary...<br>    if (background.x1 &lt;= -background.width) {<br>        // Do NOT set it to 0 or background.width statically.<br>        // Anchor it directly relative to Image B&#39;s active position to eliminate sub-pixel gaps.<br>        background.x1 = background.x2 + background.width;<br>    }<br><br>    // If the secondary image completely exits the left viewport boundary...<br>    if (background.x2 &lt;= -background.width) {<br>        // Anchor it directly relative to Image A&#39;s active position<br>        background.x2 = background.x1 + background.width;<br>    }<br>}</pre><h3>Deep Dive: The Seamless Reset Math</h3><p>Why did we write the reset logic as background.x1 = background.x2 + background.width instead of simply setting it to the canvas edge?</p><p>Modern modern browsers render 2D canvases using hardware acceleration, processing positions in floating-point decimals (e.g., x = -799.43). If your GAME_SPEED is an odd number or a dynamic variable, your image might not hit exactly -800 (the image width) on a specific frame. It might cross the border at -801.2.</p><p>If you reset it using a hardcoded absolute coordinate like background.x1 = background.width, you completely drop that extra -1.2 pixels of movement. Over a few hundred frames, these tiny sub-pixel losses accumulate, creating a distracting <strong>1-pixel flickering transparent vertical line</strong> between your tiling assets.</p><p>By anchoring x1 directly to x2 + width, the calculation remains mathematically absolute and context-aware, completely eradicating structural gaps at any frame rate.</p><h3>Conclusion: Architectural Thinking Over Frameworks</h3><p>In less than 60 lines of native JavaScript, we have engineered a production-ready, ultra-smooth infinite parallax environment wrapper. More importantly, we achieved it without hauling heavy dependencies, external physics engines, or bulky web frameworks into our runtime stack.</p><p>Understanding native browser mechanics — such as loading safety buffers via .onload, scaling canvas elements dynamically via baseline aspect ratios, and handling relative sub-pixel coordinate snapping—is what elevates an intermediate programmer into an efficient software architect.</p><h3>Next Steps for Your Game Stack:</h3><p>To push this code block even further, try experimenting with <strong>Vertical Parallax Layering</strong>. You can create three distinct background instances running at varied speeds (GAME_SPEED * 0.2 for distant clouds, GAME_SPEED * 0.5 for far-off mountains, and GAME_SPEED for immediate ground structures). This creates a stunning 3D depth perception right inside a flat 2D viewport.</p><p>Drop your live GitHub Pages link in the comments section below and show off your implementation!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=87350c794f71" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“I Built a Flappy Bird Clone in 100 Lines of Vanilla JavaScript (And What It Taught Me About…]]></title>
            <link>https://medium.com/@avinashmurmu664/i-built-a-flappy-bird-clone-in-100-lines-of-vanilla-javascript-and-what-it-taught-me-about-6f8fbf63aaab?source=rss-1a9397833c26------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f8fbf63aaab</guid>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Aourex]]></dc:creator>
            <pubDate>Sun, 24 May 2026 10:12:08 GMT</pubDate>
            <atom:updated>2026-05-24T10:12:08.316Z</atom:updated>
            <content:encoded><![CDATA[<h3>“I Built a Flappy Bird Clone in 100 Lines of Vanilla JavaScript (And What It Taught Me About Physics Engines)”</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*AogwW6tBkRhlRyWbDple5A.png" /></figure><p><strong>Part 1 — Introduction &amp; Setup</strong></p><p><strong>Stop Making To-Do Lists. Build a Game Instead.</strong></p><p>Every beginner programmer gets trapped in “tutorial hell.” You build a counter, a generic calculator, or a To-Do list app. Honestly? It’s boring. It doesn’t teach you how logic actually flows in a dynamic environment.</p><p>I wanted to learn how frames render, how collision logic works, and how to simulate gravity without relying on heavy game engines like Unity or Unreal. So, I challenged myself: <strong>Can I build a fully functional Flappy Bird clone in under 100 lines of pure Vanilla JavaScript?</strong></p><p>Spoiler alert: Yes, you can. And it’s the best way to master the HTML5 Canvas API. Here is the exact step-by-step breakdown of how I did it.</p><h3>The Canvas Setup (The Digital Playground)</h3><p>Before diving into physics and gravity, we need a canvas to draw our game. Instead of overcomplicating the HTML and CSS, we keep it bare-minimum.</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot;&gt;<br>    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;<br>    &lt;title&gt;Vanilla JS Flappy Bird&lt;/title&gt;<br>    &lt;style&gt;<br>        body {<br>            margin: 0;<br>            background: #202124;<br>            display: flex;<br>            justify-content: center;<br>            align-items: center;<br>            height: 100vh;<br>        }<br>        canvas {<br>            border: 2px solid #fff;<br>            background: #70c5ce; /* Flappy Bird Sky Blue */<br>        }<br>    &lt;/style&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>    &lt;canvas id=&quot;gameCanvas&quot; width=&quot;320&quot; height=&quot;480&quot;&gt;&lt;/canvas&gt;<br>    &lt;script src=&quot;game.js&quot;&gt;&lt;/script&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><h3>Part 2 — Simulating Gravity &amp; The Game Loop</h3><h3>Making It Move: The Game Loop &amp; Gravity</h3><p>A video game is just a series of pictures moving really fast. To achieve this in JavaScript, we need a <strong>Game Loop</strong>. This loop constantly clears the screen, updates positions (like the bird falling), and draws them back onto the canvas.</p><p>We use requestAnimationFrame() because it syncs with the browser&#39;s refresh rate, making the animation butter-smooth.</p><p>Create a file named game.js and let&#39;s define our bird and its physics:</p><pre>const canvas = document.getElementById(&quot;gameCanvas&quot;);<br>const ctx = canvas.getContext(&quot;2d&quot;);<br><br>// The Bird Object<br>const bird = {<br>    x: 50,<br>    y: 150,<br>    width: 20,<br>    height: 20,<br>    gravity: 0.6,<br>    velocity: 0,<br>    lift: -10, // How high it jumps<br><br>    draw() {<br>        ctx.fillStyle = &quot;#f4b400&quot;; // Classic Flappy Yellow<br>        ctx.fillRect(this.x, this.y, this.width, this.height);<br>    },<br><br>    update() {<br>        this.velocity += this.gravity; // Gravity constantly pulls down<br>        this.y += this.velocity;<br><br>        // Prevent falling through the floor<br>        if (this.y + this.height &gt; canvas.height) {<br>            this.y = canvas.height - this.height;<br>            this.velocity = 0;<br>        }<br>    },<br><br>    flap() {<br>        this.velocity = this.lift; // Defy gravity!<br>    }<br>};<br><br>// Event Listener for Controls<br>window.addEventListener(&quot;keydown&quot;, (e) =&gt; {<br>    if (e.code === &quot;Space&quot;) bird.flap();<br>});<br><br>// The Core Game Loop<br>function gameLoop() {<br>    ctx.clearRect(0, 0, canvas.width, canvas.height); // Clear screen<br><br>    bird.update();<br>    bird.draw();<br><br>    requestAnimationFrame(gameLoop); // Call next frame<br>}<br><br>// Start the game<br>gameLoop();</pre><h3>Breaking Down the Physics</h3><p>If you just increment y by a fixed number (like y += 2), the bird will move down at a constant speed. That’s not how the real world works. Real objects <strong>accelerate</strong> when they fall.</p><p>That’s where velocity comes into play:</p><ol><li>Every single frame, gravity (0.6) is added to velocity.</li><li>Then, velocity is added to the bird’s y position.</li><li>When you press the <strong>Spacebar</strong>, we instantly set the velocity to a negative number (lift: -10). This cancels out the downward speed and shoots the bird upward.</li></ol><p><strong><em>Medium Author Note:</em></strong><em> Notice how easily you can build a physics simulation in just 5 lines of code? No external libraries required.</em></p><h3>Part 3 — Spawning Obstacles &amp; Collision Detection</h3><h3>Introducing the Obstacles: Generating Moving Pipes</h3><p>A Flappy Bird game is nothing without its frustrating green pipes. To make this work, we need an array to hold multiple pipes, as they are constantly generated on the right side of the screen and move toward the left.</p><p>Let’s add the pipe logic right above our gameLoop function in game.js:</p><pre>const pipes = [];<br>const pipeWidth = 40;<br>const pipeGap = 100; // Space between top and bottom pipe<br>let frameCounter = 0;<br><br>function spawnPipe() {<br>    // Random height for the top pipe<br>    const topHeight = Math.floor(Math.random() * (canvas.height / 2)) + 50;<br>    const bottomHeight = canvas.height - topHeight - pipeGap;<br><br>    pipes.push({<br>        x: canvas.width,<br>        top: topHeight,<br>        bottom: bottomHeight,<br>        passed: false<br>    });<br>}<br><br>function updatePipes() {<br>    frameCounter++;<br>    <br>    // Spawn a new pipe every 100 frames<br>    if (frameCounter % 100 === 0) {<br>        spawnPipe();<br>    }<br><br>    for (let i = pipes.length - 1; i &gt;= 0; i--) {<br>        pipes[i].x -= 2; // Move pipes to the left<br><br>        // Collision Check (We will write this function next)<br>        if (checkCollision(bird, pipes[i])) {<br>            resetGame();<br>        }<br><br>        // Remove pipes that move off-screen to save memory<br>        if (pipes[i].x + pipeWidth &lt; 0) {<br>            pipes.splice(i, 1);<br>        }<br>    }<br>}</pre><h3>The Math Behind Collision Detection (Axis-Aligned Bounding Box)</h3><p>How do we know if a square bird hit a rectangular pipe? We use a foundational concept in 2D game development called <strong>AABB (Axis-Aligned Bounding Box) Collision Detection</strong>.</p><p>In simple terms: if the bird’s edges overlap with any of the pipe’s edges, it’s game over.</p><p>Here is the exact function to calculate that:</p><pre>function checkCollision(bird, pipe) {<br>    // Check Top Pipe Collision<br>    const hitTop = bird.x &lt; pipe.x + pipeWidth &amp;&amp;<br>                   bird.x + bird.width &gt; pipe.x &amp;&amp;<br>                   bird.y &lt; pipe.top;<br><br>    // Check Bottom Pipe Collision<br>    const hitBottom = bird.x &lt; pipe.x + pipeWidth &amp;&amp;<br>                      bird.x + bird.width &gt; pipe.x &amp;&amp;<br>                      bird.y + bird.height &gt; canvas.height - pipe.bottom;<br><br>    // Ceiling boundary check<br>    const hitCeiling = bird.y &lt; 0;<br><br>    return hitTop || hitBottom || hitCeiling;<br>}<br><br>function resetGame() {<br>    bird.y = 150;<br>    bird.velocity = 0;<br>    pipes.length = 0; // Clear all pipes<br>    frameCounter = 0;<br>}</pre><p>Now, just update your gameLoop() to include updatePipes() and draw them:</p><pre>function gameLoop() {<br>    ctx.clearRect(0, 0, canvas.width, canvas.height);<br><br>    bird.update();<br>    bird.draw();<br><br>    updatePipes();<br>    // Draw Pipes<br>    ctx.fillStyle = &quot;#0f9d58&quot;; // Classic Android/Google Green<br>    pipes.forEach(pipe =&gt; {<br>        // Draw top pipe<br>        ctx.fillRect(pipe.x, 0, pipeWidth, pipe.top);<br>        // Draw bottom pipe<br>        ctx.fillRect(pipe.x, canvas.height - pipe.bottom, pipeWidth, pipe.bottom);<br>    });<br><br>    requestAnimationFrame(gameLoop);<br>}</pre><p><strong>What This Teaches You About Memory Management:</strong> Notice the pipes.splice(i, 1) line? If we don&#39;t remove pipes that leave the screen, the array will keep growing infinitely. Over time, this causes a severe <strong>memory leak</strong>, making the game lag. Checking for this is what separates hobbyist coders from software engineers.</p><h3>Part 4 — Score Tracking &amp; The Wrap-Up</h3><h3>Keeping Score: Rewarding the Player</h3><p>A game isn’t fun if you can’t brag about your high score. To add score tracking, we just need a simple integer variable and a mechanism to check if the bird successfully crossed a pipe without colliding.</p><p>Let’s add a score variable at the top of game.js and update it inside our pipe loop:</p><pre>let score = 0;<br><br>function updatePipes() {<br>    frameCounter++;<br>    if (frameCounter % 100 === 0) spawnPipe();<br><br>    for (let i = pipes.length - 1; i &gt;= 0; i--) {<br>        pipes[i].x -= 2;<br><br>        if (checkCollision(bird, pipes[i])) {<br>            resetGame();<br>        }<br><br>        // Check if bird passed the pipe<br>        if (!pipes[i].passed &amp;&amp; pipes[i].x + pipeWidth &lt; bird.x) {<br>            score++;<br>            pipes[i].passed = true; // Mark as passed so we don&#39;t count it again<br>        }<br><br>        if (pipes[i].x + pipeWidth &lt; 0) {<br>            pipes.splice(i, 1);<br>        }<br>    }<br>}</pre><p>Now, let’s render the score on top of everything inside the gameLoop() function using canvas text methods:</p><pre>// Add this inside gameLoop() right after drawing the pipes<br>ctx.fillStyle = &quot;#ffffff&quot;;<br>ctx.font = &quot;24px &#39;Courier New&#39;, Courier, monospace&quot;;<br>ctx.fillText(`Score: ${score}`, 20, 40);</pre><p>And update your resetGame() function to reset the score back to zero when the player crashes:</p><pre>function resetGame() {<br>    bird.y = 150;<br>    bird.velocity = 0;<br>    pipes.length = 0;<br>    frameCounter = 0;<br>    score = 0; // Reset score<br>}</pre><h3>What to do next?</h3><p>If you want to stretch your muscles, try modifying this base code to add:</p><ul><li>A “High Score” system using localStorage.</li><li>A smooth rotation effect where the bird tilts down when falling.</li></ul><p>The best part? You can drop this code into a repository and host it instantly on <strong>GitHub Pages</strong> for free, giving you a live game link to show off in your portfolio.</p><p><em>What simple feature would you add to this to make it even more challenging? Let me know in the comments!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f8fbf63aaab" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>