Skip to content

Commit 16d9166

Browse files
Merge pull request #88 from ut-code:fix-wall-collision
左と上の壁の判定を追加
2 parents 85843ba + 9ace2b8 commit 16d9166

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎packages/web/src/component/game.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,14 @@ class World {
289289
// 壁との当たり判定
290290
for (const fighter of this.fighters) {
291291
fighter.location = {
292-
x: Math.min(fighter.location.x, STAGE_WIDTH - fighter.size.x),
293-
y: Math.min(fighter.location.y, STAGE_HEIGHT - fighter.size.y),
292+
x: Math.min(
293+
Math.max(fighter.location.x, 0),
294+
STAGE_WIDTH - fighter.size.x
295+
),
296+
y: Math.min(
297+
Math.max(fighter.location.y, 0),
298+
STAGE_HEIGHT - fighter.size.y
299+
),
294300
};
295301
}
296302

0 commit comments

Comments
 (0)