AI でゲームを作る体験 — ブリーフを書いて、コマンドを叩いて、動くアプリを手に入れる
/vb "説明"
→ フルビルド (Intake → Blueprint → Build → Check)
/vb-add "機能"
→ 既存アプリに機能追加
/vb-check
→ 品質チェック (P0/P1 機能、コード、UX)
90分以内
アイデア → 動くアプリ
$ git clone https://fabbi.backlog.com/git/
STNETMSRSDC_PRJ_AI/vibecode.git vibecode-handson
$ cd vibecode-handson
# 通常モード(毎回ファイル操作を確認)
$ claude
# 推奨: 権限確認をスキップ(VB Mini は高速開発)
$ claude --dangerously-skip-permissions
--dangerously-skip-permissions はファイル作成・npm install 等を自動許可します。トレーニング環境でのみ使用してください。
$ ls .claude/commands/
vb.md vb-add.md vb-check.md
$ ls briefs/
01-todo-kanban.md
02-bookmark-manager.md
03-expense-tracker.md
# ↑ 3つのサンプル brief が同梱
# 04-flappy-bird.md は自分で作成 → Slide 4 参照
vibecode-handson/
├── .claude/
│ ├── CLAUDE.md
│ └── commands/
│ ├── vb.md
│ ├── vb-add.md
│ └── vb-check.md
├── briefs/ ← サンプル brief 3つ同梱
│ └── 04-flappy-bird.md ← 自分で作成
├── flappy-bird/ ← ビルド出力
│ ├── BLUEPRINT.md
│ └── index.html
└── handson-log.md ← 実践ログ
エディタで briefs/04-flappy-bird.md を新規作成し、以下の構成で書く:
| セクション | 内容 |
|---|---|
| Core | 重力 + フラップ + パイプ |
| P0 (8件) | Canvas、物理、衝突、スコア... |
| P1 (5件) | 回転、グラデ、アニメ... |
| Tech | 単一 index.html、Canvas API |
| Scope外 | マルチプレイ、音、ライブラリ不可 |
> /vb "Build Flappy Bird
per briefs/04-flappy-bird.md"
ブリーフに書いていない 曖昧な部分 を解消し、ブループリントを正確に生成するため
承認したらビルド開始
「Approved — proceed」
// CFG 定数オブジェクト
const CFG = {
GRAVITY: 0.45,
FLAP_FORCE: -8.5,
PIPE_GAP: 120,
PIPE_SPEED: 2.4,
PIPE_INTERVAL: 1600,
};
// 状態マシン
const STATE = {
READY: 'READY', PLAYING: 'PLAYING',
GAME_OVER: 'GAME_OVER'
};
update(dt) {
// 重力 (フレームレート独立)
this.vy += CFG.GRAVITY * dt;
if (this.vy > 12) this.vy = 12;
this.y += this.vy * dt;
// 速度 → 回転角度 (lerp)
const target = Math.min(
Math.PI / 2, this.vy * 0.08
);
this.angle += (target - this.angle)
* 0.18 * dt;
}
入力: click / Space / ArrowUp / W / touchstart
spawnPipe() {
const minY = 60;
const maxY = groundY - CFG.PIPE_GAP - 60;
const gapTop = minY + Math.random()
* (maxY - minY);
pipes.push({
x: BASE_W + 10,
gapTop,
gapBottom: gapTop + CFG.PIPE_GAP,
scored: false
});
}
// 1.6秒ごとに生成
// 4-stop グラデーション描画
// roundRect() でキャップ
checkCollisions() {
const br = bird.radius - CFG.LENIENCY; // 3px
// 地面判定
if (by + bird.radius >= groundY) return true;
// パイプ AABB 判定
for (let p of pipes) {
if (by - br < p.gapTop) return true;
if (by + br > p.gapBottom) return true;
}
}
// スコア += 1 (パイプ通過時)
// 5点ごとに PIPE_SPEED += 0.35
// 最大速度: 5.5
30/30
全機能チェック クリア
P0 (8) + P1 (5) + Build + UX + Code
チェック方法:
# JS 構文チェック例
$ node -e "new Function(
fs.readFileSync('index.html')
.toString()
.match(/<script>([\s\S]*)<\/script>/)[1]
)"
$ npx wrangler pages deploy flappy-bird/
--project-name=vbmini-flappy
✨ Success! Deployment complete
https://vbmini-flappy.pages.dev
| 環境 | URL パターン |
|---|---|
| 本番 | {slug}.pages.dev |
| 開発 | {slug}-dev.pages.dev |
| ローカル | localhost:8787 |
🎮
今すぐプレイ!
https://vbmini-flappy.pages.dev
wrangler 1コマンドでデプロイ完了
briefs/ にある他のアプリを作ってみよう!
01-todo-kanban.md — Kanban ボード02-bookmark-manager.md — ブックマーク管理03-expense-tracker.md — 家計簿目標達成時間
90分
アイデア → 動くアプリ → デプロイ
# Flappy Bird
HTML5 Canvas game — single file (index.html).
## Core Mechanic
- Bird falls with gravity, tap/click/space to flap
- Pipes scroll left, gap between top/bottom pipe
- Collision with pipe or ground = game over
- Pass through gap = +1 score
## Features
P0 (Must)
- Canvas-based rendering (no DOM game elements)
- Bird with gravity + flap physics
- Randomly generated pipe pairs with gap
- Collision detection (AABB with 3px leniency)
- Score counter (top center)
- Game states: READY → PLAYING → GAME_OVER
- Restart on click/space after game over
- High score (localStorage)
P1 (Nice to have)
- Bird rotation based on velocity
- Pipe color gradient
- Score flash animation
- Ground scrolling parallax
- Mobile touch support
## Visual Style
- Sky blue background (#70c5ce)
- Green pipes (#73bf2e)
- Yellow/orange bird
- Retro pixel-art feel (but CSS, no sprites)
- Clean, minimal UI
## Tech
- Single index.html file
- HTML5 Canvas API
- requestAnimationFrame game loop
- No external dependencies
- ~500 lines target
## Scope Boundary
- NO multiplayer
- NO sound (keep simple)
- NO frameworks/libraries
- NO multiple files
---
# 実際の結果: 663行 (目標~500行を超過)
# P0 8/8 ✅ P1 5/5 ✅ 外部依存 0 ✅
| Step | アクション | 結果 | 行数 |
|---|---|---|---|
2.1 Intake |
/vb "Build Flappy Bird..." — 3つのQ&A |
技術スタック確定 | — |
2.2 Blueprint |
BLUEPRINT.md 自動生成、承認 | 5 STEPs 定義済み | — |
2.3 STEP 1 |
Canvas + ゲームループ、CFG定数、状態マシン | scaffold 完成 ✅ | ~80 |
2.4 STEP 2 |
鳥オブジェクト、重力、フラップ、回転、描画 | フラップ動作 ✅ | ~200 |
2.5 STEP 3 |
パイプ生成、スクロール、グラデーション描画 | パイプ動作 ✅ | ~350 |
2.6 STEP 4 |
衝突 AABB、スコア加算、速度ランプ | ゲームオーバー動作 ✅ | ~480 |
2.7 STEP 5 |
ゲームステート、パララックス、localStorage | 全機能完成 ✅ | 663 |
2.8 /vb-check |
自動品質チェック実行 | 30/30 ✅ | 663 |
# Flappy Bird — BLUEPRINT
**VB Mini Blueprint v1.0** | 2026-03-18 | APPROVED
## Tech Stack Decisions
| 項目 | 選択 | 理由 |
| Rendering | HTML5 Canvas | ライブラリ不使用、直接制御 |
| Game loop | rAF | 60fps、ブラウザネイティブ |
| State | Object + enum | シンプル、フレームワーク不要|
| Persist | localStorage | セッション横断ハイスコア |
| Input | Click+Key+Touch | モバイル + デスクトップ |
## STEP 1: Canvas + Game Loop
- HTML boilerplate, <canvas> 400×600px
- CFG: GRAVITY, FLAP_FORCE, PIPE_SPEED...
- State enum: READY | PLAYING | GAME_OVER
- rAF loop: update() + draw()
- Delta time (フレームレート独立)
## STEP 2: Bird
- {x, y, vy, radius, angle, flapAnim}
- gravity → vy, clamp 12, vy → y
- flap(): vy = FLAP_FORCE (-8.5)
- rotation: lerp angle ← vy * 0.08
## STEP 3: Pipes
- {x, gapTop, gapBottom, scored}
- gap 120px, random gapTop [60, groundY-180]
- spawn timer: 1500ms
- scroll left: PIPE_SPEED * dt
- gradient: #5DB82A → #3D8C1A
## STEP 4: Collision + Scoring
- AABB: circle vs pipe rects, 3px leniency
- ground: bird.y + radius >= groundY
- score: pipe.x + PIPE_WIDTH < bird.x
- flash: animate score size on increment
## STEP 5: Game States + Polish
- READY: overlay "Click to Start"
- GAME_OVER: score, high score, restart
- Ground: gradient + parallax lines
- Speed: PIPE_SPEED += 0.35 per 5pts
- Background: sky gradient
## Quality Gates
- [ ] Opens with no errors
- [ ] Bird flaps on click/space/touch
- [ ] Pipes scroll and collide
- [ ] Score increments correctly
- [ ] Game over + restart
- [ ] localStorage high score
- [ ] Responsive 400×600
function gameLoop(timestamp) {
const rawDt = lastTime
? (timestamp - lastTime) / (1000 / 60)
: 1;
// tab 復帰時の大きな dt を防ぐ
const dt = Math.min(rawDt, 3);
lastTime = timestamp;
update(dt);
draw();
requestAnimationFrame(gameLoop);
}
requestAnimationFrame(gameLoop);
function handleInput() {
if (state === STATE.READY) {
state = STATE.PLAYING; bird.flap();
} else if (state === STATE.PLAYING) {
bird.flap();
} else if (state === STATE.GAME_OVER) {
resetGame(); state = STATE.PLAYING;
bird.flap();
}
}
canvas.addEventListener('click', handleInput);
canvas.addEventListener('touchstart', (e) => {
e.preventDefault(); handleInput();
}, { passive: false });
function checkCollisions() {
const br = bird.radius - CFG.LENIENCY;
// 地面
if (bird.y + bird.radius >= groundY)
return true;
// パイプ AABB (broad phase + narrow)
for (let p of pipes) {
const pw = CFG.PIPE_WIDTH;
if (bird.x+br < p.x ||
bird.x-br > p.x+pw) continue;
if (bird.y-br < p.gapTop) return true;
if (bird.y+br > p.gapBottom) return true;
}
return false;
}
// 初期化
let highScore = parseInt(
localStorage.getItem('flappyHigh') || '0'
);
// ゲームオーバー時に保存
if (score > highScore) {
highScore = score;
localStorage.setItem('flappyHigh', highScore);
}
## /vb-check Results — Flappy Bird
✅ 1. BUILD
index.html loads without errors
JS syntax: valid (node -e new Function...)
✅ 2. P0 FEATURES (8/8)
✅ Canvas-based rendering
✅ Bird with gravity + flap physics
✅ Random pipe pairs (120px gap)
✅ AABB collision (3px leniency)
✅ Score counter (top center)
✅ States: READY → PLAYING → GAME_OVER
✅ Restart on click/space/touch
✅ High score (localStorage)
✅ 3. P1 FEATURES (5/5)
✅ Bird rotation (velocity-based lerp)
✅ Pipe gradient (linear, 4 stops)
✅ Score flash animation (scale pulse)
✅ Ground scrolling parallax
✅ Mobile touch support
✅ 4. UX
✅ Smooth delta-time loop (60fps)
✅ Responsive canvas (scales to window)
✅ Tab-return dt clamped to max 3
✅ Touch preventDefault (no scroll)
✅ Keyboard: Space, ArrowUp, W
✅ 5. CODE QUALITY
Lines: 663
Structure: organized by STEP comments
External deps: 0
Single file: index.html only
Scope violations: none
## Summary
Total checks: 30/30 ✅
Build time: ~1 session
P0 compliance: 100%
P1 compliance: 100%
Scope boundary: respected
Mobile support: touch + responsive
## Metrics
File: flappy-bird/index.html
Lines: 663 (target: ~500)
JS syntax: valid
External deps: 0
localStorage: flappyHigh key