Skip to content

Commit 646a41f

Browse files
committed
World borders for player
1 parent 741029e commit 646a41f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/system/game/player.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::{
22
component::{Actor, Player},
3+
data::WORLD_SIZE_HALF,
34
model::{ActorAction, ActorActionsExt},
45
resource::Config,
56
};
@@ -70,5 +71,9 @@ pub fn player(
7071
player.add_zoom(zoom, time);
7172
player.update(time, delta);
7273
transform.rotate_local_z(player_rotation);
74+
75+
let limit = WORLD_SIZE_HALF;
76+
transform.translation.x = transform.translation.x.clamp(-limit, limit);
77+
transform.translation.y = transform.translation.y.clamp(-limit, limit);
7378
}
7479
}

0 commit comments

Comments
 (0)