forked from zapashcanon/pellest
optim
This commit is contained in:
parent
0aded75cb7
commit
ddeba99f2e
@ -94,16 +94,12 @@ let kb_handler ev =
|
||||
let x, y = !Map.player_pos in
|
||||
let x, y =
|
||||
match ev |> Ev.as_type |> Ev.Keyboard.code |> Jstr.to_string with
|
||||
| "KeyW" | "ArrowUp" -> (x, y - 1)
|
||||
| "KeyA" | "ArrowLeft" -> (x - 1, y)
|
||||
| "KeyS" | "ArrowDown" -> (x, y + 1)
|
||||
| "KeyD" | "ArrowRight" -> (x + 1, y)
|
||||
| "KeyW" | "ArrowUp" -> (x, max 0 (y - 1))
|
||||
| "KeyA" | "ArrowLeft" -> (max 0 (x - 1), y)
|
||||
| "KeyS" | "ArrowDown" -> (x, min (Map.height - 1) y + 1)
|
||||
| "KeyD" | "ArrowRight" -> (min (Map.width - 1) x + 1, y)
|
||||
| _s -> (x, y)
|
||||
in
|
||||
let x = max 0 x in
|
||||
let x = min (Map.width - 1) x in
|
||||
let y = max 0 y in
|
||||
let y = min (Map.height - 1) y in
|
||||
Map.player_pos := (x, y)
|
||||
|
||||
let rec game_loop state _timestamp =
|
||||
|
Loading…
x
Reference in New Issue
Block a user