diff --git a/apps/client/src/entities/Player.ts b/apps/client/src/entities/Player.ts index b0dab8b..4546dde 100644 --- a/apps/client/src/entities/Player.ts +++ b/apps/client/src/entities/Player.ts @@ -1,4 +1,5 @@ import { Graphics } from 'pixi.js'; +import { GAME_CONFIG } from "@repo/shared/src/config/gameConfig"; export class Player extends Graphics { constructor(color: number = 0xFF0000) { @@ -9,8 +10,8 @@ // 移動メソッド move(vx: number, vy: number, deltaTime: number) { - // 速度 200 で移動 - const speed = 200 * deltaTime; + // 速度を定数から取得 + const speed = GAME_CONFIG.PLAYER_SPEED * deltaTime; this.x += vx * speed; this.y += vy * speed; diff --git a/apps/client/src/main.ts b/apps/client/src/main.ts index de0cf01..bb8cce3 100644 --- a/apps/client/src/main.ts +++ b/apps/client/src/main.ts @@ -1,6 +1,7 @@ import { Application } from 'pixi.js'; import { Joystick } from './input/Joystick'; import { Player } from './entities/Player'; +import { GAME_CONFIG } from '@repo/shared/src/config/gameConfig'; // アプリケーション初期化 const app = new Application(); @@ -27,7 +28,7 @@ // 4. ゲームループ (毎フレーム実行) app.ticker.add((ticker) => { // 秒単位の経過時間 (Delta Time) - const dt = ticker.deltaTime / 60; + const dt = ticker.deltaTime / GAME_CONFIG.TARGET_FPS; // ジョイスティックの入力があれば移動 if (joystick.input.x !== 0 || joystick.input.y !== 0) { diff --git a/packages/shared/src/config/gameConfig.ts b/packages/shared/src/config/gameConfig.ts index 987b7be..4139e4c 100644 --- a/packages/shared/src/config/gameConfig.ts +++ b/packages/shared/src/config/gameConfig.ts @@ -10,4 +10,7 @@ // プレイヤー設定 PLAYER_RADIUS: 20, // キャラの大きさ PLAYER_SPEED: 300, // 移動速度 (ピクセル/秒) + + // システム設定 + TARGET_FPS: 60, // 基準となるFPS } as const; \ No newline at end of file