Overworld Movement #9
2 changed files with 21 additions and 2 deletions
|
@ -66,6 +66,8 @@ fn update_move_player(state: &mut State) {
|
||||||
requested_pos_diff = Some(diff);
|
requested_pos_diff = Some(diff);
|
||||||
requested_cost_curr = Some(tile.movement_cost_up());
|
requested_cost_curr = Some(tile.movement_cost_up());
|
||||||
requested_cost_new = Some(new_tile.movement_cost_down());
|
requested_cost_new = Some(new_tile.movement_cost_down());
|
||||||
|
} else {
|
||||||
|
info!("Rejecting movement - cannot stand in the requested tile.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,6 +80,8 @@ fn update_move_player(state: &mut State) {
|
||||||
requested_pos_diff = Some(diff);
|
requested_pos_diff = Some(diff);
|
||||||
requested_cost_curr = Some(tile.movement_cost_down());
|
requested_cost_curr = Some(tile.movement_cost_down());
|
||||||
requested_cost_new = Some(new_tile.movement_cost_up());
|
requested_cost_new = Some(new_tile.movement_cost_up());
|
||||||
|
} else {
|
||||||
|
info!("Rejecting movement - cannot stand in the requested tile.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,6 +94,8 @@ fn update_move_player(state: &mut State) {
|
||||||
requested_pos_diff = Some(diff);
|
requested_pos_diff = Some(diff);
|
||||||
requested_cost_curr = Some(tile.movement_cost_left());
|
requested_cost_curr = Some(tile.movement_cost_left());
|
||||||
requested_cost_new = Some(new_tile.movement_cost_right());
|
requested_cost_new = Some(new_tile.movement_cost_right());
|
||||||
|
} else {
|
||||||
|
info!("Rejecting movement - cannot stand in the requested tile.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,6 +108,8 @@ fn update_move_player(state: &mut State) {
|
||||||
requested_pos_diff = Some(diff);
|
requested_pos_diff = Some(diff);
|
||||||
requested_cost_curr = Some(tile.movement_cost_right());
|
requested_cost_curr = Some(tile.movement_cost_right());
|
||||||
requested_cost_new = Some(new_tile.movement_cost_left());
|
requested_cost_new = Some(new_tile.movement_cost_left());
|
||||||
|
} else {
|
||||||
|
info!("Rejecting movement - cannot stand in the requested tile.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +130,10 @@ fn update_move_player(state: &mut State) {
|
||||||
state.ghost.overworld_movement_speed = match (requested_cost_curr, requested_cost_new)
|
state.ghost.overworld_movement_speed = match (requested_cost_curr, requested_cost_new)
|
||||||
{
|
{
|
||||||
// movement in this direction not possible
|
// movement in this direction not possible
|
||||||
(MovementCost::Infinite, _) | (_, MovementCost::Infinite) => return,
|
(MovementCost::Infinite, _) | (_, MovementCost::Infinite) => {
|
||||||
|
info!("Rejecting movement - movement cost is infinite");
|
||||||
|
return;
|
||||||
|
},
|
||||||
|
|
||||||
// we are walking on a path
|
// we are walking on a path
|
||||||
(MovementCost::Path, MovementCost::Path) => 10.0,
|
(MovementCost::Path, MovementCost::Path) => 10.0,
|
||||||
|
|
|
@ -126,6 +126,7 @@ impl Tile {
|
||||||
match self {
|
match self {
|
||||||
Self::Grass => MovementCost::Default,
|
Self::Grass => MovementCost::Default,
|
||||||
Self::Path { left: true, .. } => MovementCost::Path,
|
Self::Path { left: true, .. } => MovementCost::Path,
|
||||||
|
Self::Path { left: false, .. } => MovementCost::Default,
|
||||||
Self::Fence { left: false, .. } => MovementCost::Obstacle,
|
Self::Fence { left: false, .. } => MovementCost::Obstacle,
|
||||||
_ => MovementCost::Infinite
|
_ => MovementCost::Infinite
|
||||||
}
|
}
|
||||||
|
@ -134,6 +135,7 @@ impl Tile {
|
||||||
match self {
|
match self {
|
||||||
Self::Grass => MovementCost::Default,
|
Self::Grass => MovementCost::Default,
|
||||||
Self::Path { right: true, .. } => MovementCost::Path,
|
Self::Path { right: true, .. } => MovementCost::Path,
|
||||||
|
Self::Path { right: false, .. } => MovementCost::Default,
|
||||||
Self::Fence { right: false, .. } => MovementCost::Obstacle,
|
Self::Fence { right: false, .. } => MovementCost::Obstacle,
|
||||||
_ => MovementCost::Infinite
|
_ => MovementCost::Infinite
|
||||||
}
|
}
|
||||||
|
@ -142,6 +144,7 @@ impl Tile {
|
||||||
match self {
|
match self {
|
||||||
Self::Grass => MovementCost::Default,
|
Self::Grass => MovementCost::Default,
|
||||||
Self::Path { top: true, .. } => MovementCost::Path,
|
Self::Path { top: true, .. } => MovementCost::Path,
|
||||||
|
Self::Path { top: false, .. } => MovementCost::Default,
|
||||||
Self::Fence { top: false, .. } => MovementCost::Obstacle,
|
Self::Fence { top: false, .. } => MovementCost::Obstacle,
|
||||||
_ => MovementCost::Infinite
|
_ => MovementCost::Infinite
|
||||||
}
|
}
|
||||||
|
@ -150,7 +153,9 @@ impl Tile {
|
||||||
match self {
|
match self {
|
||||||
Self::Grass => MovementCost::Default,
|
Self::Grass => MovementCost::Default,
|
||||||
Self::Path { bottom: true, .. } => MovementCost::Path,
|
Self::Path { bottom: true, .. } => MovementCost::Path,
|
||||||
|
Self::Path { bottom: false, .. } => MovementCost::Default,
|
||||||
Self::Fence { bottom: false, .. } => MovementCost::Obstacle,
|
Self::Fence { bottom: false, .. } => MovementCost::Obstacle,
|
||||||
|
Self::House { door: true, .. } => MovementCost::Path,
|
||||||
_ => MovementCost::Infinite
|
_ => MovementCost::Infinite
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -313,7 +318,10 @@ impl Chunk {
|
||||||
fence_vert,
|
fence_vert,
|
||||||
grass,
|
grass,
|
||||||
house(ASSETS.overworld.house_bottom_left),
|
house(ASSETS.overworld.house_bottom_left),
|
||||||
house(ASSETS.overworld.house_bottom_door),
|
Tile::House {
|
||||||
|
door: true,
|
||||||
|
texture: ASSETS.overworld.house_bottom_door
|
||||||
|
},
|
||||||
house(ASSETS.overworld.house_bottom_window),
|
house(ASSETS.overworld.house_bottom_window),
|
||||||
house(ASSETS.overworld.house_bottom_window),
|
house(ASSETS.overworld.house_bottom_window),
|
||||||
house(ASSETS.overworld.house_bottom_right),
|
house(ASSETS.overworld.house_bottom_right),
|
||||||
|
|
Loading…
Reference in a new issue