create-ax-project 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +374 -0
- package/bin/create.js +193 -0
- package/package.json +38 -0
- package/template/.claude/CLAUDE.md +7 -0
- package/template/.claude/commands/CLAUDE.md +0 -0
- package/template/.claude/commands/benchmark.md +103 -0
- package/template/.claude/commands/brainstorm.md +67 -0
- package/template/.claude/commands/checkpoint.md +93 -0
- package/template/.claude/commands/codex.md +107 -0
- package/template/.claude/commands/collaborate.md +85 -0
- package/template/.claude/commands/context.md +154 -0
- package/template/.claude/commands/deploy.md +102 -0
- package/template/.claude/commands/fork.md +142 -0
- package/template/.claude/commands/gemini.md +84 -0
- package/template/.claude/commands/handoff.md +80 -0
- package/template/.claude/commands/implement.md +82 -0
- package/template/.claude/commands/init-project.md +49 -0
- package/template/.claude/commands/next.md +125 -0
- package/template/.claude/commands/planning.md +69 -0
- package/template/.claude/commands/qa.md +81 -0
- package/template/.claude/commands/refactor.md +95 -0
- package/template/.claude/commands/research.md +60 -0
- package/template/.claude/commands/restore.md +113 -0
- package/template/.claude/commands/run-stage.md +78 -0
- package/template/.claude/commands/stages.md +109 -0
- package/template/.claude/commands/status.md +73 -0
- package/template/.claude/commands/tasks.md +80 -0
- package/template/.claude/commands/test.md +93 -0
- package/template/.claude/commands/ui-ux.md +61 -0
- package/template/.claude/commands/validate.md +174 -0
- package/template/.claude/hooks/CLAUDE.md +0 -0
- package/template/.claude/hooks/ai-selector.sh +223 -0
- package/template/.claude/hooks/auto-checkpoint.sh +187 -0
- package/template/.claude/hooks/output-validator.sh +289 -0
- package/template/.claude/hooks/post-stage.sh +123 -0
- package/template/.claude/hooks/pre-stage.sh +186 -0
- package/template/.claude/hooks/session-start.sh +90 -0
- package/template/.claude/hooks/statusline.sh +115 -0
- package/template/.claude/hooks/stop.sh +104 -0
- package/template/.claude/settings.json +149 -0
- package/template/.claude/skills/ai-collaboration/CLAUDE.md +0 -0
- package/template/.claude/skills/ai-collaboration/README.md +61 -0
- package/template/.claude/skills/ai-collaboration/debate.md +148 -0
- package/template/.claude/skills/ai-collaboration/parallel.md +96 -0
- package/template/.claude/skills/ai-collaboration/prompts/CLAUDE.md +107 -0
- package/template/.claude/skills/auto-checkpoint/CLAUDE.md +0 -0
- package/template/.claude/skills/auto-checkpoint/README.md +77 -0
- package/template/.claude/skills/auto-checkpoint/prompts/CLAUDE.md +113 -0
- package/template/.claude/skills/auto-checkpoint/rollback.md +152 -0
- package/template/.claude/skills/auto-checkpoint/trigger.md +122 -0
- package/template/.claude/skills/context-compression/CLAUDE.md +0 -0
- package/template/.claude/skills/context-compression/README.md +121 -0
- package/template/.claude/skills/context-compression/analyze.md +114 -0
- package/template/.claude/skills/context-compression/compress.md +175 -0
- package/template/.claude/skills/context-compression/prompts/CLAUDE.md +0 -0
- package/template/.claude/skills/context-compression/prompts/compression.md +172 -0
- package/template/.claude/skills/output-validator/CLAUDE.md +0 -0
- package/template/.claude/skills/output-validator/README.md +86 -0
- package/template/.claude/skills/output-validator/prompts/CLAUDE.md +119 -0
- package/template/.claude/skills/output-validator/validate.md +182 -0
- package/template/.claude/skills/smart-handoff/CLAUDE.md +0 -0
- package/template/.claude/skills/smart-handoff/README.md +59 -0
- package/template/.claude/skills/smart-handoff/extract.md +76 -0
- package/template/.claude/skills/smart-handoff/prompts/CLAUDE.md +86 -0
- package/template/.claude/skills/smart-handoff/summarize.md +94 -0
- package/template/.claude/skills/stage-transition/CLAUDE.md +0 -0
- package/template/.claude/skills/stage-transition/README.md +84 -0
- package/template/.claude/skills/stage-transition/handoff-gen.md +160 -0
- package/template/.claude/skills/stage-transition/prompts/CLAUDE.md +0 -0
- package/template/.claude/skills/stage-transition/prompts/transition.md +145 -0
- package/template/.claude/skills/stage-transition/validate.md +108 -0
- package/template/CLAUDE.md +528 -0
- package/template/config/CLAUDE.md +0 -0
- package/template/config/ai_benchmarking.yaml +184 -0
- package/template/config/ai_collaboration.yaml +159 -0
- package/template/config/ai_logging.yaml +129 -0
- package/template/config/auto_checkpoint.yaml +189 -0
- package/template/config/context.yaml +78 -0
- package/template/config/git.yaml +161 -0
- package/template/config/handoff_intelligence.yaml +229 -0
- package/template/config/implementation.yaml.template +181 -0
- package/template/config/mcp_fallbacks.yaml +252 -0
- package/template/config/memory_integration.yaml +200 -0
- package/template/config/model_enforcement.yaml +141 -0
- package/template/config/models.yaml +242 -0
- package/template/config/output_validation.yaml +352 -0
- package/template/config/pipeline.yaml +357 -0
- package/template/config/pipeline_forking.yaml +236 -0
- package/template/config/qa_logging.yaml +166 -0
- package/template/config/smart_rollback.yaml +209 -0
- package/template/config/stage_personas.yaml +354 -0
- package/template/config/workflow.yaml +54 -0
- package/template/scripts/CLAUDE.md +0 -0
- package/template/scripts/ai-benchmark.sh +272 -0
- package/template/scripts/codex-wrapper.sh +97 -0
- package/template/scripts/context-manager.sh +528 -0
- package/template/scripts/create-checkpoint.sh +116 -0
- package/template/scripts/gemini-wrapper.sh +96 -0
- package/template/scripts/init-project.sh +109 -0
- package/template/scripts/list-stages.sh +245 -0
- package/template/scripts/next-stage.sh +228 -0
- package/template/scripts/output-validate.sh +12 -0
- package/template/scripts/pipeline-fork.sh +293 -0
- package/template/scripts/pre-run-check.sh +361 -0
- package/template/scripts/restore-checkpoint.sh +247 -0
- package/template/scripts/run-stage.sh +139 -0
- package/template/scripts/show-status.sh +185 -0
- package/template/scripts/smart-handoff.sh +254 -0
- package/template/stages/01-brainstorm/CLAUDE.md +103 -0
- package/template/stages/01-brainstorm/HANDOFF.md +110 -0
- package/template/stages/01-brainstorm/HANDOFF.md.template +112 -0
- package/template/stages/01-brainstorm/README.md +97 -0
- package/template/stages/01-brainstorm/config.yaml +92 -0
- package/template/stages/01-brainstorm/inputs/.gitkeep +0 -0
- package/template/stages/01-brainstorm/inputs/CLAUDE.md +0 -0
- package/template/stages/01-brainstorm/inputs/project_brief.md +40 -0
- package/template/stages/01-brainstorm/outputs/.gitkeep +0 -0
- package/template/stages/01-brainstorm/outputs/CLAUDE.md +0 -0
- package/template/stages/01-brainstorm/outputs/ideas.md +159 -0
- package/template/stages/01-brainstorm/outputs/requirements_analysis.md +222 -0
- package/template/stages/01-brainstorm/prompts/CLAUDE.md +0 -0
- package/template/stages/01-brainstorm/prompts/collaboration.md +46 -0
- package/template/stages/01-brainstorm/prompts/ideation.md +62 -0
- package/template/stages/01-brainstorm/prompts/persona.md +73 -0
- package/template/stages/01-brainstorm/prompts/requirements.md +73 -0
- package/template/stages/01-brainstorm/prompts/validation.md +50 -0
- package/template/stages/01-brainstorm/templates/CLAUDE.md +0 -0
- package/template/stages/01-brainstorm/templates/ideas.md +91 -0
- package/template/stages/01-brainstorm/templates/requirements_analysis.md +129 -0
- package/template/stages/02-research/CLAUDE.md +101 -0
- package/template/stages/02-research/HANDOFF.md +158 -0
- package/template/stages/02-research/HANDOFF.md.template +102 -0
- package/template/stages/02-research/config.yaml +68 -0
- package/template/stages/02-research/inputs/.gitkeep +0 -0
- package/template/stages/02-research/outputs/.gitkeep +0 -0
- package/template/stages/02-research/outputs/CLAUDE.md +0 -0
- package/template/stages/02-research/outputs/feasibility_report.md +176 -0
- package/template/stages/02-research/outputs/tech_research.md +403 -0
- package/template/stages/02-research/prompts/CLAUDE.md +0 -0
- package/template/stages/02-research/prompts/collaboration.md +51 -0
- package/template/stages/02-research/prompts/feasibility.md +73 -0
- package/template/stages/02-research/prompts/market_analysis.md +58 -0
- package/template/stages/02-research/prompts/tech_stack.md +60 -0
- package/template/stages/02-research/prompts/validation.md +51 -0
- package/template/stages/02-research/templates/.gitkeep +0 -0
- package/template/stages/03-planning/CLAUDE.md +98 -0
- package/template/stages/03-planning/HANDOFF.md +168 -0
- package/template/stages/03-planning/HANDOFF.md.template +91 -0
- package/template/stages/03-planning/config.yaml +64 -0
- package/template/stages/03-planning/inputs/.gitkeep +0 -0
- package/template/stages/03-planning/outputs/.gitkeep +0 -0
- package/template/stages/03-planning/outputs/CLAUDE.md +0 -0
- package/template/stages/03-planning/outputs/architecture.md +400 -0
- package/template/stages/03-planning/outputs/implementation.yaml +209 -0
- package/template/stages/03-planning/outputs/project_plan.md +204 -0
- package/template/stages/03-planning/outputs/tech_stack.md +176 -0
- package/template/stages/03-planning/prompts/CLAUDE.md +0 -0
- package/template/stages/03-planning/prompts/architecture.md +62 -0
- package/template/stages/03-planning/prompts/collaboration.md +57 -0
- package/template/stages/03-planning/prompts/validation.md +59 -0
- package/template/stages/03-planning/templates/.gitkeep +0 -0
- package/template/stages/04-ui-ux/CLAUDE.md +88 -0
- package/template/stages/04-ui-ux/HANDOFF.md +165 -0
- package/template/stages/04-ui-ux/HANDOFF.md.template +92 -0
- package/template/stages/04-ui-ux/config.yaml +57 -0
- package/template/stages/04-ui-ux/inputs/.gitkeep +0 -0
- package/template/stages/04-ui-ux/outputs/.gitkeep +0 -0
- package/template/stages/04-ui-ux/outputs/CLAUDE.md +0 -0
- package/template/stages/04-ui-ux/outputs/design_system.md +449 -0
- package/template/stages/04-ui-ux/outputs/user_flows.md +321 -0
- package/template/stages/04-ui-ux/outputs/wireframes.md +241 -0
- package/template/stages/04-ui-ux/prompts/.gitkeep +0 -0
- package/template/stages/04-ui-ux/prompts/CLAUDE.md +0 -0
- package/template/stages/04-ui-ux/prompts/collaboration.md +56 -0
- package/template/stages/04-ui-ux/prompts/validation.md +54 -0
- package/template/stages/04-ui-ux/templates/.gitkeep +0 -0
- package/template/stages/05-task-management/CLAUDE.md +105 -0
- package/template/stages/05-task-management/HANDOFF.md +187 -0
- package/template/stages/05-task-management/HANDOFF.md.template +97 -0
- package/template/stages/05-task-management/config.yaml +81 -0
- package/template/stages/05-task-management/inputs/.gitkeep +0 -0
- package/template/stages/05-task-management/outputs/.gitkeep +0 -0
- package/template/stages/05-task-management/outputs/CLAUDE.md +0 -0
- package/template/stages/05-task-management/outputs/milestones.md +253 -0
- package/template/stages/05-task-management/outputs/sprint_plan.md +203 -0
- package/template/stages/05-task-management/outputs/tasks.md +402 -0
- package/template/stages/05-task-management/prompts/.gitkeep +0 -0
- package/template/stages/05-task-management/prompts/CLAUDE.md +0 -0
- package/template/stages/05-task-management/prompts/collaboration.md +54 -0
- package/template/stages/05-task-management/prompts/validation.md +66 -0
- package/template/stages/05-task-management/templates/CLAUDE.md +0 -0
- package/template/stages/05-task-management/templates/notion_integration.md +176 -0
- package/template/stages/05-task-management/templates/parallel_groups.yaml +153 -0
- package/template/stages/05-task-management/templates/task_schema.yaml +154 -0
- package/template/stages/06-implementation/CLAUDE.md +163 -0
- package/template/stages/06-implementation/HANDOFF.md +184 -0
- package/template/stages/06-implementation/HANDOFF.md.template +192 -0
- package/template/stages/06-implementation/config.yaml +62 -0
- package/template/stages/06-implementation/inputs/.gitkeep +0 -0
- package/template/stages/06-implementation/outputs/.gitkeep +0 -0
- package/template/stages/06-implementation/prompts/.gitkeep +0 -0
- package/template/stages/06-implementation/prompts/CLAUDE.md +0 -0
- package/template/stages/06-implementation/prompts/collaboration.md +64 -0
- package/template/stages/06-implementation/prompts/validation.md +65 -0
- package/template/stages/06-implementation/templates/.gitkeep +0 -0
- package/template/stages/07-refactoring/CLAUDE.md +180 -0
- package/template/stages/07-refactoring/HANDOFF.md +82 -0
- package/template/stages/07-refactoring/HANDOFF.md.template +97 -0
- package/template/stages/07-refactoring/config.yaml +68 -0
- package/template/stages/07-refactoring/inputs/.gitkeep +0 -0
- package/template/stages/07-refactoring/outputs/.gitkeep +0 -0
- package/template/stages/07-refactoring/outputs/refactoring_report.md +102 -0
- package/template/stages/07-refactoring/prompts/.gitkeep +0 -0
- package/template/stages/07-refactoring/prompts/CLAUDE.md +0 -0
- package/template/stages/07-refactoring/prompts/collaboration.md +71 -0
- package/template/stages/07-refactoring/prompts/validation.md +76 -0
- package/template/stages/07-refactoring/templates/.gitkeep +0 -0
- package/template/stages/08-qa/CLAUDE.md +93 -0
- package/template/stages/08-qa/HANDOFF.md +114 -0
- package/template/stages/08-qa/HANDOFF.md.template +96 -0
- package/template/stages/08-qa/config.yaml +56 -0
- package/template/stages/08-qa/inputs/.gitkeep +0 -0
- package/template/stages/08-qa/outputs/.gitkeep +0 -0
- package/template/stages/08-qa/outputs/qa_report.md +138 -0
- package/template/stages/08-qa/prompts/.gitkeep +0 -0
- package/template/stages/08-qa/prompts/CLAUDE.md +0 -0
- package/template/stages/08-qa/prompts/collaboration.md +65 -0
- package/template/stages/08-qa/prompts/validation.md +71 -0
- package/template/stages/08-qa/templates/.gitkeep +0 -0
- package/template/stages/09-testing/CLAUDE.md +124 -0
- package/template/stages/09-testing/HANDOFF.md +118 -0
- package/template/stages/09-testing/HANDOFF.md.template +113 -0
- package/template/stages/09-testing/config.yaml +65 -0
- package/template/stages/09-testing/inputs/.gitkeep +0 -0
- package/template/stages/09-testing/outputs/.gitkeep +0 -0
- package/template/stages/09-testing/outputs/test_report.md +146 -0
- package/template/stages/09-testing/prompts/.gitkeep +0 -0
- package/template/stages/09-testing/prompts/CLAUDE.md +0 -0
- package/template/stages/09-testing/prompts/collaboration.md +77 -0
- package/template/stages/09-testing/prompts/validation.md +83 -0
- package/template/stages/09-testing/templates/.gitkeep +0 -0
- package/template/stages/10-deployment/CLAUDE.md +117 -0
- package/template/stages/10-deployment/HANDOFF.md +141 -0
- package/template/stages/10-deployment/HANDOFF.md.template +148 -0
- package/template/stages/10-deployment/config.yaml +61 -0
- package/template/stages/10-deployment/inputs/.gitkeep +0 -0
- package/template/stages/10-deployment/outputs/.gitkeep +0 -0
- package/template/stages/10-deployment/prompts/.gitkeep +0 -0
- package/template/stages/10-deployment/prompts/CLAUDE.md +0 -0
- package/template/stages/10-deployment/prompts/collaboration.md +80 -0
- package/template/stages/10-deployment/prompts/validation.md +93 -0
- package/template/stages/10-deployment/templates/CLAUDE.md +0 -0
- package/template/stages/10-deployment/templates/github-actions-cd.yaml +118 -0
- package/template/stages/10-deployment/templates/github-actions-ci.yaml +136 -0
- package/template/state/progress.json.template +111 -0
- package/template/state/templates/CLAUDE.md +0 -0
- package/template/state/templates/handoff_base.md.template +187 -0
- package/template/state/templates/phase_state.md.template +97 -0
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
# 🏗️ Snake Game 시스템 아키텍처 설계서
|
|
2
|
+
|
|
3
|
+
> 생성일: 2026-01-21
|
|
4
|
+
> 스테이지: 03-planning
|
|
5
|
+
> 프로젝트: snake-game
|
|
6
|
+
> AI 도구: Gemini CLI
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## 1. 컴포넌트 구조
|
|
11
|
+
|
|
12
|
+
이 프로젝트는 단일 캔버스 렌더링 방식과 React UI 오버레이를 결합한 **하이브리드 구조**를 채택합니다.
|
|
13
|
+
|
|
14
|
+
### 1.1 컴포넌트 역할
|
|
15
|
+
|
|
16
|
+
| 컴포넌트 | 타입 | 역할 |
|
|
17
|
+
|---------|------|------|
|
|
18
|
+
| **App** | Container | 전체 레이아웃, 최상위 상태(테마 등) 관리 |
|
|
19
|
+
| **GameEngine** | Smart | 핵심 비즈니스 로직 연결, Canvas/UI 조율 |
|
|
20
|
+
| **CanvasLayer** | Presentation | Canvas 접근, 게임 렌더링 수행 |
|
|
21
|
+
| **UIOverlay** | Presentation | HTML/CSS 기반 UI (점수, 모달 등) |
|
|
22
|
+
| **ScoreBoard** | UI | 현재 점수와 최고 점수 표시 |
|
|
23
|
+
| **GameOverModal** | UI | 게임 종료 시 재시작 버튼과 결과 |
|
|
24
|
+
| **StartScreen** | UI | 게임 시작 전 타이틀 화면 |
|
|
25
|
+
| **MobileControls** | UI | 모바일 방향 버튼 |
|
|
26
|
+
|
|
27
|
+
### 1.2 계층 구조 다이어그램
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
+-------------------------------------------------------+
|
|
31
|
+
| App |
|
|
32
|
+
|-------------------------------------------------------|
|
|
33
|
+
| +-------------------------------------------------+ |
|
|
34
|
+
| | GameEngine | |
|
|
35
|
+
| | (Holds Game State, Refs, and Event Listeners) | |
|
|
36
|
+
| |-------------------------------------------------| |
|
|
37
|
+
| | +-------------------+ +-------------------+ | |
|
|
38
|
+
| | | CanvasLayer | | UIOverlay | | |
|
|
39
|
+
| | | (Rendering Target)| | (React Components)| | |
|
|
40
|
+
| | | | | | | |
|
|
41
|
+
| | | [Snake] [Food] | | [ScoreBoard] | | |
|
|
42
|
+
| | | [Grid] [Fx] | | [GameOverModal] | | |
|
|
43
|
+
| | | | | [MobileControls] | | |
|
|
44
|
+
| | +-------------------+ +-------------------+ | |
|
|
45
|
+
| +-------------------------------------------------+ |
|
|
46
|
+
+-------------------------------------------------------+
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### 1.3 컴포넌트 의존성 그래프
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
App
|
|
53
|
+
│
|
|
54
|
+
GameEngine
|
|
55
|
+
│
|
|
56
|
+
┌────────────┼────────────┐
|
|
57
|
+
│ │ │
|
|
58
|
+
CanvasLayer UIOverlay Hooks
|
|
59
|
+
│ │ │
|
|
60
|
+
│ ┌─────┴─────┐ │
|
|
61
|
+
│ │ │ │ │
|
|
62
|
+
│ Score Modal Mobile │
|
|
63
|
+
│ Board Over Controls│
|
|
64
|
+
│ │
|
|
65
|
+
└────────────────────────┘
|
|
66
|
+
Canvas Context
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## 2. 데이터 흐름
|
|
72
|
+
|
|
73
|
+
React의 선언적 상태 관리와 Canvas의 명령형 렌더링을 조화시키는 것이 핵심입니다.
|
|
74
|
+
|
|
75
|
+
### 2.1 게임 상태 흐름
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
┌─────────────────────────────────────────────────────────┐
|
|
79
|
+
│ State Flow │
|
|
80
|
+
├─────────────────────────────────────────────────────────┤
|
|
81
|
+
│ │
|
|
82
|
+
│ useReducer ──────────────────────────────────────┐ │
|
|
83
|
+
│ │ │ │
|
|
84
|
+
│ ▼ │ │
|
|
85
|
+
│ gameState ────────────────────────────────────► │ │
|
|
86
|
+
│ (snake, food, direction, score, status) │ │
|
|
87
|
+
│ │ │ │
|
|
88
|
+
│ │ requestAnimationFrame │ │
|
|
89
|
+
│ ▼ │ │ │
|
|
90
|
+
│ gameLoop ◄────┘ │ │
|
|
91
|
+
│ │ │ │
|
|
92
|
+
│ ├──► dispatch({ type: 'TICK' }) │ │
|
|
93
|
+
│ │ │ │
|
|
94
|
+
│ ▼ │ │
|
|
95
|
+
│ Canvas.draw() ◄──────────────────────────────────┘ │
|
|
96
|
+
│ │
|
|
97
|
+
└─────────────────────────────────────────────────────────┘
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### 2.2 이벤트 처리 흐름
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
┌─────────────────────────────────────────────────────────┐
|
|
104
|
+
│ Event Flow │
|
|
105
|
+
├─────────────────────────────────────────────────────────┤
|
|
106
|
+
│ │
|
|
107
|
+
│ User Input │
|
|
108
|
+
│ │ │
|
|
109
|
+
│ ├──► Keyboard (useKeyboard) ──┐ │
|
|
110
|
+
│ │ │ │
|
|
111
|
+
│ └──► Touch (useSwipe) ────────┤ │
|
|
112
|
+
│ │ │
|
|
113
|
+
│ ▼ │
|
|
114
|
+
│ Direction Normalized │
|
|
115
|
+
│ (UP/DOWN/LEFT/RIGHT) │
|
|
116
|
+
│ │ │
|
|
117
|
+
│ ▼ │
|
|
118
|
+
│ dispatch({ type: 'CHANGE_DIRECTION' }) │
|
|
119
|
+
│ │ │
|
|
120
|
+
│ ▼ │
|
|
121
|
+
│ Collision Check │
|
|
122
|
+
│ │ │
|
|
123
|
+
│ ┌────────────────┼────────────┐ │
|
|
124
|
+
│ │ │ │ │
|
|
125
|
+
│ ▼ ▼ ▼ │
|
|
126
|
+
│ Wall Hit Self Hit Eat Food │
|
|
127
|
+
│ │ │ │ │
|
|
128
|
+
│ ▼ ▼ ▼ │
|
|
129
|
+
│ GAME_OVER GAME_OVER Grow +10 │
|
|
130
|
+
│ │
|
|
131
|
+
└─────────────────────────────────────────────────────────┘
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### 2.3 상태 vs 참조 분리
|
|
135
|
+
|
|
136
|
+
| 데이터 | 관리 방식 | 이유 |
|
|
137
|
+
|--------|----------|------|
|
|
138
|
+
| snake, food, score | `useReducer` | UI 리렌더링 필요 |
|
|
139
|
+
| direction (버퍼) | `useRef` | 빠른 입력 처리, 리렌더링 방지 |
|
|
140
|
+
| canvasRef | `useRef` | DOM 참조 |
|
|
141
|
+
| animationFrameId | `useRef` | 루프 관리 |
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## 3. 커스텀 훅 설계
|
|
146
|
+
|
|
147
|
+
### 3.1 useGameLoop
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
/**
|
|
151
|
+
* requestAnimationFrame 기반 게임 루프 관리
|
|
152
|
+
* @param callback 매 프레임 실행될 함수
|
|
153
|
+
* @param isRunning 루프 실행 여부
|
|
154
|
+
*/
|
|
155
|
+
const useGameLoop = (
|
|
156
|
+
callback: (deltaTime: number) => void,
|
|
157
|
+
isRunning: boolean
|
|
158
|
+
) => void;
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
**특징**:
|
|
162
|
+
- 컴포넌트 언마운트 시 자동 정리
|
|
163
|
+
- deltaTime 계산하여 프레임 독립적 애니메이션
|
|
164
|
+
- isRunning으로 일시정지/재개 제어
|
|
165
|
+
|
|
166
|
+
### 3.2 useKeyboard
|
|
167
|
+
|
|
168
|
+
```typescript
|
|
169
|
+
/**
|
|
170
|
+
* 키보드 입력 감지 및 방향 변환
|
|
171
|
+
* @param onDirectionChange 방향 변경 시 콜백
|
|
172
|
+
* @param onPause 일시정지 토글 콜백
|
|
173
|
+
* @param onRestart 재시작 콜백
|
|
174
|
+
*/
|
|
175
|
+
const useKeyboard = (
|
|
176
|
+
onDirectionChange: (direction: Direction) => void,
|
|
177
|
+
onPause?: () => void,
|
|
178
|
+
onRestart?: () => void
|
|
179
|
+
) => void;
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
**지원 키**:
|
|
183
|
+
- Arrow Keys: 방향 이동
|
|
184
|
+
- WASD: 방향 이동 (대안)
|
|
185
|
+
- P / Escape: 일시정지
|
|
186
|
+
- R / Space: 재시작
|
|
187
|
+
|
|
188
|
+
### 3.3 useSwipe
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
/**
|
|
192
|
+
* 터치 스와이프 제스처 감지
|
|
193
|
+
* @param handlers 각 방향별 핸들러
|
|
194
|
+
*/
|
|
195
|
+
const useSwipe = (handlers: {
|
|
196
|
+
left?: () => void;
|
|
197
|
+
right?: () => void;
|
|
198
|
+
up?: () => void;
|
|
199
|
+
down?: () => void;
|
|
200
|
+
}) => void;
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
**특징**:
|
|
204
|
+
- 최소 스와이프 거리 (threshold): 50px
|
|
205
|
+
- 최대 스와이프 시간: 500ms
|
|
206
|
+
- passive 리스너로 성능 최적화
|
|
207
|
+
|
|
208
|
+
### 3.4 useHighScore
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
/**
|
|
212
|
+
* localStorage 기반 최고 점수 관리
|
|
213
|
+
*/
|
|
214
|
+
const useHighScore = () => {
|
|
215
|
+
highScore: number;
|
|
216
|
+
updateHighScore: (score: number) => boolean; // 갱신 여부 반환
|
|
217
|
+
resetHighScore: () => void;
|
|
218
|
+
};
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## 4. 파일/폴더 구조
|
|
224
|
+
|
|
225
|
+
```
|
|
226
|
+
snake-game/
|
|
227
|
+
├── public/
|
|
228
|
+
│ └── favicon.svg
|
|
229
|
+
├── src/
|
|
230
|
+
│ ├── assets/ # 정적 자산
|
|
231
|
+
│ │ └── sounds/ # 효과음 (선택)
|
|
232
|
+
│ │
|
|
233
|
+
│ ├── components/ # React UI 컴포넌트
|
|
234
|
+
│ │ ├── CanvasLayer.tsx # Canvas 래퍼
|
|
235
|
+
│ │ ├── GameOverlay.tsx # UI 오버레이 컨테이너
|
|
236
|
+
│ │ ├── ScoreBoard.tsx # 점수판
|
|
237
|
+
│ │ ├── StartScreen.tsx # 시작 화면
|
|
238
|
+
│ │ ├── GameOverModal.tsx # 게임 오버 모달
|
|
239
|
+
│ │ └── MobileControls.tsx # 모바일 버튼
|
|
240
|
+
│ │
|
|
241
|
+
│ ├── hooks/ # 커스텀 훅
|
|
242
|
+
│ │ ├── useGameLoop.ts
|
|
243
|
+
│ │ ├── useKeyboard.ts
|
|
244
|
+
│ │ ├── useSwipe.ts
|
|
245
|
+
│ │ └── useHighScore.ts
|
|
246
|
+
│ │
|
|
247
|
+
│ ├── engine/ # 게임 핵심 로직
|
|
248
|
+
│ │ ├── gameReducer.ts # 상태 관리 리듀서
|
|
249
|
+
│ │ ├── collision.ts # 충돌 감지
|
|
250
|
+
│ │ └── renderer.ts # Canvas 렌더링
|
|
251
|
+
│ │
|
|
252
|
+
│ ├── types/ # TypeScript 타입
|
|
253
|
+
│ │ └── index.ts
|
|
254
|
+
│ │
|
|
255
|
+
│ ├── utils/ # 유틸리티 함수
|
|
256
|
+
│ │ └── random.ts # 랜덤 좌표 생성
|
|
257
|
+
│ │
|
|
258
|
+
│ ├── constants/ # 상수 정의
|
|
259
|
+
│ │ └── config.ts
|
|
260
|
+
│ │
|
|
261
|
+
│ ├── styles/ # 스타일
|
|
262
|
+
│ │ └── index.css
|
|
263
|
+
│ │
|
|
264
|
+
│ ├── App.tsx # 루트 컴포넌트
|
|
265
|
+
│ ├── GameEngine.tsx # 게임 엔진 컴포넌트
|
|
266
|
+
│ └── main.tsx # 진입점
|
|
267
|
+
│
|
|
268
|
+
├── index.html
|
|
269
|
+
├── package.json
|
|
270
|
+
├── tsconfig.json
|
|
271
|
+
├── vite.config.ts
|
|
272
|
+
└── README.md
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## 5. 타입 정의
|
|
278
|
+
|
|
279
|
+
```typescript
|
|
280
|
+
// types/index.ts
|
|
281
|
+
|
|
282
|
+
/** 좌표 타입 */
|
|
283
|
+
export interface Point {
|
|
284
|
+
x: number;
|
|
285
|
+
y: number;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/** 이동 방향 */
|
|
289
|
+
export type Direction = 'UP' | 'DOWN' | 'LEFT' | 'RIGHT';
|
|
290
|
+
|
|
291
|
+
/** 게임 진행 상태 */
|
|
292
|
+
export type GameStatus = 'IDLE' | 'PLAYING' | 'PAUSED' | 'GAME_OVER';
|
|
293
|
+
|
|
294
|
+
/** 전체 게임 상태 (Reducer State) */
|
|
295
|
+
export interface GameState {
|
|
296
|
+
status: GameStatus;
|
|
297
|
+
snake: Point[]; // 뱀 몸통 (0번이 머리)
|
|
298
|
+
food: Point; // 먹이 위치
|
|
299
|
+
direction: Direction; // 현재 방향
|
|
300
|
+
nextDirection: Direction; // 입력 버퍼 (다음 틱에 적용)
|
|
301
|
+
score: number;
|
|
302
|
+
level: number;
|
|
303
|
+
speed: number; // 현재 속도 (ms)
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/** Reducer Actions */
|
|
307
|
+
export type GameAction =
|
|
308
|
+
| { type: 'START_GAME' }
|
|
309
|
+
| { type: 'PAUSE_GAME' }
|
|
310
|
+
| { type: 'RESUME_GAME' }
|
|
311
|
+
| { type: 'GAME_OVER' }
|
|
312
|
+
| { type: 'TICK' }
|
|
313
|
+
| { type: 'CHANGE_DIRECTION'; payload: Direction }
|
|
314
|
+
| { type: 'EAT_FOOD' }
|
|
315
|
+
| { type: 'RESTART' };
|
|
316
|
+
|
|
317
|
+
/** 게임 설정 */
|
|
318
|
+
export interface GameConfig {
|
|
319
|
+
boardSize: number; // 그리드 크기 (20x20)
|
|
320
|
+
cellSize: number; // 셀 픽셀 크기
|
|
321
|
+
initialSpeed: number; // 초기 속도 (ms)
|
|
322
|
+
speedDecrement: number; // 레벨업 시 속도 감소량
|
|
323
|
+
minSpeed: number; // 최소 속도 (최대 난이도)
|
|
324
|
+
pointsPerFood: number; // 먹이당 점수
|
|
325
|
+
pointsForLevelUp: number; // 레벨업 필요 점수
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/** 키보드 핸들러 */
|
|
329
|
+
export interface KeyboardHandlers {
|
|
330
|
+
onDirectionChange: (direction: Direction) => void;
|
|
331
|
+
onPause?: () => void;
|
|
332
|
+
onRestart?: () => void;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/** 스와이프 핸들러 */
|
|
336
|
+
export interface SwipeHandlers {
|
|
337
|
+
left?: () => void;
|
|
338
|
+
right?: () => void;
|
|
339
|
+
up?: () => void;
|
|
340
|
+
down?: () => void;
|
|
341
|
+
}
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
---
|
|
345
|
+
|
|
346
|
+
## 6. 게임 설정 상수
|
|
347
|
+
|
|
348
|
+
```typescript
|
|
349
|
+
// constants/config.ts
|
|
350
|
+
|
|
351
|
+
export const GAME_CONFIG: GameConfig = {
|
|
352
|
+
boardSize: 20, // 20x20 그리드
|
|
353
|
+
cellSize: 20, // 각 셀 20px
|
|
354
|
+
initialSpeed: 150, // 150ms (초기)
|
|
355
|
+
speedDecrement: 10, // 레벨업 시 10ms 감소
|
|
356
|
+
minSpeed: 50, // 최소 50ms (최고 난이도)
|
|
357
|
+
pointsPerFood: 10, // 먹이당 10점
|
|
358
|
+
pointsForLevelUp: 50, // 50점마다 레벨업
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
export const COLORS = {
|
|
362
|
+
background: '#1a1a2e',
|
|
363
|
+
grid: '#16213e',
|
|
364
|
+
snake: '#00ff88',
|
|
365
|
+
snakeHead: '#00cc6a',
|
|
366
|
+
food: '#ff6b6b',
|
|
367
|
+
text: '#ffffff',
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
export const INITIAL_SNAKE: Point[] = [
|
|
371
|
+
{ x: 10, y: 10 }, // 머리
|
|
372
|
+
{ x: 9, y: 10 },
|
|
373
|
+
{ x: 8, y: 10 },
|
|
374
|
+
];
|
|
375
|
+
|
|
376
|
+
export const DIRECTION_VECTORS: Record<Direction, Point> = {
|
|
377
|
+
UP: { x: 0, y: -1 },
|
|
378
|
+
DOWN: { x: 0, y: 1 },
|
|
379
|
+
LEFT: { x: -1, y: 0 },
|
|
380
|
+
RIGHT: { x: 1, y: 0 },
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
export const OPPOSITE_DIRECTIONS: Record<Direction, Direction> = {
|
|
384
|
+
UP: 'DOWN',
|
|
385
|
+
DOWN: 'UP',
|
|
386
|
+
LEFT: 'RIGHT',
|
|
387
|
+
RIGHT: 'LEFT',
|
|
388
|
+
};
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
---
|
|
392
|
+
|
|
393
|
+
## ✅ 아키텍처 체크리스트
|
|
394
|
+
|
|
395
|
+
- [x] 컴포넌트 구조 정의
|
|
396
|
+
- [x] 데이터 흐름 설계
|
|
397
|
+
- [x] 커스텀 훅 설계
|
|
398
|
+
- [x] 파일/폴더 구조 정의
|
|
399
|
+
- [x] 타입 정의
|
|
400
|
+
- [x] 게임 설정 상수 정의
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# Snake Game - Implementation Rules
|
|
2
|
+
# 생성일: 2026-01-21
|
|
3
|
+
# 스테이지: 03-planning
|
|
4
|
+
|
|
5
|
+
project:
|
|
6
|
+
name: snake-game
|
|
7
|
+
type: game
|
|
8
|
+
framework: react
|
|
9
|
+
language: typescript
|
|
10
|
+
|
|
11
|
+
# 컴포넌트 규칙
|
|
12
|
+
components:
|
|
13
|
+
type: functional # functional | class
|
|
14
|
+
naming: PascalCase
|
|
15
|
+
file_extension: tsx
|
|
16
|
+
|
|
17
|
+
# 컴포넌트 구조
|
|
18
|
+
structure:
|
|
19
|
+
- props_interface # Props 인터페이스 정의
|
|
20
|
+
- component_function
|
|
21
|
+
- exports
|
|
22
|
+
|
|
23
|
+
# 컴포넌트 카테고리
|
|
24
|
+
categories:
|
|
25
|
+
- name: containers
|
|
26
|
+
path: src/
|
|
27
|
+
examples: [App.tsx, GameEngine.tsx]
|
|
28
|
+
- name: presentation
|
|
29
|
+
path: src/components/
|
|
30
|
+
examples: [CanvasLayer.tsx, ScoreBoard.tsx]
|
|
31
|
+
- name: ui
|
|
32
|
+
path: src/components/
|
|
33
|
+
examples: [GameOverModal.tsx, MobileControls.tsx]
|
|
34
|
+
|
|
35
|
+
# 스타일링 규칙
|
|
36
|
+
styling:
|
|
37
|
+
method: css-modules # css-modules | tailwind | styled-components
|
|
38
|
+
naming: kebab-case
|
|
39
|
+
file_pattern: "{ComponentName}.module.css"
|
|
40
|
+
|
|
41
|
+
# 색상 변수 (CSS Custom Properties)
|
|
42
|
+
colors:
|
|
43
|
+
background: "#1a1a2e"
|
|
44
|
+
grid: "#16213e"
|
|
45
|
+
snake: "#00ff88"
|
|
46
|
+
snake_head: "#00cc6a"
|
|
47
|
+
food: "#ff6b6b"
|
|
48
|
+
text: "#ffffff"
|
|
49
|
+
|
|
50
|
+
# 상태 관리
|
|
51
|
+
state_management:
|
|
52
|
+
global: useReducer # context | redux | zustand | useReducer
|
|
53
|
+
local: useState
|
|
54
|
+
refs: useRef # 게임 루프, Canvas ref
|
|
55
|
+
|
|
56
|
+
# 상태 분리 원칙
|
|
57
|
+
principles:
|
|
58
|
+
- "UI 리렌더링 필요한 상태 → useReducer"
|
|
59
|
+
- "빠른 업데이트 필요한 상태 → useRef"
|
|
60
|
+
- "Canvas DOM 참조 → useRef"
|
|
61
|
+
|
|
62
|
+
# 훅 규칙
|
|
63
|
+
hooks:
|
|
64
|
+
naming: "use{Name}"
|
|
65
|
+
location: src/hooks/
|
|
66
|
+
|
|
67
|
+
# 커스텀 훅 목록
|
|
68
|
+
custom:
|
|
69
|
+
- name: useGameLoop
|
|
70
|
+
purpose: requestAnimationFrame 기반 게임 루프
|
|
71
|
+
- name: useKeyboard
|
|
72
|
+
purpose: 키보드 입력 처리
|
|
73
|
+
- name: useSwipe
|
|
74
|
+
purpose: 터치 스와이프 감지
|
|
75
|
+
- name: useHighScore
|
|
76
|
+
purpose: localStorage 최고점수 관리
|
|
77
|
+
|
|
78
|
+
# 타입 정의 규칙
|
|
79
|
+
types:
|
|
80
|
+
location: src/types/
|
|
81
|
+
naming: PascalCase
|
|
82
|
+
|
|
83
|
+
# 핵심 타입
|
|
84
|
+
core:
|
|
85
|
+
- Point
|
|
86
|
+
- Direction
|
|
87
|
+
- GameStatus
|
|
88
|
+
- GameState
|
|
89
|
+
- GameAction
|
|
90
|
+
- GameConfig
|
|
91
|
+
|
|
92
|
+
# 상수 규칙
|
|
93
|
+
constants:
|
|
94
|
+
location: src/constants/
|
|
95
|
+
naming: SCREAMING_SNAKE_CASE
|
|
96
|
+
|
|
97
|
+
# 핵심 상수
|
|
98
|
+
core:
|
|
99
|
+
- GAME_CONFIG
|
|
100
|
+
- COLORS
|
|
101
|
+
- INITIAL_SNAKE
|
|
102
|
+
- DIRECTION_VECTORS
|
|
103
|
+
- OPPOSITE_DIRECTIONS
|
|
104
|
+
|
|
105
|
+
# 유틸리티 규칙
|
|
106
|
+
utilities:
|
|
107
|
+
location: src/utils/
|
|
108
|
+
naming: camelCase
|
|
109
|
+
|
|
110
|
+
# 유틸리티 함수
|
|
111
|
+
functions:
|
|
112
|
+
- generateRandomPosition
|
|
113
|
+
- isCollision
|
|
114
|
+
- isValidDirection
|
|
115
|
+
|
|
116
|
+
# 폴더 구조
|
|
117
|
+
folder_structure:
|
|
118
|
+
type: type-based # feature-based | type-based
|
|
119
|
+
|
|
120
|
+
structure:
|
|
121
|
+
src:
|
|
122
|
+
- components/ # React 컴포넌트
|
|
123
|
+
- hooks/ # 커스텀 훅
|
|
124
|
+
- engine/ # 게임 로직 (reducer, collision, renderer)
|
|
125
|
+
- types/ # TypeScript 타입
|
|
126
|
+
- constants/ # 상수
|
|
127
|
+
- utils/ # 유틸리티 함수
|
|
128
|
+
- styles/ # 글로벌 스타일
|
|
129
|
+
- assets/ # 정적 자산
|
|
130
|
+
|
|
131
|
+
# 파일 명명 규칙
|
|
132
|
+
file_naming:
|
|
133
|
+
components: PascalCase.tsx
|
|
134
|
+
hooks: camelCase.ts
|
|
135
|
+
types: index.ts # 단일 파일 또는 camelCase.ts
|
|
136
|
+
constants: camelCase.ts
|
|
137
|
+
utils: camelCase.ts
|
|
138
|
+
styles: index.css 또는 {Component}.module.css
|
|
139
|
+
|
|
140
|
+
# 임포트 규칙
|
|
141
|
+
imports:
|
|
142
|
+
order:
|
|
143
|
+
- react # React 관련
|
|
144
|
+
- external # 외부 라이브러리
|
|
145
|
+
- internal # 내부 모듈 (절대 경로)
|
|
146
|
+
- relative # 상대 경로
|
|
147
|
+
- styles # 스타일
|
|
148
|
+
- types # 타입
|
|
149
|
+
|
|
150
|
+
alias:
|
|
151
|
+
"@": src/
|
|
152
|
+
|
|
153
|
+
# 코드 품질
|
|
154
|
+
code_quality:
|
|
155
|
+
eslint: true
|
|
156
|
+
prettier: true
|
|
157
|
+
typescript_strict: true
|
|
158
|
+
|
|
159
|
+
rules:
|
|
160
|
+
- "no-any: 가능한 한 any 타입 사용 금지"
|
|
161
|
+
- "explicit-return-types: 함수 반환 타입 명시"
|
|
162
|
+
- "no-unused-vars: 미사용 변수 금지"
|
|
163
|
+
|
|
164
|
+
# 테스트 규칙
|
|
165
|
+
testing:
|
|
166
|
+
framework: vitest
|
|
167
|
+
location: src/__tests__/ 또는 컴포넌트 옆 {name}.test.ts
|
|
168
|
+
|
|
169
|
+
coverage_target: 80%
|
|
170
|
+
|
|
171
|
+
naming:
|
|
172
|
+
unit: "{name}.test.ts"
|
|
173
|
+
e2e: "{feature}.e2e.ts"
|
|
174
|
+
|
|
175
|
+
# 성능 규칙
|
|
176
|
+
performance:
|
|
177
|
+
# Canvas 최적화
|
|
178
|
+
canvas:
|
|
179
|
+
- "requestAnimationFrame 사용"
|
|
180
|
+
- "오프스크린 캔버스 고려"
|
|
181
|
+
- "불필요한 리렌더링 방지"
|
|
182
|
+
|
|
183
|
+
# React 최적화
|
|
184
|
+
react:
|
|
185
|
+
- "React.memo 필요시 사용"
|
|
186
|
+
- "useCallback/useMemo 과도한 사용 자제"
|
|
187
|
+
- "게임 상태는 useRef로 관리"
|
|
188
|
+
|
|
189
|
+
# Git 커밋 규칙
|
|
190
|
+
git:
|
|
191
|
+
conventional_commits: true
|
|
192
|
+
|
|
193
|
+
types:
|
|
194
|
+
feat: 새 기능
|
|
195
|
+
fix: 버그 수정
|
|
196
|
+
refactor: 리팩토링
|
|
197
|
+
test: 테스트
|
|
198
|
+
docs: 문서
|
|
199
|
+
style: 포맷팅
|
|
200
|
+
chore: 기타
|
|
201
|
+
|
|
202
|
+
# 금지 사항
|
|
203
|
+
prohibited:
|
|
204
|
+
- "외부 게임 엔진 (Phaser, PixiJS 등)"
|
|
205
|
+
- "jQuery"
|
|
206
|
+
- "Class 컴포넌트 (함수형만 사용)"
|
|
207
|
+
- "any 타입 남용"
|
|
208
|
+
- "전역 변수"
|
|
209
|
+
- "setInterval (requestAnimationFrame 대신 사용)"
|