<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Shivam Gupta</title>
    <description>The latest articles on DEV Community by Shivam Gupta (@shivamgpt).</description>
    <link>https://dev.to/shivamgpt</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3284238%2F0df4fc83-a842-4cd6-9fab-70ebc9b329d9.jpeg</url>
      <title>DEV Community: Shivam Gupta</title>
      <link>https://dev.to/shivamgpt</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shivamgpt"/>
    <language>en</language>
    <item>
      <title>🚀 Building “Space Ball” – My First AI-Generated Game with Amazon Q CLI</title>
      <dc:creator>Shivam Gupta</dc:creator>
      <pubDate>Sun, 22 Jun 2025 09:10:20 +0000</pubDate>
      <link>https://dev.to/shivamgpt/building-space-ball-my-first-ai-generated-game-with-amazon-q-cli-1ncp</link>
      <guid>https://dev.to/shivamgpt/building-space-ball-my-first-ai-generated-game-with-amazon-q-cli-1ncp</guid>
      <description>&lt;h3&gt;
  
  
  🎥 Here's a short clip showing the game in action:
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://youtu.be/EzLUSZKgJSY?si=zSQ0kHgJYmTNk1pl" rel="noopener noreferrer"&gt;Youtube Video&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  🎮 The Idea
&lt;/h3&gt;

&lt;p&gt;As someone curious about game development but not a full-time game dev, I wanted to build something fun and interactive—quickly. When I saw the &lt;a href="https://community.aws/content/2xIoduO0xhkhUApQpVUIqBFGmAc/build-games-with-amazon-q-cli-and-score-a-t-shirt" rel="noopener noreferrer"&gt;Amazon Q Game Jam Challenge&lt;/a&gt;, I thought: &lt;em&gt;Why not try building a simple space-themed ball game using Amazon Q CLI?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The concept was straightforward:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“A bouncing space ball that avoids obstacles or collects stars, with arrow keys for control and a scoring mechanism.”&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  🧠 Tools Used
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Amazon Q CLI&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Amazon Q Chat (in VS Code)&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;p5.js&lt;/strong&gt; for graphics and game logic&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;VS Code&lt;/strong&gt; for development&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GitHub&lt;/strong&gt; for version control and sharing&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Screen recording tools &amp;amp; screenshots&lt;/strong&gt; to capture the process&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  ⚙️ Step-by-Step: How I Built It
&lt;/h3&gt;

&lt;h4&gt;
  
  
  1. 🔧 Project Initialization
&lt;/h4&gt;

&lt;p&gt;I started by creating a new project using the Q CLI:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;q init space-ball-game
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I chose:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Language&lt;/strong&gt;: JavaScript&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Framework&lt;/strong&gt;: p5.js (great for quick 2D games)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This scaffolded a complete p5.js game project with basic structure in place.&lt;/p&gt;




&lt;h4&gt;
  
  
  2. 🧠 AI-Powered Development with Amazon Q Chat
&lt;/h4&gt;

&lt;p&gt;I opened &lt;strong&gt;Amazon Q Chat&lt;/strong&gt; in VS Code and gave it this prompt:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Create a simple 2D space ball game using p5.js where a ball bounces and avoids obstacles in space. Add scoring when player survives longer. Use arrow keys for control.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In seconds, it generated working code for a ball that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Bounces around the canvas&lt;/li&gt;
&lt;li&gt;Responds to arrow key movement&lt;/li&gt;
&lt;li&gt;Increments score over time&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then I asked follow-ups like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;“Add space background with stars”&lt;/li&gt;
&lt;li&gt;“Show score on the top-left”&lt;/li&gt;
&lt;li&gt;“Add a game over screen if the ball touches the edge”&lt;/li&gt;
&lt;li&gt;“Make it gradually harder”&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each prompt improved the game significantly. It felt like collaborating with a game dev buddy who worked at lightning speed.&lt;/p&gt;






&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;title&amp;gt;Space Ball Game&amp;lt;/title&amp;gt;
    &amp;lt;script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.7.0/p5.min.js"&amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;style&amp;gt;
        body {
            margin: 0;
            padding: 20px;
            background: #000;
            color: white;
            font-family: Arial, sans-serif;
            display: flex;
            flex-direction: column;
            align-items: center;
        }
        #gameContainer {
            border: 2px solid #333;
        }
        .instructions {
            margin-top: 10px;
            text-align: center;
        }
    &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;div id="gameContainer"&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;div class="instructions"&amp;gt;
        &amp;lt;p&amp;gt;Use arrow keys to control the ball • Avoid red obstacles • Survive as long as possible!&amp;lt;/p&amp;gt;
        &amp;lt;p&amp;gt;Press SPACE to restart when game over&amp;lt;/p&amp;gt;
    &amp;lt;/div&amp;gt;

    &amp;lt;script&amp;gt;
        let ball;
        let obstacles = [];
        let stars = [];
        let score = 0;
        let gameOver = false;
        let gameStartTime;

        function setup() {
            let canvas = createCanvas(800, 600);
            canvas.parent('gameContainer');

            // Initialize ball
            ball = {
                x: width / 2,
                y: height / 2,
                vx: 0,
                vy: 0,
                radius: 15,
                maxSpeed: 8,
                acceleration: 0.3
            };

            // Create background stars
            for (let i = 0; i &amp;lt; 100; i++) {
                stars.push({
                    x: random(width),
                    y: random(height),
                    size: random(1, 3),
                    brightness: random(100, 255)
                });
            }

            gameStartTime = millis();
        }

        function draw() {
            // Space background
            background(5, 5, 20);

            // Draw stars
            drawStars();

            if (!gameOver) {
                // Update game state
                updateBall();
                updateObstacles();
                checkCollisions();

                // Update score based on survival time
                score = Math.floor((millis() - gameStartTime) / 100);

                // Spawn obstacles periodically
                if (frameCount % 60 === 0) {
                    spawnObstacle();
                }
            }

            // Draw game objects
            drawBall();
            drawObstacles();
            drawUI();

            if (gameOver) {
                drawGameOver();
            }
        }

        function drawStars() {
            noStroke();
            for (let star of stars) {
                fill(255, star.brightness);
                ellipse(star.x, star.y, star.size);

                // Twinkling effect
                star.brightness += random(-10, 10);
                star.brightness = constrain(star.brightness, 50, 255);
            }
        }

        function updateBall() {
            // Handle input
            if (keyIsDown(LEFT_ARROW)) {
                ball.vx -= ball.acceleration;
            }
            if (keyIsDown(RIGHT_ARROW)) {
                ball.vx += ball.acceleration;
            }
            if (keyIsDown(UP_ARROW)) {
                ball.vy -= ball.acceleration;
            }
            if (keyIsDown(DOWN_ARROW)) {
                ball.vy += ball.acceleration;
            }

            // Limit speed
            ball.vx = constrain(ball.vx, -ball.maxSpeed, ball.maxSpeed);
            ball.vy = constrain(ball.vy, -ball.maxSpeed, ball.maxSpeed);

            // Apply friction
            ball.vx *= 0.98;
            ball.vy *= 0.98;

            // Update position
            ball.x += ball.vx;
            ball.y += ball.vy;

            // Bounce off walls
            if (ball.x - ball.radius &amp;lt;= 0 || ball.x + ball.radius &amp;gt;= width) {
                ball.vx *= -0.8;
                ball.x = constrain(ball.x, ball.radius, width - ball.radius);
            }
            if (ball.y - ball.radius &amp;lt;= 0 || ball.y + ball.radius &amp;gt;= height) {
                ball.vy *= -0.8;
                ball.y = constrain(ball.y, ball.radius, height - ball.radius);
            }
        }

        function drawBall() {
            push();
            translate(ball.x, ball.y);

            // Ball glow effect
            for (let i = 3; i &amp;gt; 0; i--) {
                fill(100, 150, 255, 50 / i);
                noStroke();
                ellipse(0, 0, ball.radius * 2 * i);
            }

            // Main ball
            fill(150, 200, 255);
            stroke(200, 230, 255);
            strokeWeight(2);
            ellipse(0, 0, ball.radius * 2);

            // Ball highlight
            fill(255, 255, 255, 150);
            noStroke();
            ellipse(-ball.radius * 0.3, -ball.radius * 0.3, ball.radius * 0.6);

            pop();
        }

        function spawnObstacle() {
            let obstacle = {
                x: random(width),
                y: -50,
                vx: random(-2, 2),
                vy: random(2, 5),
                radius: random(20, 40),
                rotation: 0,
                rotationSpeed: random(-0.1, 0.1)
            };
            obstacles.push(obstacle);
        }

        function updateObstacles() {
            for (let i = obstacles.length - 1; i &amp;gt;= 0; i--) {
                let obs = obstacles[i];

                obs.x += obs.vx;
                obs.y += obs.vy;
                obs.rotation += obs.rotationSpeed;

                // Remove obstacles that are off screen
                if (obs.y &amp;gt; height + 100) {
                    obstacles.splice(i, 1);
                }

                // Bounce off side walls
                if (obs.x - obs.radius &amp;lt;= 0 || obs.x + obs.radius &amp;gt;= width) {
                    obs.vx *= -1;
                    obs.x = constrain(obs.x, obs.radius, width - obs.radius);
                }
            }
        }

        function drawObstacles() {
            for (let obs of obstacles) {
                push();
                translate(obs.x, obs.y);
                rotate(obs.rotation);

                // Obstacle glow
                for (let i = 3; i &amp;gt; 0; i--) {
                    fill(255, 50, 50, 30 / i);
                    noStroke();
                    ellipse(0, 0, obs.radius * 2 * i);
                }

                // Main obstacle
                fill(255, 80, 80);
                stroke(255, 120, 120);
                strokeWeight(2);

                // Draw as angular asteroid-like shape
                beginShape();
                for (let angle = 0; angle &amp;lt; TWO_PI; angle += PI / 6) {
                    let r = obs.radius + sin(angle * 3) * 5;
                    let x = cos(angle) * r;
                    let y = sin(angle) * r;
                    vertex(x, y);
                }
                endShape(CLOSE);

                pop();
            }
        }

        function checkCollisions() {
            for (let obs of obstacles) {
                let distance = dist(ball.x, ball.y, obs.x, obs.y);
                if (distance &amp;lt; ball.radius + obs.radius) {
                    gameOver = true;
                    break;
                }
            }
        }

        function drawUI() {
            // Score
            fill(255);
            textAlign(LEFT);
            textSize(24);
            text(`Score: ${score}`, 20, 40);

            // Speed indicator
            let speed = sqrt(ball.vx * ball.vx + ball.vy * ball.vy);
            fill(100, 255, 100);
            textSize(16);
            text(`Speed: ${speed.toFixed(1)}`, 20, 70);

            // Obstacle count
            fill(255, 100, 100);
            text(`Obstacles: ${obstacles.length}`, 20, 95);
        }

        function drawGameOver() {
            // Semi-transparent overlay
            fill(0, 0, 0, 150);
            rect(0, 0, width, height);

            // Game over text
            fill(255, 100, 100);
            textAlign(CENTER);
            textSize(48);
            text("GAME OVER", width / 2, height / 2 - 50);

            fill(255);
            textSize(24);
            text(`Final Score: ${score}`, width / 2, height / 2);

            textSize(18);
            text("Press SPACE to restart", width / 2, height / 2 + 40);
        }

        function keyPressed() {
            if (key === ' ' &amp;amp;&amp;amp; gameOver) {
                // Restart game
                gameOver = false;
                obstacles = [];
                score = 0;
                gameStartTime = millis();

                // Reset ball
                ball.x = width / 2;
                ball.y = height / 2;
                ball.vx = 0;
                ball.vy = 0;
            }
        }
    &amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  3. 🧪 Testing and Running
&lt;/h4&gt;

&lt;p&gt;I used:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;q run
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;...and the game loaded perfectly in the browser. I recorded a short video and took screenshots to document the gameplay.&lt;/p&gt;




&lt;h3&gt;
  
  
  🎥 Experience Video &amp;amp; Screenshots
&lt;/h3&gt;

&lt;p&gt;Here's a short clip showing the game in action:&lt;br&gt;
&lt;a href="https://youtu.be/EzLUSZKgJSY?si=zSQ0kHgJYmTNk1pl" rel="noopener noreferrer"&gt;Youtube Video&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And some screenshots:&lt;/p&gt;

&lt;p&gt;📸 &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcs31hbedth1v7d9uf9w6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcs31hbedth1v7d9uf9w6.png" alt="Screenshot 1" width="800" height="426"&gt;&lt;/a&gt;&lt;br&gt;
📸 &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F94nno0rmr9tkfywvefe1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F94nno0rmr9tkfywvefe1.png" alt="Screenshot 2" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  🧵 What I Learned
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Q CLI + Q Chat is a powerful combo.&lt;/strong&gt; I didn’t write a single line of game logic manually.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;p5.js is fantastic&lt;/strong&gt; for small 2D games and works well with Q.&lt;/li&gt;
&lt;li&gt;The iterative prompt-based flow lets you build, test, improve quickly.&lt;/li&gt;
&lt;li&gt;Building a game is no longer “hard” when you have the right tools and guidance.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  💡 Tips If You Want to Try
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Start with a simple idea.&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;clear and direct prompts&lt;/strong&gt; in Q Chat.&lt;/li&gt;
&lt;li&gt;Ask for improvements iteratively.&lt;/li&gt;
&lt;li&gt;Take screenshots and short videos as you go (makes writing blogs easy 😉).&lt;/li&gt;
&lt;li&gt;Don’t be afraid to experiment. You can always undo or regenerate!&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  🙌 Final Words
&lt;/h3&gt;

&lt;p&gt;This was my first time building a game with the help of AI. And it was surprisingly smooth and rewarding.&lt;/p&gt;

&lt;p&gt;Whether you're a student, hobbyist, or even a non-coder—&lt;strong&gt;Amazon Q can help you bring your game idea to life in hours&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Give it a try, build your game, and maybe win that T-shirt too!&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Thanks for reading! Feel free to connect or ask if you want help getting started with your own game.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>vscode</category>
      <category>aws</category>
      <category>amazonqcli</category>
    </item>
  </channel>
</rss>
