mirror of
https://github.com/Noratrieb/game-wip-dontplay.git
synced 2026-01-17 04:45:02 +01:00
Use saturating arithmetic for keyboard camera movement
This commit is contained in:
parent
91cd644b8c
commit
6f1c351b5f
1 changed files with 4 additions and 4 deletions
|
|
@ -69,16 +69,16 @@ impl App {
|
||||||
2
|
2
|
||||||
};
|
};
|
||||||
if self.kb_input.down(Key::Left) {
|
if self.kb_input.down(Key::Left) {
|
||||||
self.game.camera_offset.x -= spd;
|
self.game.camera_offset.x = self.game.camera_offset.x.saturating_sub(spd);
|
||||||
}
|
}
|
||||||
if self.kb_input.down(Key::Right) {
|
if self.kb_input.down(Key::Right) {
|
||||||
self.game.camera_offset.x += spd;
|
self.game.camera_offset.x = self.game.camera_offset.x.saturating_add(spd);
|
||||||
}
|
}
|
||||||
if self.kb_input.down(Key::Up) {
|
if self.kb_input.down(Key::Up) {
|
||||||
self.game.camera_offset.y -= spd;
|
self.game.camera_offset.y = self.game.camera_offset.y.saturating_sub(spd);
|
||||||
}
|
}
|
||||||
if self.kb_input.down(Key::Down) {
|
if self.kb_input.down(Key::Down) {
|
||||||
self.game.camera_offset.y += spd;
|
self.game.camera_offset.y = self.game.camera_offset.y.saturating_add(spd);
|
||||||
}
|
}
|
||||||
let tp = self.game.camera_offset.tile_pos();
|
let tp = self.game.camera_offset.tile_pos();
|
||||||
imm_dbg!(tp);
|
imm_dbg!(tp);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue