はじめに
Amazon Q Developer CLI がとても進化しているという情報を聞いたので、テトリスを作れるかを試してみました。
やってみた
まずは Amazon Q Developer を起動します。
% q chat
Hi, I'm Amazon Q. Ask me anything.
Things to try
• Fix the build failures in this project.
• List my s3 buckets in us-west-2.
• Write unit tests for my application.
• Help me understand my git status
/acceptall Toggles acceptance prompting for the session.
/profile (Beta) Manage profiles for the chat session
/context (Beta) Manage context files for a profile
/help Show the help dialogue
/quit Quit the application
>
次にテトリスを作るように命じます。
> nodejsを使ってテトリスのWEBサービスを作ってください。テトリスに備わっている基本的な機能は全て実装してください。
テトリスのWebサービスを作成しましょう。Node.jsを使って基本的な機能を全て実装します。
まず、プロジェクトの構造を作成し、必要なファイルを作成していきます。
ディレクトリの作成確認を求められたので「y」を入力します。
Execute shell command
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I will run the following shell command:
mkdir -p public/js public/css
Enter y to run this tool, otherwise continue chatting.
> y
Executing `mkdir -p public/js public/css`...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
🟢 Completed in 0.32s
package.jsonの作成確認で「y」を入力します。
### 1. まずはpackage.jsonを作成します
Write to filesystem
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Path: package.json
+ 1: {
+ 2: "name": "tetris-web-service",
+ 3: "version": "1.0.0",
+ 4: "description": "A web-based Tetris game",
+ 5: "main": "server.js",
+ 6: "scripts": {
+ 7: "start": "node server.js"
+ 8: },
+ 9: "dependencies": {
+ 10: "express": "^4.18.2"
+ 11: }
+ 12: }
Enter y to run this tool, otherwise continue chatting.
> y
Writing to filesystem...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Creating: package.json
🟢 Completed in 0.5s
server.jsの作成確認で、「y」を入力します。
Write to filesystem
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Path: server.js
+ 1: const express = require('express');
+ 2: const path = require('path');
+ 3: const app = express();
+ 4: const PORT = process.env.PORT || 3000;
+ 5:
+ 6: // 静的ファイルの提供
+ 7: app.use(express.static(path.join(__dirname, 'public')));
+ 8:
+ 9: // ルートパスへのアクセス
+ 10: app.get('/', (req, res) => {
+ 11: res.sendFile(path.join(__dirname, 'public', 'index.html'));
+ 12: });
+ 13:
+ 14: // サーバー起動
+ 15: app.listen(PORT, () => {
+ 16: console.log(`Server is running on http://localhost:${PORT}`);
+ 17: });
Enter y to run this tool, otherwise continue chatting.
> y
Writing to filesystem...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Creating: server.js
🟢 Completed in 0.2s
index.htmlの作成確認で「y」を入力します。
Write to filesystem
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Path: public/index.html
+ 1: <!DOCTYPE html>
+ 2: <html lang="ja">
+ 3: <head>
+ 4: <meta charset="UTF-8">
+ 5: <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ 6: <title>テトリス</title>
+ 7: <link rel="stylesheet" href="css/style.css">
+ 8: </head>
+ 9: <body>
+ 10: <div class="container">
+ 11: <div class="game-info">
+ 12: <div class="score-container">
+ 13: <h2>スコア: <span id="score">0</span></h2>
+ 14: <h3>レベル: <span id="level">1</span></h3>
+ 15: <h3>ライン: <span id="lines">0</span></h3>
+ 16: </div>
+ 17: <div class="next-piece-container">
+ 18: <h3>次のピース:</h3>
+ 19: <canvas id="next-piece" width="100" height="100"></canvas>
+ 20: </div>
+ 21: </div>
+ 22:
+ 23: <canvas id="tetris" width="300" height="600"></canvas>
+ 24:
+ 25: <div class="controls">
+ 26: <h3>操作方法:</h3>
+ 27: <ul>
+ 28: <li>← → : 左右移動</li>
+ 29: <li>↑ : 回転</li>
+ 30: <li>↓ : 高速落下</li>
+ 31: <li>スペース : ハードドロップ</li>
+ 32: <li>P : 一時停止</li>
+ 33: </ul>
+ 34: <button id="start-button">ゲーム開始</button>
+ 35: <button id="pause-button">一時停止</button>
+ 36: </div>
+ 37: </div>
+ 38:
+ 39: <script src="js/tetris.js"></script>
+ 40: </body>
+ 41: </html>
Enter y to run this tool, otherwise continue chatting.
> y
Writing to filesystem...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Creating: public/index.html
🟢 Completed in 0.2s
style.css の作成確認で「y」を入力します。
Write to filesystem
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Path: public/css/style.css
+ 1: * {
+ 2: margin: 0;
+ 3: padding: 0;
+ 4: box-sizing: border-box;
+ 5: }
+ 6:
+ 7: body {
+ 8: font-family: 'Arial', sans-serif;
+ 9: background-color: #f0f0f0;
+ 10: display: flex;
+ 11: justify-content: center;
+ 12: align-items: center;
+ 13: min-height: 100vh;
+ 14: }
+ 15:
+ 16: .container {
+ 17: display: flex;
+ 18: flex-wrap: wrap;
+ 19: justify-content: center;
+ 20: gap: 20px;
+ 21: max-width: 800px;
+ 22: padding: 20px;
+ 23: }
+ 24:
+ 25: canvas#tetris {
+ 26: background-color: #000;
+ 27: border: 2px solid #333;
+ 28: box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
+ 29: }
+ 30:
+ 31: canvas#next-piece {
+ 32: background-color: #000;
+ 33: border: 1px solid #333;
+ 34: }
+ 35:
+ 36: .game-info, .controls {
+ 37: width: 200px;
+ 38: }
+ 39:
+ 40: .score-container, .next-piece-container {
+ 41: background-color: #fff;
+ 42: padding: 15px;
+ 43: border-radius: 5px;
+ 44: box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
+ 45: margin-bottom: 20px;
+ 46: }
+ 47:
+ 48: h2, h3 {
+ 49: margin-bottom: 10px;
+ 50: color: #333;
+ 51: }
+ 52:
+ 53: .controls {
+ 54: background-color: #fff;
+ 55: padding: 15px;
+ 56: border-radius: 5px;
+ 57: box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
+ 58: }
+ 59:
+ 60: .controls ul {
+ 61: list-style-type: none;
+ 62: margin: 10px 0;
+ 63: }
+ 64:
+ 65: .controls li {
+ 66: margin-bottom: 5px;
+ 67: }
+ 68:
+ 69: button {
+ 70: background-color: #4CAF50;
+ 71: color: white;
+ 72: border: none;
+ 73: padding: 10px 15px;
+ 74: margin: 5px;
+ 75: border-radius: 4px;
+ 76: cursor: pointer;
+ 77: font-size: 16px;
+ 78: transition: background-color 0.3s;
+ 79: }
+ 80:
+ 81: button:hover {
+ 82: background-color: #45a049;
+ 83: }
+ 84:
+ 85: #pause-button {
+ 86: background-color: #f39c12;
+ 87: }
+ 88:
+ 89: #pause-button:hover {
+ 90: background-color: #e67e22;
+ 91: }
Enter y to run this tool, otherwise continue chatting.
> y
Writing to filesystem...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Creating: style.css
🟢 Completed in 0.2s
tetris.jsの作成確認で「y」を入力します。
Write to filesystem
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Path: public/js/tetris.js
+ 1: document.addEventListener('DOMContentLoaded', () => {
+ 2: // キャンバスの設定
+ 3: const canvas = document.getElementById('tetris');
+ 4: const ctx = canvas.getContext('2d');
+ 5: const nextPieceCanvas = document.getElementById('next-piece');
+ 6: const nextPieceCtx = nextPieceCanvas.getContext('2d');
+ 7:
+ 8: // ゲームの設定
+ 9: const COLS = 10;
+ 10: const ROWS = 20;
+ 11: const BLOCK_SIZE = 30;
+ 12: const NEXT_BLOCK_SIZE = 20;
+ 13:
+ 14: // スコア表示要素
+ 15: const scoreElement = document.getElementById('score');
+ 16: const levelElement = document.getElementById('level');
+ 17: const linesElement = document.getElementById('lines');
+ 18:
+ 19: // ボタン要素
+ 20: const startButton = document.getElementById('start-button');
+ 21: const pauseButton = document.getElementById('pause-button');
+ 22:
+ 23: // ゲームの状態
+ 24: let score = 0;
+ 25: let level = 1;
+ 26: let lines = 0;
+ 27: let gameOver = false;
+ 28: let isPaused = false;
+ 29: let dropCounter = 0;
+ 30: let dropInterval = 1000; // 初期の落下速度(ミリ秒)
+ 31: let lastTime = 0;
+ 32: let grid = createGrid();
+ 33: let currentPiece = null;
+ 34: let nextPiece = null;
+ 35:
+ 36: // テトリミノの色
+ 37: const colors = [
+ 38: null,
+ 39: '#FF0D72', // I
+ 40: '#0DC2FF', // J
+ 41: '#0DFF72', // L
+ 42: '#F538FF', // O
+ 43: '#FF8E0D', // S
+ 44: '#FFE138', // T
+ 45: '#3877FF' // Z
+ 46: ];
+ 47:
+ 48: // テトリミノの形状
+ 49: const pieces = [
+ 50: [
+ 51: [0, 0, 0, 0],
+ 52: [1, 1, 1, 1],
+ 53: [0, 0, 0, 0],
+ 54: [0, 0, 0, 0]
+ 55: ],
+ 56: [
+ 57: [2, 0, 0],
+ 58: [2, 2, 2],
+ 59: [0, 0, 0]
+ 60: ],
+ 61: [
+ 62: [0, 0, 3],
+ 63: [3, 3, 3],
+ 64: [0, 0, 0]
+ 65: ],
+ 66: [
+ 67: [4, 4],
+ 68: [4, 4]
+ 69: ],
+ 70: [
+ 71: [0, 5, 5],
+ 72: [5, 5, 0],
+ 73: [0, 0, 0]
+ 74: ],
+ 75: [
+ 76: [0, 6, 0],
+ 77: [6, 6, 6],
+ 78: [0, 0, 0]
+ 79: ],
+ 80: [
+ 81: [7, 7, 0],
+ 82: [0, 7, 7],
+ 83: [0, 0, 0]
+ 84: ]
+ 85: ];
+ 86:
+ 87: // グリッドの作成
+ 88: function createGrid() {
+ 89: return Array.from({ length: ROWS }, () => Array(COLS).fill(0));
+ 90: }
+ 91:
+ 92: // ランダムなテトリミノの生成
+ 93: function createPiece() {
+ 94: const pieceType = Math.floor(Math.random() * pieces.length);
+ 95: const piece = pieces[pieceType];
+ 96:
+ 97: return {
+ 98: position: { x: Math.floor(COLS / 2) - Math.floor(piece[0].length / 2), y: 0 },
+ 99: shape: piece,
+ 100: color: pieceType + 1
+ 101: };
+ 102: }
+ 103:
+ 104: // テトリミノの描画
+ 105: function drawPiece(ctx, piece, offsetX = 0, offsetY = 0, blockSize = BLOCK_SIZE) {
+ 106: piece.shape.forEach((row, y) => {
+ 107: row.forEach((value, x) => {
+ 108: if (value !== 0) {
+ 109: ctx.fillStyle = colors[value];
+ 110: ctx.fillRect(
+ 111: (piece.position.x + x + offsetX) * blockSize,
+ 112: (piece.position.y + y + offsetY) * blockSize,
+ 113: blockSize,
+ 114: blockSize
+ 115: );
+ 116:
+ 117: ctx.strokeStyle = '#000';
+ 118: ctx.lineWidth = 1;
+ 119: ctx.strokeRect(
+ 120: (piece.position.x + x + offsetX) * blockSize,
+ 121: (piece.position.y + y + offsetY) * blockSize,
+ 122: blockSize,
+ 123: blockSize
+ 124: );
+ 125: }
+ 126: });
+ 127: });
+ 128: }
+ 129:
+ 130: // 次のテトリミノの描画
+ 131: function drawNextPiece() {
+ 132: nextPieceCtx.clearRect(0, 0, nextPieceCanvas.width, nextPieceCanvas.height);
+ 133:
+ 134: if (!nextPiece) return;
+ 135:
+ 136: const offsetX = (5 - nextPiece.shape[0].length) / 2;
+ 137: const offsetY = (5 - nextPiece.shape.length) / 2;
+ 138:
+ 139: nextPiece.shape.forEach((row, y) => {
+ 140: row.forEach((value, x) => {
+ 141: if (value !== 0) {
+ 142: nextPieceCtx.fillStyle = colors[value];
+ 143: nextPieceCtx.fillRect(
+ 144: (x + offsetX) * NEXT_BLOCK_SIZE,
+ 145: (y + offsetY) * NEXT_BLOCK_SIZE,
+ 146: NEXT_BLOCK_SIZE,
+ 147: NEXT_BLOCK_SIZE
+ 148: );
+ 149:
+ 150: nextPieceCtx.strokeStyle = '#000';
+ 151: nextPieceCtx.lineWidth = 1;
+ 152: nextPieceCtx.strokeRect(
+ 153: (x + offsetX) * NEXT_BLOCK_SIZE,
+ 154: (y + offsetY) * NEXT_BLOCK_SIZE,
+ 155: NEXT_BLOCK_SIZE,
+ 156: NEXT_BLOCK_SIZE
+ 157: );
+ 158: }
+ 159: });
+ 160: });
+ 161: }
+ 162:
+ 163: // グリッドの描画
+ 164: function drawGrid() {
+ 165: grid.forEach((row, y) => {
+ 166: row.forEach((value, x) => {
+ 167: if (value !== 0) {
+ 168: ctx.fillStyle = colors[value];
+ 169: ctx.fillRect(x * BLOCK_SIZE, y * BLOCK_SIZE, BLOCK_SIZE, BLOCK_SIZE);
+ 170:
+ 171: ctx.strokeStyle = '#000';
+ 172: ctx.lineWidth = 1;
+ 173: ctx.strokeRect(x * BLOCK_SIZE, y * BLOCK_SIZE, BLOCK_SIZE, BLOCK_SIZE);
+ 174: }
+ 175: });
+ 176: });
+ 177: }
+ 178:
+ 179: // 画面の描画
+ 180: function draw() {
+ 181: ctx.clearRect(0, 0, canvas.width, canvas.height);
+ 182:
+ 183: drawGrid();
+ 184: if (currentPiece) {
+ 185: drawPiece(ctx, currentPiece);
+ 186: }
+ 187:
+ 188: // ゲームオーバー表示
+ 189: if (gameOver) {
+ 190: ctx.fillStyle = 'rgba(0, 0, 0, 0.75)';
+ 191: ctx.fillRect(0, 0, canvas.width, canvas.height);
+ 192:
+ 193: ctx.font = '30px Arial';
+ 194: ctx.fillStyle = 'white';
+ 195: ctx.textAlign = 'center';
+ 196: ctx.fillText('GAME OVER', canvas.width / 2, canvas.height / 2);
+ 197: ctx.font = '20px Arial';
+ 198: ctx.fillText('Press START to play again', canvas.width / 2, canvas.height / 2 + 40);
+ 199: }
+ 200:
+ 201: // 一時停止表示
+ 202: if (isPaused && !gameOver) {
+ 203: ctx.fillStyle = 'rgba(0, 0, 0, 0.5)';
+ 204: ctx.fillRect(0, 0, canvas.width, canvas.height);
+ 205:
+ 206: ctx.font = '30px Arial';
+ 207: ctx.fillStyle = 'white';
+ 208: ctx.textAlign = 'center';
+ 209: ctx.fillText('PAUSED', canvas.width / 2, canvas.height / 2);
+ 210: }
+ 211: }
+ 212:
+ 213: // 衝突判定
+ 214: function collision(piece, offsetX = 0, offsetY = 0) {
+ 215: for (let y = 0; y < piece.shape.length; y++) {
+ 216: for (let x = 0; x < piece.shape[y].length; x++) {
+ 217: if (piece.shape[y][x] !== 0) {
+ 218: const newX = piece.position.x + x + offsetX;
+ 219: const newY = piece.position.y + y + offsetY;
+ 220:
+ 221: if (
+ 222: newX < 0 ||
+ 223: newX >= COLS ||
+ 224: newY >= ROWS ||
+ 225: (newY >= 0 && grid[newY][newX] !== 0)
+ 226: ) {
+ 227: return true;
+ 228: }
+ 229: }
+ 230: }
+ 231: }
+ 232: return false;
+ 233: }
+ 234:
+ 235: // テトリミノの移動
+ 236: function movePiece(direction) {
+ 237: if (gameOver || isPaused) return;
+ 238:
+ 239: currentPiece.position.x += direction;
+ 240: if (collision(currentPiece)) {
+ 241: currentPiece.position.x -= direction;
+ 242: }
+ 243: }
+ 244:
+ 245: // テトリミノの回転
+ 246: function rotatePiece() {
+ 247: if (gameOver || isPaused) return;
+ 248:
+ 249: const originalShape = currentPiece.shape;
+ 250: const rows = originalShape.length;
+ 251: const cols = originalShape[0].length;
+ 252:
+ 253: // 新しい形状の作成(90度回転)
+ 254: const rotatedShape = [];
+ 255: for (let i = 0; i < cols; i++) {
+ 256: const newRow = [];
+ 257: for (let j = rows - 1; j >= 0; j--) {
+ 258: newRow.push(originalShape[j][i]);
+ 259: }
+ 260: rotatedShape.push(newRow);
+ 261: }
+ 262:
+ 263: // 回転後の形状を一時的に適用して衝突チェック
+ 264: const originalPosition = { ...currentPiece.position };
+ 265: currentPiece.shape = rotatedShape;
+ 266:
+ 267: // 壁キック処理(回転後に壁や他のブロックと衝突する場合、位置を調整)
+ 268: let offset = 0;
+ 269: while (collision(currentPiece)) {
+ 270: currentPiece.position.x += offset;
+ 271: offset = -(offset + (offset >= 0 ? 1 : -1));
+ 272:
+ 273: // 一定回数試行しても配置できない場合は回転をキャンセル
+ 274: if (offset > 2) {
+ 275: currentPiece.shape = originalShape;
+ 276: currentPiece.position = originalPosition;
+ 277: return;
+ 278: }
+ 279: }
+ 280: }
+ 281:
+ 282: // テトリミノの固定
+ 283: function lockPiece() {
+ 284: currentPiece.shape.forEach((row, y) => {
+ 285: row.forEach((value, x) => {
+ 286: if (value !== 0) {
+ 287: const gridY = currentPiece.position.y + y;
+ 288: const gridX = currentPiece.position.x + x;
+ 289:
+ 290: if (gridY >= 0) {
+ 291: grid[gridY][gridX] = value;
+ 292: }
+ 293: }
+ 294: });
+ 295: });
+ 296:
+ 297: // ラインの確認と消去
+ 298: checkLines();
+ 299:
+ 300: // 次のテトリミノを設定
+ 301: currentPiece = nextPiece || createPiece();
+ 302: nextPiece = createPiece();
+ 303: drawNextPiece();
+ 304:
+ 305: // ゲームオーバーチェック
+ 306: if (collision(currentPiece)) {
+ 307: gameOver = true;
+ 308: }
+ 309: }
+ 310:
+ 311: // ラインの確認と消去
+ 312: function checkLines() {
+ 313: let linesCleared = 0;
+ 314:
+ 315: for (let y = ROWS - 1; y >= 0; y--) {
+ 316: let isLineComplete = true;
+ 317:
+ 318: for (let x = 0; x < COLS; x++) {
+ 319: if (grid[y][x] === 0) {
+ 320: isLineComplete = false;
+ 321: break;
+ 322: }
+ 323: }
+ 324:
+ 325: if (isLineComplete) {
+ 326: // ラインを消去して上のラインを下に移動
+ 327: grid.splice(y, 1);
+ 328: grid.unshift(Array(COLS).fill(0));
+ 329: linesCleared++;
+ 330: y++; // 同じ行を再チェック
+ 331: }
+ 332: }
+ 333:
+ 334: // スコア計算
+ 335: if (linesCleared > 0) {
+ 336: // ライン数に応じたスコア加算(1:100, 2:300, 3:500, 4:800)
+ 337: const points = [0, 100, 300, 500, 800];
+ 338: score += points[linesCleared] * level;
+ 339: lines += linesCleared;
+ 340:
+ 341: // レベルアップ(10ライン消去ごと)
+ 342: level = Math.floor(lines / 10) + 1;
+ 343:
+ 344: // 落下速度の更新
+ 345: dropInterval = Math.max(100, 1000 - (level - 1) * 100);
+ 346:
+ 347: // スコア表示の更新
+ 348: updateScore();
+ 349: }
+ 350: }
+ 351:
+ 352: // スコア表示の更新
+ 353: function updateScore() {
+ 354: scoreElement.textContent = score;
+ 355: levelElement.textContent = level;
+ 356: linesElement.textContent = lines;
+ 357: }
+ 358:
+ 359: // テトリミノの落下
+ 360: function dropPiece() {
+ 361: if (gameOver || isPaused) return;
+ 362:
+ 363: currentPiece.position.y++;
+ 364: if (collision(currentPiece)) {
+ 365: currentPiece.position.y--;
+ 366: lockPiece();
+ 367: }
+ 368: dropCounter = 0;
+ 369: }
+ 370:
+ 371: // ハードドロップ(一気に落下)
+ 372: function hardDrop() {
+ 373: if (gameOver || isPaused) return;
+ 374:
+ 375: while (!collision(currentPiece, 0, 1)) {
+ 376: currentPiece.position.y++;
+ 377: }
+ 378: lockPiece();
+ 379: }
+ 380:
+ 381: // ゲームの更新
+ 382: function update(time = 0) {
+ 383: const deltaTime = time - lastTime;
+ 384: lastTime = time;
+ 385:
+ 386: if (!gameOver && !isPaused) {
+ 387: dropCounter += deltaTime;
+ 388: if (dropCounter > dropInterval) {
+ 389: dropPiece();
+ 390: }
+ 391: }
+ 392:
+ 393: draw();
+ 394: requestAnimationFrame(update);
+ 395: }
+ 396:
+ 397: // ゲームの初期化
+ 398: function init() {
+ 399: grid = createGrid();
+ 400: score = 0;
+ 401: level = 1;
+ 402: lines = 0;
+ 403: gameOver = false;
+ 404: isPaused = false;
+ 405: dropInterval = 1000;
+ 406:
+ 407: currentPiece = createPiece();
+ 408: nextPiece = createPiece();
+ 409:
+ 410: updateScore();
+ 411: drawNextPiece();
+ 412: }
+ 413:
+ 414: // キーボード入力の処理
+ 415: document.addEventListener('keydown', (e) => {
+ 416: if (gameOver) return;
+ 417:
+ 418: switch (e.key) {
+ 419: case 'ArrowLeft':
+ 420: movePiece(-1);
+ 421: break;
+ 422: case 'ArrowRight':
+ 423: movePiece(1);
+ 424: break;
+ 425: case 'ArrowDown':
+ 426: dropPiece();
+ 427: break;
+ 428: case 'ArrowUp':
+ 429: rotatePiece();
+ 430: break;
+ 431: case ' ':
+ 432: hardDrop();
+ 433: break;
+ 434: case 'p':
+ 435: case 'P':
+ 436: togglePause();
+ 437: break;
+ 438: }
+ 439: });
+ 440:
+ 441: // 一時停止の切り替え
+ 442: function togglePause() {
+ 443: if (!gameOver) {
+ 444: isPaused = !isPaused;
+ 445: }
+ 446: }
+ 447:
+ 448: // スタートボタンのイベント
+ 449: startButton.addEventListener('click', () => {
+ 450: init();
+ 451: });
+ 452:
+ 453: // 一時停止ボタンのイベント
+ 454: pauseButton.addEventListener('click', () => {
+ 455: togglePause();
+ 456: });
+ 457:
+ 458: // ゲーム開始
+ 459: init();
+ 460: update();
+ 461: });
Enter y to run this tool, otherwise continue chatting.
> y
Writing to filesystem...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Creating: public/js/tetris.js
🟢 Completed in 0.4s
README.mdの作成確認で「y」を入力します。
Write to filesystem
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Path: README.md
+ 1: # テトリス Web サービス
+ 2:
+ 3: Node.jsを使用して作成されたシンプルなテトリスゲームです。
+ 4:
+ 5: ## 機能
+ 6:
+ 7: - 基本的なテトリスのゲームプレイ
+ 8: - スコア、レベル、ライン数の表示
+ 9: - 次のピースのプレビュー
+ 10: - レベルに応じた難易度の調整
+ 11: - 一時停止機能
+ 12:
+ 13: ## 操作方法
+ 14:
+ 15: - ← → キー: 左右移動
+ 16: - ↑ キー: 回転
+ 17: - ↓ キー: 高速落下
+ 18: - スペースキー: ハードドロップ(一気に落下)
+ 19: - P キー: 一時停止
+ 20:
+ 21: ## インストール方法
+ 22:
+ 23: ```bash
+ 24: # 依存関係のインストール
+ 25: npm install
+ 26:
+ 27: # サーバーの起動
+ 28: npm start
+ 29: ```
+ 30:
+ 31: サーバーが起動したら、ブラウザで `http://localhost:3000` にアクセスしてゲームを開始できます。
+ 32:
+ 33: ## 技術スタック
+ 34:
+ 35: - Node.js
+ 36: - Express
+ 37: - HTML5 Canvas
+ 38: - JavaScript
Enter y to run this tool, otherwise continue chatting.
> y
Writing to filesystem...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Creating: README.md
🟢 Completed in 0.4s
最後に、実施したことの説明が記述されます。
Node.jsを使ったテトリスのWebサービスを作成しました。基本的な機能を全て実装しています。
## プロジェクト構成
tetris-web-service/
├── server.js - Expressサーバー
├── package.json - プロジェクト設定
├── public/ - 静的ファイル
│ ├── index.html - メインHTML
│ ├── css/
│ │ └── style.css - スタイルシート
│ └── js/
│ └── tetris.js - ゲームロジック
└── README.md - 説明書
## 実装した機能
• 基本的なテトリスのゲームプレイ
• 7種類のテトリミノ(I, J, L, O, S, T, Z)
• スコア、レベル、ライン数の表示
• 次のピースのプレビュー表示
• レベルに応じた難易度調整(落下速度が上がる)
• 一時停止機能
• ゲームオーバー処理
• キーボード操作(左右移動、回転、高速落下、ハードドロップ)
## 使い方
1. 依存関係をインストールします:
npm install
2. サーバーを起動します:
npm start
3. ブラウザで http://localhost:3000 にアクセスしてゲームを開始します。
4. 「ゲーム開始」ボタンをクリックしてプレイを始めます。
## 操作方法
• 左右矢印キー: テトリミノを左右に移動
• 上矢印キー: テトリミノを回転
• 下矢印キー: テトリミノを高速落下
• スペースキー: ハードドロップ(一気に落下)
• Pキー: 一時停止
このテトリスゲームは、HTML5 Canvasを使用して描画され、JavaScriptでゲームロジックを実装しています。Expressサーバーを使用して、Webブラウザ上でプレイできるようになっています。
>
実際に動かしてみましょう。
Amazon Q Developer CLI に「サーバーを起動して、chrome で開いてください。」と命じます。
> サーバーを起動して、chrome で開いてください。
サーバーを起動して、Chromeで開きましょう。まず、必要な依存関係をインストールしてからサーバーを起動します。
Execute shell command
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I will run the following shell command:
npm install
Enter y to run this tool, otherwise continue chatting.
> y
Executing `npm install`...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
added 69 packages, and audited 70 packages in 9s
14 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
🟢 Completed in 9.675s
依存関係のインストールが完了しました。次にサーバーを起動します。バックグラウンドで実行して、すぐにChromeを開けるようにします。
Execute shell command
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I will run the following shell command:
npm start & sleep 2 && open -a "Google Chrome" http://localhost:3000
Enter y to run this tool, otherwise continue chatting.
> y
Executing `npm start & sleep 2 && open -a "Google Chrome" http://localhost:3000`...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
> tetris-web-service@1.0.0 start
> node server.js
Server is running on http://localhost:3000
🟢 Completed in 2.167s
サーバーが正常に起動し、Chromeでテトリスゲームが開かれました!
サーバーは http://localhost:3000 で実行されています。
テトリスゲームの操作方法:
• 左右矢印キー (← →): テトリミノを左右に移動
• 上矢印キー (↑): テトリミノを回転
• 下矢印キー (↓): テトリミノを高速落下
• スペースキー: ハードドロップ(一気に落下)
• Pキー: 一時停止
「ゲーム開始」ボタンをクリックしてプレイを始めることができます。また、「一時停止」ボタンでゲームを一時停止できます。
ゲームを終了する場合は、ターミナルで Ctrl+C を押してサーバーを停止してください。
>
Chrome が起動し、テトリスが表示されました!!
実際に動かしてみても正しく動いてます。
最後に作成したファイルを削除してもらいます。
> 作成したファイルを削除してください。
⠸ Thinking...
Execute shell command
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I will run the following shell command:
ls -la
Executing `ls -la`...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
drwxr-xr-x 10 staff 320 3 29 09:18 .
drwxrwxrwx 8 staff 256 2 19 10:43 ..
-rw-r--r--@ 1 staff 836 3 29 09:15 README.md
drwxr-xr-x@ 71 staff 2272 3 29 09:18 node_modules
-rw-r--r--@ 1 staff 29538 3 29 09:18 package-lock.json
-rw-r--r--@ 1 staff 224 3 29 09:05 package.json
drwxr-xr-x@ 5 staff 160 3 29 09:07 public
-rw-r--r--@ 1 staff 466 3 29 09:06 server.js
🟢 Completed in 0.54s
Execute shell command
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I will run the following shell command:
ls -la public
Executing `ls -la public`...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
total 8
drwxr-xr-x@ 5 staff 160 3 29 09:07 .
drwxr-xr-x 10 staff 320 3 29 09:18 ..
drwxr-xr-x@ 3 staff 96 3 29 09:08 css
-rw-r--r--@ 1 staff 1192 3 29 09:07 index.html
drwxr-xr-x@ 3 staff 96 3 29 09:14 js
🟢 Completed in 0.17s
Execute shell command
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I will run the following shell command:
pkill -f "node server.js"
Enter y to run this tool, otherwise continue chatting.
> y
Executing `pkill -f "node server.js"`...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
🟢 Completed in 0.42s
Execute shell command
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I will run the following shell command:
rm -rf public server.js package.json package-lock.json node_modules
Enter y to run this tool, otherwise continue chatting.
> y
Executing `rm -rf public server.js package.json package-lock.json node_modules`...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
🟢 Completed in 0.151s
Execute shell command
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I will run the following shell command:
ls -la
Executing `ls -la`...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
drwxr-xr-x 5 staff 160 3 29 09:35 .
drwxrwxrwx 8 staff 256 2 19 10:43 ..
-rw-r--r--@ 1 staff 836 3 29 09:15 README.md
🟢 Completed in 0.15s
テトリスWebサービス用に作成したファイルをすべて削除しました。以下のファイルとディレクトリを削除しました:
1. public ディレクトリ(HTML、CSS、JSファイルを含む)
2. server.js
3. package.json
4. package-lock.json
5. node_modules ディレクトリ
また、実行中のNode.jsサーバープロセスも終了させました。
現在のディレクトリ内容は、README.mdファイルのみとなっています。
> README.md も削除してください
⠇ Thinking...
⠏ Thinking...
Execute shell command
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I will run the following shell command:
rm -f README.md
Enter y to run this tool, otherwise continue chatting.
> y
Executing `rm -f README.md`...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
🟢 Completed in 0.28s
Execute shell command
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I will run the following shell command:
ls -la
Executing `ls -la `...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
total 24
drwxr-xr-x 4 staff 128 3 29 09:36 .
drwxrwxrwx 8 staff 256 2 19 10:43 ..
🟢 Completed in 0.13s
README.mdファイルを削除しました。
>
完璧だ....
まとめ
Amazon Q Developer CLI が進化しているということで試してみました。
今回はテトリスの作成でしたが、かなり精度良く動いてくれました。
他にも色々機能があるので、試してみたいと思います。