mirror of
https://github.com/He4eT/DotDashPit.git
synced 2026-05-04 17:37:23 +00:00
game: clamp: data last
This commit is contained in:
parent
c4c16a3267
commit
26ab30dd9a
1 changed files with 6 additions and 6 deletions
12
game.js
12
game.js
|
|
@ -161,14 +161,14 @@ function handleMoves() {
|
||||||
([dx, dy].every((d) => d !== 0) ? Math.SQRT2 : 1)
|
([dx, dy].every((d) => d !== 0) ? Math.SQRT2 : 1)
|
||||||
|
|
||||||
player.position = {
|
player.position = {
|
||||||
x: clamp(player.position.x + dx * norm)(
|
x: clamp(
|
||||||
arena.bounds.left,
|
arena.bounds.left,
|
||||||
arena.bounds.right,
|
arena.bounds.right,
|
||||||
),
|
)(player.position.x + dx * norm),
|
||||||
y: clamp(player.position.y + dy * norm)(
|
y: clamp(
|
||||||
arena.bounds.top,
|
arena.bounds.top,
|
||||||
arena.bounds.bottom,
|
arena.bounds.bottom,
|
||||||
),
|
)(player.position.y + dy * norm),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -660,8 +660,8 @@ function arr(n, filler) {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
function clamp(value) {
|
function clamp(min, max) {
|
||||||
return (min, max) => Math.max(min, Math.min(max, value))
|
return (value) => Math.max(min, Math.min(max, value))
|
||||||
}
|
}
|
||||||
|
|
||||||
function rnd(from, to, seed) {
|
function rnd(from, to, seed) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue