diff --git a/apps/client/src/entities/Player.ts b/apps/client/src/entities/Player.ts new file mode 100644 index 0000000..1652e75 --- /dev/null +++ b/apps/client/src/entities/Player.ts @@ -0,0 +1,22 @@ +import { Graphics } from 'pixi.js'; +import { GAME_CONFIG } from 'skill-semi-web-game-shared'; + +export class Player extends Graphics { + constructor(color: number = 0xFF0000) { + super(); + // プレイヤーを描画 + this.circle(0, 0, GAME_CONFIG.PLAYER_RADIUS).fill(color); + } + + // 移動メソッド + move(vx: number, vy: number, deltaTime: number) { + // 速度 * 時間 = 移動距離 + const speed = GAME_CONFIG.PLAYER_SPEED * deltaTime; + this.x += vx * speed; + this.y += vy * speed; + + // 画面外に出ないように制限(簡易版) + this.x = Math.max(0, Math.min(window.innerWidth, this.x)); + this.y = Math.max(0, Math.min(window.innerHeight, this.y)); + } +} \ No newline at end of file