Skip to content

Commit

Permalink
Reenter boards appropriately.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdm committed Oct 27, 2021
1 parent 27a56a0 commit e6d5d7a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ impl GameState for TitleState {
robots,
&mut world.global_robot,
LabelAction::Nothing,
false,
);
}

Expand Down Expand Up @@ -112,10 +113,12 @@ impl PlayState {

impl GameState for PlayState {
fn init(&mut self, world: &mut World, board_id: &mut usize) {
*board_id = self.starting_board.unwrap_or(world.starting_board_number.0 as usize);
let starting_board = self.starting_board.unwrap_or(world.starting_board_number.0 as usize);
let reenter = *board_id == starting_board;
*board_id = starting_board;
let (ref mut board, ref mut robots) = world.boards[*board_id];
let pos = board.player_pos;
enter_board(&mut world.state, &self.music, board, pos, robots, &mut world.global_robot, LabelAction::RunJustLoadedAndJustEntered);
enter_board(&mut world.state, &self.music, board, pos, robots, &mut world.global_robot, LabelAction::RunJustLoadedAndJustEntered, reenter);
world.state.charset = world.state.initial_charset;
world.state.palette = world.state.initial_palette.clone();
}
Expand Down Expand Up @@ -486,7 +489,7 @@ pub(crate) fn tick_game_loop(
CardinalDirection::West =>
Coordinate(board.width as u16 - 1, old_player_pos.1),
};
enter_board(&mut world.state, audio, board, player_pos, robots, &mut world.global_robot, LabelAction::RunJustEntered);
enter_board(&mut world.state, audio, board, player_pos, robots, &mut world.global_robot, LabelAction::RunJustEntered, false);
}
_ => {
warn!("Edge of board with no exit.");
Expand All @@ -498,7 +501,7 @@ pub(crate) fn tick_game_loop(
let (ref mut dest_board, ref mut robots) = &mut world.boards[dest_board_id as usize];
let coord = dest_board.find(id, color).unwrap_or(dest_board.player_pos);
*board_id = dest_board_id as usize;
enter_board(&mut world.state, audio, dest_board, coord, robots, &mut world.global_robot, LabelAction::RunJustEntered);
enter_board(&mut world.state, audio, dest_board, coord, robots, &mut world.global_robot, LabelAction::RunJustEntered, true);
}

Some(InputResult::Collide(pos)) => {
Expand Down

0 comments on commit e6d5d7a

Please sign in to comment.