Skip to content

実装: 自機移動と Projectile 射撃システム #1

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: none
goal_ref: "movement + projectile 最小ループ(WASD 移動・PointerEvent 射撃・60Hz fixed timestep・Projectile Canvas 描画)の deterministic な MVP を成立させる"
change_kind: code
spec_ssot:
  - docs/product/features/movement-projectile.md
runtime_verification_applicability: deferred

Parent Issue

なし(M1: Foundation Gate の単独 implementation Issue。仕様正本は #2 で main へ確定済みの feature spec docs/product/features/movement-projectile.md)

Parent Goal Ref

  • Goal: 戦闘の最小単位「動く」と「撃つ」を deterministic な fixed timestep ループ上で成立させ、後続 collision / damage 実装の前提となる入力・state・描画契約を固定する
  • Desired Destination: src/state / src/systems / src/render の責務境界を保ったまま、feature spec docs/product/features/movement-projectile.md の AC が実装上で観測可能になる

Implementation Source of Truth

本 Issue は次の feature spec の実装契約である。Issue 本文と feature spec が衝突した場合は feature spec を正とする。

anchor decision: #1 review comment 2026-05-28

Current Validated Scope

  • src/state/GameState.ts に ProjectileState 型と projectiles: ProjectileState[] / nextProjectileId: number を追加
  • src/systems/MovementSystem.ts に boundary clamp と斜め入力正規化を実装
  • src/systems/CombatSystem.ts を fire intent → cooldown 管理 → GameState.projectiles への spawn に限定(progress.resources 非 mutate)
  • src/systems/ProjectileSystem.ts(新規)で direction * speed * dt 移動と lifetime / 境界外削除
  • src/main.ts の fixed timestep ループに panic clamp 残余破棄と ProjectileSystem 統合
  • src/input/(新規 adapter 層、anchor reframe)で KeyboardEvent.code と PointerEvent lifecycle(setPointerCapture / pointercancel / lostpointercapture)を担当
  • src/render/CanvasRenderer.ts に devicePixelRatio 対応と Projectile 描画
  • tests/ に movement / combat / projectile / input-mapper の deterministic ユニットテスト
  • canvas に CSS touch-action: none 適用(index.html または src/style.css の最小編集)

Remaining Parent Gaps

  • collision / damage 実装は本 Issue で実装しない(後続 implementation Issue)
  • docs/product/game-logic.md 71 行目の AimIntent.angle 例示修正(feature spec で follow-up 指定済み)
  • enemy AI / 強化 UI / 戦果画面 / 武器データ外部化 / multi-touch
  • balance tuning(projectile_speed_px_per_sec / projectile_lifetime_ms 等の最適値)

Initial Constants for #1

feature spec open_questions のうち #1 実装で固定するもの。Balance tuning は後続 Issue で扱う。

識別子 値
player_speed_px_per_sec 既存 GameState.player.speed = 210 を流用
player_radius_px 既存 GameState.player.radius = 14 を流用
fire_cooldown_ms 既存 weaponIntervalMs = 280 を流用
arena_width_px / arena_height_px 既存 GameState.arena を流用
projectile_speed_px_per_sec 520
projectile_lifetime_ms 1200
projectile_radius_px 4
projectile_out_of_bounds_margin_px 8
aim_epsilon_px 0.001
spawn_origin_offset 自機中心(offset なし)
aim at same position fallback 直前 frame の非ゼロ aim 方向を保持。初期値が無い場合は +X 方向

Outcome

src/state / src/systems / src/render の責務境界を保ったまま、WASD 入力で自機が arena 内を移動し、primary PointerEvent の hold-to-repeat で GameState.projectiles に Projectile が spawn・直進・寿命/境界外で削除され、CanvasRenderer が自機・照準線・Projectile を描画する状態。pnpm typecheck && pnpm lint && pnpm test && pnpm build が PASS する。

成果物: src/state/GameState.ts, src/systems/MovementSystem.ts, src/systems/CombatSystem.ts, src/systems/ProjectileSystem.ts (新規), src/render/CanvasRenderer.ts, src/main.ts, src/input/(新規 adapter), および tests/ 配下の 4 テストファイル(下記)の追加・拡充。

In Scope

  • src/state/GameState.ts への ProjectileState 追加
  • MovementSystem の boundary clamp と斜め入力正規化
  • CombatSystem の fire / cooldown / Projectile spawn(resources 非 mutate)
  • 新規 ProjectileSystem の移動・削除
  • 新規 src/input/ adapter(KeyboardEvent.code + PointerEvent lifecycle)
  • src/main.ts の panic clamp 残余破棄と ProjectileSystem 統合
  • CanvasRenderer の devicePixelRatio 対応と Projectile 描画
  • 4 件の unit test 追加・拡充

Out of Scope

  • collision 判定(弾と敵の衝突検知)
  • damage / HP 演算
  • enemy AI / 味方 AI
  • visual effects(ヒットストップ、パーティクル、画面振動、音、着弾エフェクト)
  • 戦果画面 / 強化 UI
  • 武器データの外部化(複雑な weapon data)
  • multi-touch 対応
  • arena サイズの可変化(後続 stage feature の責務)
  • docs/product/game-logic.md AimIntent.angle 例示の修正(別 Issue)

Acceptance Criteria

  • AC1: simulation は 60Hz 固定タイムステップ(fixedDeltaMs ≈ 16.667)のアキュムレータで進行する
  • AC2: 1 animation frame あたりの catch-up step は maxFrameSkip(既定 5)で上限化される
  • AC3: maxFrameSkip 到達時に accumulatorMs の >= fixedDeltaMs 残余は破棄され、次 frame には accumulatorMs < fixedDeltaMs の通常残余のみ持ち越される(テスト可能な純関数 / ヘルパに切り出し)
  • AC4: cooldown は simulation tick 時間で管理され、Date.now() / performance.now() / wall clock に依存しない
  • AC5: WASD は KeyboardEvent.code(KeyW / KeyA / KeyS / KeyD)で取得し InputCommand に正規化される
  • AC6: 斜め入力はベクトル正規化により 8 方向で速度が均等になる
  • AC7: 自機中心は [player_radius_px, arena_size - player_radius_px] に boundary clamp される
  • AC8: aim の source of truth は { x, y } arena logical 座標。角度は GameState / InputCommand に保持しない
  • AC9: pointerdown は event.isPrimary === true かつ event.button === 0 のみ受け付け、canvas.setPointerCapture(pointerId) で capture する
  • AC10: capture 中の pointerId に一致する pointermove のみ aim を更新する
  • AC11: pointerup / pointercancel / lostpointercapture で primaryPressed = false とし fire hold を終了する
  • AC12: canvas interaction target に CSS touch-action: none が指定されている
  • AC13: primary pointer hold 中はクールダウン完了ごとに自動連射される
  • AC14: aim と自機中心の差が aim_epsilon_px 未満の場合は前 frame の非ゼロ aim 方向にフォールバックする(無ければ +X)。zero-length ベクトルから NaN が伝播しない
  • AC15: GameState.projectiles: ProjectileState[] と monotonic GameState.nextProjectileId が追加され、ProjectileState は id / x / y / radius / directionX / directionY / speedPxPerSec / ageMs / lifetimeMs を持つ
  • AC16: CombatSystem は fire 実行時に GameState.projectiles へ Projectile を push し cooldown を reset する。progress.resources を mutate せず damage を発生させない
  • AC17: ProjectileSystem は各 Projectile を direction * speed_px_per_sec * fixed_dt で進める
  • AC18: ProjectileSystem は ageMs >= lifetimeMs または arena 境界外(projectile_out_of_bounds_margin_px 含む)の Projectile を削除する。残存要素の順序が deterministic
  • AC19: CanvasRenderer は devicePixelRatio を考慮して backing store を拡大し描画 context を scale する
  • AC20: System 層(src/state / src/systems)は devicePixelRatio を読まない
  • AC21: メインループの fixed tick 順は MovementSystem → CombatSystem → ProjectileSystem → CollisionSystem → tick/elapsedMs で、CombatSystem で spawn された Projectile は同 tick の ProjectileSystem で進む
  • AC22: pnpm typecheck && pnpm lint && pnpm test && pnpm build が PASS する

Verification Commands

# AC1
$ pnpm test

# AC2
$ pnpm test

# AC3
$ rg -n "accumulatorMs % fixedDeltaMs|residualMs|panic.*discard|panic.*clamp.*reset" src/main.ts src/state

# AC4
$ pnpm test

# AC5
$ rg -n "KeyW|KeyA|KeyS|KeyD" src tests

# AC6
$ pnpm test

# AC7
$ pnpm test

# AC8
$ pnpm test

# AC9
$ rg -n "setPointerCapture" src

# AC10
$ pnpm test

# AC11
$ rg -n "pointercancel|lostpointercapture" src

# AC12
$ rg -n "touch-action" src/style.css index.html

# AC13
$ pnpm test

# AC14
$ rg -n "aim_epsilon|AIM_EPSILON|aimEpsilon" src/systems

# AC15
$ rg -n "ProjectileState|nextProjectileId" src/state/GameState.ts

# AC16
$ pnpm test

# AC17
$ test -f src/systems/ProjectileSystem.ts

# AC18
$ test -f tests/projectile-system.test.ts

# AC19
$ rg -n "devicePixelRatio" src/render/CanvasRenderer.ts

# AC20
$ pnpm test

# AC21
$ rg -n "ProjectileSystem" src/main.ts

# AC22
$ pnpm typecheck
$ pnpm lint
$ pnpm test
$ pnpm build

Required Tests

tests/movement-system.test.ts:

  • player_speed_px_per_sec で fixed delta 移動
  • 斜め入力の正規化
  • 左 / 上 / 右 / 下の boundary clamp
  • 通常より大きい deltaMs 後の clamp
  • invalid arena(player_radius_px > arena_width_px / 2 等)の防御的扱い

tests/combat-system.test.ts:

  • aim を InputCommand.aim から {x, y} で更新する
  • GameState / InputCommand に angle を保持しない
  • cooldown 完了時の fire で GameState.projectiles に Projectile が push される
  • cooldown 中は spawn が抑止される
  • simulation delta で cooldown が減算される
  • progress.resources を mutate しない
  • same-position aim fallback(前 aim 保持 / 初期 +X)

tests/projectile-system.test.ts(新規):

  • 正規化方向 × projectile_speed_px_per_sec × dt で進む
  • ageMs が加算される
  • lifetimeMs 経過で削除される
  • arena 境界外 + margin で削除される
  • 残存要素の順序が deterministic

tests/input-mapper.test.ts(新規):

  • KeyboardEvent.code が KeyW/KeyA/KeyS/KeyD にマップされる
  • primary pointer / 左ボタンのみ受け付ける
  • captured pointerId のみ aim を更新する
  • pointercancel で primaryPressed がクリアされる
  • lostpointercapture で primaryPressed がクリアされる

Allowed Paths

  • src/state/GameState.ts
  • src/systems/MovementSystem.ts
  • src/systems/CombatSystem.ts
  • src/systems/ProjectileSystem.ts(新規)
  • src/render/CanvasRenderer.ts
  • src/main.ts
  • src/input/(新規 adapter 層、anchor reframe)
  • tests/movement-system.test.ts
  • tests/combat-system.test.ts
  • tests/projectile-system.test.ts(新規)
  • tests/input-mapper.test.ts(新規)
  • index.html または src/style.css(canvas touch-action: none の最小編集)

Scope Delta(PR #444 で追加)

AC3「panic clamp 残余破棄をテスト可能な純関数 / ヘルパに切り出し」実現のため、Issue contract の意図と整合する範囲で以下 3 件を追加 Allowed Paths とする:

  • src/systems/SimulationLoop.ts(新規 — runFixedTimestep 純関数)
  • src/systems/index.ts(上記の barrel 追記)
  • tests/main-loop.test.ts(新規 — AC3 unit test。Required Tests 末尾で既に言及)

Runtime Verification Applicability

decision: deferred
reason: >
  AC は決定論的単体テスト(fixed timestep / pure systems)で網羅検証可能。
  Canvas / Pointer 連動の体感確認は feature spec PH-1〜PH-4 として
  後続 playtest issue で扱う(docs/dev/runtime-verification-policy.md)。
deferred_destination:
  destination_type: phase
  destination_ref: M1 Foundation Gate playtest(feature spec PH-1〜PH-4 検証 issue を別途起票)

Stop Conditions

実装中に次の状況が発生したら直ちに作業を停止し、Issue comment に状況を記録して人間判断を待つ。

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(AC・Initial Constants・System 責務境界)の変更が必要になった場合
  • 別 Issue 起票が必要と判断した場合(collision / damage / enemy AI への波及など)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合

Required Skills

  • TypeScript(strict mode)
  • Vitest によるユニットテスト
  • HTML5 Canvas 2D API(devicePixelRatio 対応)
  • PointerEvent / KeyboardEvent(pointer capture, event.code semantics)
  • ECS 風 state / systems 分離アーキテクチャ

Delivery Rule

  • 1 Issue = 1 PR
  • Draft PR で開始し、AC 全件 PASS 後に Ready for Review
  • 実装計画の追加承認は不要。本 Issue contract(Outcome / AC / VC / Allowed Paths)を実装計画の正本として扱う(docs/dev/workflow.md)

Activity

  1. added
    enhancement
    on May 16, 2026
  2. added 2 commits that reference this issue on May 22, 2026
  3. squne121 commented on May 28, 2026

    @squne121
    OwnerAuthor

    判定

    REQUEST CHANGES 相当。
    #1 の方向性自体は妥当ですが、現状の #1 本文だけを実装契約として使うと、後続で整備された #2 / #440 の仕様と現在コードの実態を取り逃がします。#1 は「WASD 移動・pointerdown 射撃・60Hz fixed timestep・Projectile の Canvas 描画」を要求していますが、実装仕様の正本は後から #2 / #440 で docs/product/features/movement-projectile.md に切り出されています。#1 側にその back-reference がないため、実装者が古い Issue 本文だけで作業すると仕様ドリフトします。([GitHub]1)

    関連 PR #440 では、初期 approve 後に「panic clamp」「AimIntent の source of truth」「速度識別子」「pointer capture」などの意味論的な欠陥が REQUEST CHANGES で指摘され、その後修正されて main に merge されています。つまり、#1 は #440 で確定した仕様を実装 Issue に再注入してから着手すべきです。([GitHub]2)


    Blocker 1: #1 が現在の仕様正本を参照していない

    #1 は Projectile 実装の範囲と AC を書いていますが、Projectile speed、lifetime、arena size、same-position aim fallback、PointerEvent の終了条件など、実装で必ず決める必要がある値や振る舞いが曖昧です。#2 は「#1 の前提として movement + projectile feature spec を固定する」ための Issue で、#1 実装は out of scope、#1 本文からの back-reference は follow-up とされています。([GitHub]1)

    修正要求: #1 本文の冒頭に次を追加してください。

    Implementation source of truth:
    - docs/product/features/movement-projectile.md
    - This issue implements that contract; if this issue body conflicts with the feature spec, the feature spec wins.

    さらに #1 の AC は、現在の feature spec に合わせて KeyboardEvent.code、PointerEvent primary pointer / capture / cancel / lostpointercapture、simulation-time cooldown、projectile state schema、DPR-aware Canvas rendering を明記するべきです。([GitHub]3)


    Blocker 2: current main loop の panic clamp が仕様と衝突している

    現在の main.ts は while (accumulatorMs >= fixedDeltaMs && frameSkips < maxFrameSkip) で 1 frame 内の catch-up 回数を制限していますが、上限に達した後の backlog を破棄していません。つまり、重い frame の後も巨大な accumulatorMs が残り、次 frame 以降も catch-up が継続します。これは #440 で指摘された「panic clamp residual carry」問題そのものです。([GitHub]4)

    feature spec は「通常の accumulator remainder だけを持ち越し、panic clamp 超過分は捨てる」としています。fixed timestep の古典的な設計でも、simulation が追いつけない場合は spiral of death を避けるため、1 frame あたりの最大 simulation step を制限し、重い状況では見かけ上スローになる方が安全です。([GitHub]3)

    修正要求: #1 の実装 AC に次を追加。

    When accumulator catch-up reaches maxFrameSkip, discard accumulated overage.
    Only the normal sub-fixedDelta remainder may be carried to the next frame.

    実装例は概念的には以下です。

    if (frameSkips === maxFrameSkip && accumulatorMs >= fixedDeltaMs) {
      accumulatorMs = accumulatorMs % fixedDeltaMs;
    }

    この挙動は closure 内に閉じず、純粋関数またはテスト可能な loop helper として切り出してください。そうしないと回帰テストが書けません。


    Blocker 3: input contract が current code と merged spec でズレている

    現在の入力処理は event.key で w/a/s/d を見ています。しかし merged spec は KeyboardEvent.code を要求しています。ゲーム入力で WASD を物理キーとして扱うなら、キーボード配列差、たとえば AZERTY などを考慮して code を使うのが妥当です。MDN もゲームの WASD 例では、同じ物理キーを使うため KeyboardEvent.code を使うべきと説明しています。([GitHub]4)

    Pointer 入力も未完成です。現在は canvas の pointermove / pointerdown と window の pointerup だけで、setPointerCapture、pointercancel、lostpointercapture、primary pointer 判定、touch-action: none がありません。Pointer capture は capture した要素へ後続 pointer event を送る仕組みで、pointercancel はブラウザがスクロール・ズーム等を開始した場合にも発火します。touch device 対応を崩さないため、この契約は省略できません。([GitHub]4)

    修正要求: DOM binding を main.ts に直書きし続けるのではなく、少なくとも pointer lifecycle をテスト可能な adapter に切り出してください。

    期待挙動:

    pointerdown:
      if event.isPrimary && event.button === 0:
        activePointerId = event.pointerId
        canvas.setPointerCapture(event.pointerId)
        primaryPressed = true
    
    pointermove:
      if event.pointerId === activePointerId:
        update aim logical coordinate
    
    pointerup / pointercancel / lostpointercapture:
      if event.pointerId === activePointerId:
        activePointerId = null
        primaryPressed = false

    CSS 側は canvas に touch-action: none を指定するべきです。MDN も touch-action によりブラウザの既定タッチ動作を制御できると説明しています。([MDN Web Docs]5)


    Blocker 4: CombatSystem が Projectile ではなく resource を増やしている

    現在の CombatSystem は fire 時に shotsFired を増やし、さらに progress.resources += weaponPower を実行しています。#1 の non-goal は damage、result screen、upgrade UI、complex weapon data を明示的に除外しており、merged spec でも CombatSystem の責務は Projectile spawn と cooldown に寄せられています。([GitHub]6)

    これは設計上かなり危険です。射撃ボタンを押すだけで resource が増える現行挙動を残したまま Projectile を追加すると、「Projectile は見た目だけで、実際の戦果は CombatSystem が即時付与する」という二重モデルになります。後で collision / damage を入れると破綻します。

    修正要求: #1 の実装では fire の副作用を次に限定してください。

    - decrement cooldown by simulation delta
    - if fire requested and cooldown <= 0:
      - spawn Projectile into GameState.projectiles
      - reset cooldown
      - increment shotsFired only if telemetryとして必要
    - must not mutate progress.resources
    - must not apply damage

    Blocker 5: GameState に Projectile の正規 schema がない

    現在の GameState は arena、player、progress、telemetry を持ちますが、projectiles や nextProjectileId がありません。merged spec は GameState.projectiles と monotonic counter を要求しています。([GitHub]7)

    推奨 schema:

    export interface ProjectileState {
      id: number;
      x: number;
      y: number;
      radius: number;
      directionX: number;
      directionY: number;
      speedPxPerSec: number;
      ageMs: number;
      lifetimeMs: number;
    }
    
    export interface GameState {
      // existing fields...
      projectiles: ProjectileState[];
      nextProjectileId: number;
    }

    禁止事項:

    Date.now()
    performance.now()
    Math.random()
    crypto.randomUUID()

    Projectile ID と lifetime は simulation state から決定し、wall-clock や乱数に依存させない方が deterministic test を書けます。


    Blocker 6: CanvasRenderer が DPR-aware ではない

    現在の CanvasRenderer は canvas.width = state.arena.width、canvas.height = state.arena.height とし、logical arena size をそのまま backing store size にしています。merged spec は「simulation は logical pixels、devicePixelRatio は renderer が扱う」としています。高 DPI canvas の一般実装では、CSS 上の表示サイズと devicePixelRatio を使って backing store を拡大し、描画 context を scale します。([GitHub]8)

    修正要求: renderer の責務を次のように固定してください。

    - GameState coordinates are arena logical pixels.
    - Pointer client coordinates are converted into arena logical pixels.
    - CanvasRenderer maps logical pixels to device pixels using devicePixelRatio.
    - Systems must never read devicePixelRatio.

    Projectile 描画は state.projectiles を走査して円または短い streak として描画すれば十分です。FX は #1 の non-goal なので不要です。([GitHub]1)


    Major: MovementSystem の clamp と test が不足している

    現在の MovementSystem は axis normalization と速度反映はしていますが、arena boundary clamp がありません。#1 は「player が Canvas 内に clamp される」ことを AC にしています。([GitHub]9)

    既存 test は右移動の基本ケースのみで、境界、左上、右下、巨大 dt、斜め入力後の clamp を検証していません。merged spec は boundary clamp 関連テストを明示しています。([GitHub]10)

    追加テスト必須:

    MovementSystem:
    - normalizes diagonal input
    - clamps left/top by player.radius
    - clamps right/bottom by arena size - player.radius
    - clamps after large deltaMs
    - handles zero / invalid arena defensively, or rejects via invariant

    Major: Projectile update order を明文化すべき

    現在の loop order は MovementSystem -> CombatSystem -> CollisionSystem -> tick です。#1 で ProjectileSystem を追加するなら、spawn された Projectile を同 tick で動かすのか、次 tick から動かすのかを決める必要があります。ここを曖昧にすると、初弾位置、snapshot test、将来の collision timing がブレます。([GitHub]4)

    推奨は次です。

    Per fixed simulation tick:
    1. MovementSystem
    2. CombatSystem   // spawns projectile at player center
    3. ProjectileSystem // advances all projectiles, including newly spawned ones only if explicitly tested
    4. CollisionSystem // no projectile collision in #1
    5. tick / elapsedMs increment

    個人的には、CombatSystem で spawn した Projectile は同 tick の ProjectileSystem で進める方が実装は単純です。ただし test で「spawn 後 1 fixed tick 分だけ進む」ことを固定してください。


    Major: same-position aim fallback が未確定

    merged spec は aim source of truth を {x, y} logical arena coordinate に固定していますが、player center と aim point が同一だった場合の fallback は open question のままです。([GitHub]3)

    推奨: 次のように固定してください。

    If aim point equals player center within AIM_EPSILON:
    - use previous non-zero aim direction
    - if no previous aim direction exists, use +X direction

    これにより zero-length vector の NaN 化を防げます。


    #1 に入れるべき具体的な修正案

    ## Implementation source of truth
    
    This issue implements:
    
    - docs/product/features/movement-projectile.md
    
    If this issue body conflicts with the feature spec, the feature spec wins.
    
    ## Initial constants for #1
    
    - player_speed_px_per_sec: existing 210
    - player_radius_px: existing 14
    - fire_cooldown_ms: existing 280
    - projectile_speed_px_per_sec: 520
    - projectile_lifetime_ms: 1200
    - projectile_radius_px: 4
    - projectile_out_of_bounds_margin_px: 8
    - aim_epsilon_px: 0.001
    
    ## Revised acceptance criteria
    
    - Simulation uses 60Hz fixed timestep.
    - Panic clamp executes at most maxFrameSkip simulation steps per animation frame and discards catch-up overage.
    - Movement uses KeyboardEvent.code-derived semantic input.
    - Diagonal movement is normalized.
    - Player is clamped inside arena using player radius.
    - Pointer aim uses logical arena coordinates.
    - Primary pointerdown starts fire intent and captures pointer.
    - pointerup / pointercancel / lostpointercapture clears fire intent.
    - Holding primary pointer repeats fire according to simulation-time cooldown.
    - CombatSystem spawns ProjectileState into GameState.projectiles.
    - CombatSystem does not mutate progress.resources or apply damage.
    - ProjectileSystem advances projectiles by direction * speed * fixed dt.
    - ProjectileSystem removes projectiles by lifetime or out-of-arena.
    - CanvasRenderer renders player, aim line, and projectiles.
    - CanvasRenderer owns devicePixelRatio handling; systems use logical pixels only.
    - pnpm typecheck, pnpm lint, pnpm test, pnpm build pass.

    既存 state の player speed、radius、cooldown は現在コード上に既に存在するので、#1 ではそれを再利用できます。Projectile speed / lifetime / radius は #1 で明示しないと実装者判断になり、後続レビューで不毛な差し戻しになります。([GitHub]7)


    必須テストセット

    MovementSystem:
    - moves at player_speed_px_per_sec under fixed delta
    - normalizes diagonal movement
    - clamps left/top/right/bottom
    - clamps after large deltaMs
    
    CombatSystem:
    - updates aim from InputCommand aim x/y
    - does not store angle in GameState/InputCommand
    - spawns projectile on fire when cooldown <= 0
    - suppresses spawn during cooldown
    - uses simulation delta for cooldown
    - does not mutate progress.resources
    - handles same-position aim fallback
    
    ProjectileSystem:
    - advances projectile by normalized direction * projectile_speed * dt
    - increments ageMs
    - removes projectile after lifetime
    - removes projectile when out-of-arena
    - preserves deterministic order for remaining projectiles
    
    Input / DOM adapter:
    - KeyboardEvent.code maps KeyW/KeyA/KeyS/KeyD
    - pointerdown only accepts primary pointer / left button
    - pointermove updates aim only for captured pointer
    - pointercancel clears primaryPressed
    - lostpointercapture clears primaryPressed
    
    Renderer:
    - draws all projectiles from GameState.projectiles
    - keeps simulation coordinates independent from devicePixelRatio

    現在の tests には projectile-system.test.ts が存在せず、movement test も基本移動のみです。#1 の完了条件にするには不足です。([GitHub][11])


    最終レビューコメント案

    REQUEST CHANGES
    
    #1 は方向性として妥当だが、現時点の Issue 本文は実装契約として古い。
    #2 / #440 で movement-projectile feature spec が main に merge 済みなので、
    #1 は docs/product/features/movement-projectile.md を正本として参照する形に更新してから実装するべき。
    
    特に以下は blocker:
    
    1. #1 本文が merged feature spec を参照していない。
    2. current main loop は maxFrameSkip 後の accumulator overage を破棄しておらず、panic clamp 契約に反する。
    3. current input は KeyboardEvent.code ではなく event.key を使っている。
    4. pointer capture / pointercancel / lostpointercapture / touch-action:none が未設計。
    5. CombatSystem が fire 時に progress.resources を増やしており、Projectile spawn 契約と衝突する。
    6. GameState に projectiles / nextProjectileId がない。
    7. CanvasRenderer が devicePixelRatio handling を持たない。
    8. clamp / projectile / pointer lifecycle の test が不足している。
    
    この Issue は「Projectile を見えるようにする」だけでなく、
    後続の collision/damage 実装の前提となる deterministic simulation contract を固定する作業として扱うべき。

    結論として、#1 は **「実装してよい Issue」ではなく、「#440 の仕様を取り込んでから実装する Issue」**です。実装 PR を出すなら、上の blocker を PR scope に含めない限り差し戻しが妥当です。

    [11]: https://github.com/squne121/loop-protocol/tree/main/tests "loop-protocol/tests at main · squne121/loop-protocol · GitHub"****

  4. squne121 commented on May 28, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop 完了

    termination_reason: approved
    iterations: 2(iteration 0 → needs-fix → iteration 1 → approve)
    anchor: #1 review comment 2026-05-28(OWNER, classification: feedback_update_required / scope_impact: amend、anchor reframe で src/input/ 新規層を allowed)

    Deterministic checks(13/13 pass)

    check result
    C1 required_sections pass
    C2 stop_conditions_6 pass
    C3 ac_checkbox_format pass
    C4 vc_commands_present pass
    C5 ac_vc_number_alignment pass
    C6 no_subjective_phrasing pass
    C7 required_skills_semantics pass
    C8 outcome_concreteness pass
    C9 runtime_applicability_present pass
    C10 deferred_destination_present pass
    C11 decision_tag_consistency pass
    C12 product_trace_fields_structure n/a
    C13 vc_preflight_decision_consistency n/a

    反映した anchor フィードバック

    • Implementation source of truth として docs/product/features/movement-projectile.md を本文先頭で固定(PR docs(#2): movement + projectile 最小仕様を feature spec として固定する #440 で main 確定済み)
    • 22 件の AC へ rewrite(panic clamp 残余破棄 / KeyboardEvent.code / PointerEvent capture+cancel+lostpointercapture / touch-action: none / CombatSystem の progress.resources 非 mutate / GameState.projectiles & nextProjectileId schema / DPR は renderer 責務)
    • VC に AC1〜AC22 すべての # AC<N> ブロックを deterministic コマンドで紐付け
    • Initial Constants ブロックで feature spec open_questions のうち #1 実装値を固定(projectile_speed_px_per_sec=520 / projectile_lifetime_ms=1200 / projectile_radius_px=4 / out_of_bounds_margin_px=8 / aim_epsilon_px=0.001)
    • aim same-position fallback の方針(前 frame の非ゼロ aim 保持 → 無ければ +X)を明文化
    • Allowed Paths に src/input/(新規 adapter 層、anchor reframe)を含めた
    • Runtime Verification Applicability: deferred / destination_type: phase / playtest PH-1〜PH-4 を後続 issue 起票へ委譲

    scope rollup / follow-up materialization

    次のステップ

    本 Issue は issue-contract-review を通せば実装着手可能な状態。/impl-review-loop 1 で実装ループへ進める。

  5. changed the title [-]自機移動と Projectile 射撃システムを実装する[/-] [+]実装: 自機移動と Projectile 射撃システム[/+] on May 28, 2026
  6. squne121 commented on May 28, 2026

    @squne121
    OwnerAuthor

    Contract Snapshot (2026-05-28T10:12:45Z)

    • Outcome: WASD 移動・PointerEvent 射撃・60Hz fixed timestep・Projectile Canvas 描画の deterministic MVP
    • Acceptance Criteria: AC1〜AC22(本文参照)
    • Verification Commands: AC1〜AC22 ごとに # AC<N> で紐付け(本文参照)
    • Allowed Paths: src/state/GameState.ts, src/systems/{Movement,Combat,Projectile}System.ts, src/render/CanvasRenderer.ts, src/main.ts, src/input/, tests/{movement,combat,projectile,input-mapper}-system.test.ts, index.html / src/style.css
    • Worktree: .claude/worktrees/issue-1-jiki-ido-to-projectile-shageki-system
    • Branch: worktree-issue-1-jiki-ido-to-projectile-shageki-system
    • VC preflight: baseline fail = 11, 想定外 pass = 0, 実行不可 = 0
    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: '2026-05-28T10:12:45Z'
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/1
      checks:
        template_compliance: pass
        state_label: ok
        allowed_paths_present: pass
        vc_present: pass
        stop_conditions_complete: pass
        vc_preflight:
          passed: true
          vc_failed_as_expected: 11
          vc_passed_unexpectedly: 0
          vc_unrunnable: 0
          vc_expected_pass: 14
          vc_skipped: 0
          classifications:
          - ac: AC1
            command: pnpm test
            exit_code: 0
            category: regression_gate
            scope_class: regression_gate
            confidence: low
            evidence:
              stdout_excerpt: " RUN  v4.1.6 /home/squne/projects/LOOP_PROTOCOL\n Test Files  7 passed (7)\n      Tests  75 passed (75)"
              stderr_excerpt: $ vitest run
            decision: go
          - ac: AC2
            command: pnpm test
            exit_code: 0
            category: regression_gate
            scope_class: regression_gate
            confidence: low
            evidence:
              stdout_excerpt: " RUN  v4.1.6 /home/squne/projects/LOOP_PROTOCOL\n Test Files  7 passed (7)\n      Tests  75 passed (75)"
              stderr_excerpt: $ vitest run
            decision: go
          - ac: AC3
            command: rg -n "accumulatorMs % fixedDeltaMs|residualMs|panic.*discard|panic.*clamp.*reset" src/main.ts src/state
            exit_code: 1
            category: expected_baseline_fail
            scope_class: baseline_fail_expected
            confidence: high
            evidence:
              stdout_excerpt: ''
              stderr_excerpt: ''
            decision: go
          - ac: AC4
            command: pnpm test
            exit_code: 0
            category: regression_gate
            scope_class: regression_gate
            confidence: low
            evidence:
              stdout_excerpt: " RUN  v4.1.6 /home/squne/projects/LOOP_PROTOCOL\n Test Files  7 passed (7)\n      Tests  75 passed (75)"
              stderr_excerpt: $ vitest run
            decision: go
          - ac: AC5
            command: rg -n "KeyW|KeyA|KeyS|KeyD" src tests
            exit_code: 1
            category: expected_baseline_fail
            scope_class: baseline_fail_expected
            confidence: high
            evidence:
              stdout_excerpt: ''
              stderr_excerpt: ''
            decision: go
          - ac: AC6
            command: pnpm test
            exit_code: 0
            category: regression_gate
            scope_class: regression_gate
            confidence: low
            evidence:
              stdout_excerpt: " RUN  v4.1.6 /home/squne/projects/LOOP_PROTOCOL\n Test Files  7 passed (7)\n      Tests  75 passed (75)"
              stderr_excerpt: $ vitest run
            decision: go
          - ac: AC7
            command: pnpm test
            exit_code: 0
            category: regression_gate
            scope_class: regression_gate
            confidence: low
            evidence:
              stdout_excerpt: " RUN  v4.1.6 /home/squne/projects/LOOP_PROTOCOL\n Test Files  7 passed (7)\n      Tests  75 passed (75)"
              stderr_excerpt: $ vitest run
            decision: go
          - ac: AC8
            command: pnpm test
            exit_code: 0
            category: regression_gate
            scope_class: regression_gate
            confidence: low
            evidence:
              stdout_excerpt: " RUN  v4.1.6 /home/squne/projects/LOOP_PROTOCOL\n Test Files  7 passed (7)\n      Tests  75 passed (75)"
              stderr_excerpt: $ vitest run
            decision: go
          - ac: AC9
            command: rg -n "setPointerCapture" src
            exit_code: 1
            category: expected_baseline_fail
            scope_class: baseline_fail_expected
            confidence: high
            evidence:
              stdout_excerpt: ''
              stderr_excerpt: ''
            decision: go
          - ac: AC10
            command: pnpm test
            exit_code: 0
            category: regression_gate
            scope_class: regression_gate
            confidence: low
            evidence:
              stdout_excerpt: " RUN  v4.1.6 /home/squne/projects/LOOP_PROTOCOL\n Test Files  7 passed (7)\n      Tests  75 passed (75)"
              stderr_excerpt: $ vitest run
            decision: go
          - ac: AC11
            command: rg -n "pointercancel|lostpointercapture" src
            exit_code: 1
            category: expected_baseline_fail
            scope_class: baseline_fail_expected
            confidence: high
            evidence:
              stdout_excerpt: ''
              stderr_excerpt: ''
            decision: go
          - ac: AC12
            command: rg -n "touch-action" src/style.css index.html
            exit_code: 1
            category: expected_baseline_fail
            scope_class: baseline_fail_expected
            confidence: high
            evidence:
              stdout_excerpt: ''
              stderr_excerpt: ''
            decision: go
          - ac: AC13
            command: pnpm test
            exit_code: 0
            category: regression_gate
            scope_class: regression_gate
            confidence: low
            evidence:
              stdout_excerpt: " RUN  v4.1.6 /home/squne/projects/LOOP_PROTOCOL\n Test Files  7 passed (7)\n      Tests  75 passed (75)"
              stderr_excerpt: $ vitest run
            decision: go
          - ac: AC14
            command: rg -n "aim_epsilon|AIM_EPSILON|aimEpsilon" src/systems
            exit_code: 1
            category: expected_baseline_fail
            scope_class: baseline_fail_expected
            confidence: high
            evidence:
              stdout_excerpt: ''
              stderr_excerpt: ''
            decision: go
          - ac: AC15
            command: rg -n "ProjectileState|nextProjectileId" src/state/GameState.ts
            exit_code: 1
            category: expected_baseline_fail
            scope_class: baseline_fail_expected
            confidence: high
            evidence:
              stdout_excerpt: ''
              stderr_excerpt: ''
            decision: go
          - ac: AC16
            command: pnpm test
            exit_code: 0
            category: regression_gate
            scope_class: regression_gate
            confidence: low
            evidence:
              stdout_excerpt: " RUN  v4.1.6 /home/squne/projects/LOOP_PROTOCOL\n Test Files  7 passed (7)\n      Tests  75 passed (75)"
              stderr_excerpt: $ vitest run
            decision: go
          - ac: AC17
            command: test -f src/systems/ProjectileSystem.ts
            exit_code: 1
            category: file_not_found_expected
            scope_class: baseline_fail_expected
            confidence: high
            evidence:
              stdout_excerpt: ''
              stderr_excerpt: ''
            decision: go
          - ac: AC18
            command: test -f tests/projectile-system.test.ts
            exit_code: 1
            category: file_not_found_expected
            scope_class: baseline_fail_expected
            confidence: high
            evidence:
              stdout_excerpt: ''
              stderr_excerpt: ''
            decision: go
          - ac: AC19
            command: rg -n "devicePixelRatio" src/render/CanvasRenderer.ts
            exit_code: 1
            category: expected_baseline_fail
            scope_class: baseline_fail_expected
            confidence: high
            evidence:
              stdout_excerpt: ''
              stderr_excerpt: ''
            decision: go
          - ac: AC20
            command: pnpm test
            exit_code: 0
            category: regression_gate
            scope_class: regression_gate
            confidence: low
            evidence:
              stdout_excerpt: " RUN  v4.1.6 /home/squne/projects/LOOP_PROTOCOL\n Test Files  7 passed (7)\n      Tests  75 passed (75)"
              stderr_excerpt: $ vitest run
            decision: go
          - ac: AC21
            command: rg -n "ProjectileSystem" src/main.ts
            exit_code: 1
            category: expected_baseline_fail
            scope_class: baseline_fail_expected
            confidence: high
            evidence:
              stdout_excerpt: ''
              stderr_excerpt: ''
            decision: go
          - ac: AC22
            command: pnpm typecheck
            exit_code: 0
            category: regression_gate
            scope_class: regression_gate
            confidence: low
            evidence:
              stdout_excerpt: ''
              stderr_excerpt: $ tsc --noEmit
            decision: go
          - ac: AC22
            command: pnpm lint
            exit_code: 0
            category: regression_gate
            scope_class: regression_gate
            confidence: low
            evidence:
              stdout_excerpt: ''
              stderr_excerpt: $ eslint .
            decision: go
          - ac: AC22
            command: pnpm test
            exit_code: 0
            category: regression_gate
            scope_class: regression_gate
            confidence: low
            evidence:
              stdout_excerpt: " RUN  v4.1.6 /home/squne/projects/LOOP_PROTOCOL\n Test Files  7 passed (7)\n      Tests  75 passed (75)"
              stderr_excerpt: $ vitest run
            decision: go
          - ac: AC22
            command: pnpm build
            exit_code: 0
            category: regression_gate
            scope_class: regression_gate
            confidence: low
            evidence:
              stdout_excerpt: "vite v8.0.13 building client environment for production...\n\e[2K\ntransforming...✓ 22 modules transformed."
              stderr_excerpt: $ tsc && vite build
            decision: go
        ac_verifiability: pass
        product_spec_check:
          applicability: not_applicable
          decision: pass
          triggers:
            docs_product_allowed_paths: false
            tasks_md_mentioned: false
            specify_artifact_mentioned: false
            generated_task_mentioned: false
            product_spec_context_present: false
          conditions:
            docs_product_requires_spec_evidence:
              status: pass
              evidence: []
            tasks_md_not_direct_source:
              status: pass
              evidence: []
            specify_not_canonical:
              status: pass
              evidence: []
            diff_first_rationale_present:
              status: pass
              evidence: []
            generated_task_trace_present:
              status: pass
              evidence: []
            task_dependencies_materialized:
              status: pass
              evidence: []
          blocked_reasons: []
        worktree_branch_collision: clear
      next_action: implement_issue
      blocked_reasons: []
      warnings: []
  7. squne121 commented on May 28, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-05-28T10:23:25Z)

    • PR: feat(#1): 自機移動と Projectile 射撃システム (AC1-AC22) #444
    • Worktree: .claude/worktrees/issue-1-jiki-ido-to-projectile-shageki-system
    • Branch: worktree-issue-1-jiki-ido-to-projectile-shageki-system
    • Verification: 4/4 PASS (typecheck / lint / test 124 passed / build)
    • 後続: PR レビュー(pr-review-judge)→ マージ → post-merge-cleanup
  8. added 2 commits that reference this issue on May 28, 2026
  9. added 2 commits that reference this issue on May 31, 2026
  10. added 2 commits that reference this issue on Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementphase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions