<?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>Forem: Antrixsh Gupta</title>
    <description>The latest articles on Forem by Antrixsh Gupta (@antrixsh_gupta).</description>
    <link>https://forem.com/antrixsh_gupta</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%2F3294069%2Fd5b53b4a-b8e9-4c6f-817d-ebfaba10e171.png</url>
      <title>Forem: Antrixsh Gupta</title>
      <link>https://forem.com/antrixsh_gupta</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/antrixsh_gupta"/>
    <language>en</language>
    <item>
      <title>🎮 Building TETRIS with Amazon Q Developer CLI</title>
      <dc:creator>Antrixsh Gupta</dc:creator>
      <pubDate>Wed, 25 Jun 2025 14:45:39 +0000</pubDate>
      <link>https://forem.com/antrixsh_gupta/building-tetris-with-amazon-q-developer-cli-hae</link>
      <guid>https://forem.com/antrixsh_gupta/building-tetris-with-amazon-q-developer-cli-hae</guid>
      <description>&lt;p&gt;&lt;strong&gt;Reimagining a Retro Classic with the Power of Conversational AI&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"What if creating a classic game didn’t require lines of manual code, but just smart prompts?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For the AWS Build Games Challenge, I set out to recreate one of the most iconic games in history—TETRIS—using the Amazon Q Developer CLI. What started as an experiment turned into a full-blown retro revival, powered entirely by conversational coding.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🎮 Why TETRIS?&lt;/strong&gt;&lt;br&gt;
Tetris is timeless. It's a game with simple rules, addictive mechanics, and infinite replayability. More importantly, it’s a perfect fit for AI-assisted development: it has clear game logic, visual feedback, and challenging mechanics like collision detection, rotation logic, and grid updates.&lt;/p&gt;

&lt;p&gt;🤖 &lt;strong&gt;Effective Prompting Techniques I Discovered&lt;/strong&gt;&lt;br&gt;
Here are a few prompt patterns that worked like magic:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;“Create a Tetris board with a 2D array and grid snapping logic.”&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;This led to a clean grid-based layout with collision-aware placement.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;“Generate rotation logic for tetrominoes with wall kick handling.”&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Amazon Q handled edge collision logic like a seasoned dev.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;“Add a scoring system that gives 100 points per line cleared.”&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Straightforward and accurate—no refactor needed!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;“Build controls for left, right, soft drop, and rotation using keyboard input.”&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Integrated seamlessly with pygame for smooth gameplay.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;🧠 &lt;strong&gt;How Amazon Q Handled Classic Programming Challenges&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;🧠 Classic Challenge&lt;/th&gt;
&lt;th&gt;🛠️ Prompt or Request&lt;/th&gt;
&lt;th&gt;🤖 Amazon Q's Response Summary&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Piece Rotation&lt;/td&gt;
&lt;td&gt;"Generate rotation logic for tetrominoes with wall kick handling."&lt;/td&gt;
&lt;td&gt;Used matrix transpose + reverse method.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Line Detection&lt;/td&gt;
&lt;td&gt;"Detect and clear full lines on the board."&lt;/td&gt;
&lt;td&gt;Loop checking for full rows with a clean overwrite logic.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Game Over Logic&lt;/td&gt;
&lt;td&gt;"End game when new piece collides at spawn location."&lt;/td&gt;
&lt;td&gt;Implemented top-row check and graceful game end.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Grid Drawing&lt;/td&gt;
&lt;td&gt;"Draw grid and update display for each frame using pygame."&lt;/td&gt;
&lt;td&gt;Automated drawing using &lt;code&gt;pygame.draw.rect&lt;/code&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Score Updates&lt;/td&gt;
&lt;td&gt;"Show score on screen and update per line cleared."&lt;/td&gt;
&lt;td&gt;Added dynamic score overlay rendered live on screen.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;⚙️ Dev Automation That Saved Me Hours&lt;/strong&gt;&lt;br&gt;
Instead of spending hours on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Manual debugging of piece collisions&lt;/li&gt;
&lt;li&gt;Writing the draw-loop boilerplate&lt;/li&gt;
&lt;li&gt;Creating a scoring overlay&lt;/li&gt;
&lt;li&gt;Managing piece spawning logic&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;…I used smart prompting like:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Detect when the current piece cannot move down and freeze it in place.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And Q instantly gave me the code + comments to integrate it directly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🧩 Interesting Code Examples&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;1. Tetromino Definitions&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// 7 classic pieces in matrix form
const PIECES = [
  [[1,1,1,1]],                // I
  [[1,1],[1,1]],              // O
  [[0,1,0],[1,1,1]],          // T
  [[0,1,1],[1,1,0]],          // S
  [[1,1,0],[0,1,1]],          // Z
  [[1,0,0],[1,1,1]],          // J
  [[0,0,1],[1,1,1]]           // L
];

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

&lt;/div&gt;



&lt;p&gt;Why it matters: keeping shapes as 1/0 matrices lets every other function stay generic.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;One-Liner Rotation
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function rotatePiece(piece) {
  // Transpose + reverse rows →  90° clockwise
  return piece[0].map((_, i) =&amp;gt; piece.map(row =&amp;gt; row[i]).reverse());
}

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

&lt;/div&gt;



&lt;p&gt;AI insight: Q generated the transpose-reverse trick, which avoids nested loops.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Move Validation Helper
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function isValidMove(piece, dx, dy, shape = piece.shape) {
  for (let y = 0; y &amp;lt; shape.length; y++) {
    for (let x = 0; x &amp;lt; shape[y].length; x++) {
      if (!shape[y][x]) continue;
      const nx = piece.x + x + dx;
      const ny = piece.y + y + dy;
      if (
        nx &amp;lt; 0 || nx &amp;gt;= COLS || ny &amp;gt;= ROWS ||
        (ny &amp;gt;= 0 &amp;amp;&amp;amp; board[ny][nx])
      ) return false;
    }
  }
  return true;
}

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

&lt;/div&gt;



&lt;p&gt;Why it’s neat: a single routine handles wall bounds, floor contact, and collisions.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Line Clearing &amp;amp; Scoring
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// inside placePiece()
for (let y = ROWS - 1; y &amp;gt;= 0; y--) {
  if (board[y].every(cell =&amp;gt; cell !== 0)) {
    board.splice(y, 1);                    // remove filled row
    board.unshift(Array(COLS).fill(0));    // add empty row on top
    score += 100;
    y++;                                   // re-check same index
  }
}
scoreElement.textContent = score;

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

&lt;/div&gt;



&lt;p&gt;Why it’s efficient: splice + unshift swaps rows without rebuilding the whole grid.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Main Game Loop
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function gameLoop() {
  if (isValidMove(currentPiece, 0, 1)) {
    currentPiece.y++;          // move down
  } else {
    placePiece();              // freeze &amp;amp; spawn new
  }
  draw();                      // render frame
}

setInterval(gameLoop, 500);     // 2 frames per second

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

&lt;/div&gt;



&lt;p&gt;A minimalist loop: gravity, collision handling, and rendering—all in ~10 lines.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🔗 Check the Complete Code&lt;/strong&gt;&lt;br&gt;
Explore the full Tetris game source code on my &lt;a href="https://github.com/antrixsh/AmazonQ-tetris" rel="noopener noreferrer"&gt;GitHub repository&lt;/a&gt; – clean, modular, and AI-assisted from start to finish!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🖼️ Screenshots of the Final Creation&lt;/strong&gt;&lt;br&gt;
Here’s how the final game looks in action:&lt;/p&gt;

&lt;p&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%2Fb39u53nmeuykkf9wk0cd.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%2Fb39u53nmeuykkf9wk0cd.png" alt="Image description" width="800" height="1200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Final Thoughts&lt;/strong&gt;&lt;br&gt;
Using Amazon Q Developer CLI to build Tetris has been both nostalgic and futuristic. It proved that AI can be a true coding partner—handling everything from low-level math to game loop architecture. I never imagined I could build something playable so quickly without writing every line of logic manually.&lt;/p&gt;

&lt;p&gt;If you're a developer—even one with minimal game dev experience—I highly recommend giving this challenge a try. You’ll be surprised at how quickly creativity flows when AI does the heavy lifting.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔗 Follow Me
&lt;/h2&gt;

&lt;p&gt;If you liked this project, feel free to connect:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;💼 &lt;a href="https://www.linkedin.com/in/antrixshgupta/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;🐙 &lt;a href="https://github.com/antrixsh" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;📝 &lt;a href="https://dev.to/antrixsh_gupta"&gt;Dev.to&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thanks for reading!&lt;/p&gt;

</description>
      <category>awschallenge</category>
      <category>aws</category>
      <category>gamechallenge</category>
      <category>amazonqdevcli</category>
    </item>
  </channel>
</rss>
