no longer walking through walls
This commit is contained in:
parent
6705af3611
commit
ea5041d85a
@ -95,10 +95,15 @@ struct Player {}
|
||||
fn try_move_player(delta_x: i32, delta_y: i32, ecs: &mut World) {
|
||||
let mut positions = ecs.write_storage::<Position>();
|
||||
let mut players = ecs.write_storage::<Player>();
|
||||
let map = ecs.fetch::<Vec<TileType>>();
|
||||
|
||||
for (_player, pos) in (&mut players, &mut positions).join() {
|
||||
pos.x = min(79 , max(0, pos.x + delta_x));
|
||||
pos.y = min(49, max(0, pos.y + delta_y));
|
||||
let x = min(79 , max(0, pos.x + delta_x));
|
||||
let y = min(49, max(0, pos.y + delta_y));
|
||||
if map[xy_idx(x,y)] != TileType::Wall {
|
||||
pos.x = x;
|
||||
pos.y = y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user