Skip to content

Commit d94d1cc

Browse files
authored
Merge pull request #83 from jjfiv/fix-amidar
player_start now part of config and not state #80
2 parents 3dc23c4 + ea48aa1 commit d94d1cc

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

tb_amidar/src/amidar.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ pub const AMIDAR_ENEMY_POSITIONS_DATA: &str = include_str!("resources/amidar_ene
6464
pub struct Amidar {
6565
pub rand: random::Gen,
6666
board: Vec<String>,
67+
pub player_start: TilePoint,
6768
bg_color: Color,
6869
player_color: Color,
6970
unpainted_color: Color,
@@ -100,6 +101,7 @@ impl Default for Amidar {
100101
Amidar {
101102
rand: random::Gen::new_from_seed(13),
102103
board: AMIDAR_BOARD.lines().map(|s| s.to_owned()).collect(),
104+
player_start: TilePoint::new(31, 15),
103105
bg_color: Color::black(),
104106
player_color: Color::rgb(255, 255, 153),
105107
unpainted_color: Color::rgb(148, 0, 211),
@@ -1033,7 +1035,6 @@ pub struct StateCore {
10331035
pub chase_timer: i32,
10341036
pub jump_timer: i32,
10351037
pub player: Mob,
1036-
pub player_start: TilePoint,
10371038
pub enemies: Vec<Mob>,
10381039
pub board: Board,
10391040
}
@@ -1053,8 +1054,7 @@ impl State {
10531054
.iter()
10541055
.map(|ai| board.make_enemy(ai.clone()))
10551056
.collect();
1056-
let player_start = TilePoint::new(31, 15);
1057-
let player = Mob::new_player(player_start.to_world());
1057+
let player = Mob::new_player(config.player_start.to_world());
10581058

10591059
let core = StateCore {
10601060
rand: random::Gen::new_child(&mut config.rand),
@@ -1064,7 +1064,6 @@ impl State {
10641064
jumps: config.start_jumps,
10651065
jump_timer: 0,
10661066
player,
1067-
player_start,
10681067
enemies,
10691068
board,
10701069
};
@@ -1079,7 +1078,7 @@ impl State {
10791078
pub fn reset(&mut self) {
10801079
self.state
10811080
.player
1082-
.reset(&self.state.player_start, &self.state.board);
1081+
.reset(&self.config.player_start, &self.state.board);
10831082
// On the default board, we imagine starting from below the initial place.
10841083
// This way going up paints the first segment.
10851084
if self.config.default_board_bugs {
@@ -1091,7 +1090,7 @@ impl State {
10911090
);
10921091
}
10931092
for enemy in &mut self.state.enemies {
1094-
enemy.reset(&self.state.player_start, &self.state.board);
1093+
enemy.reset(&self.config.player_start, &self.state.board);
10951094
}
10961095
}
10971096
pub fn board_size(&self) -> WorldPoint {

0 commit comments

Comments
 (0)