|
@ -36,7 +36,6 @@ pub fn make_grid(ctx: &mut Context, r: u8, c: u8, board: &[Vec<u8>]) -> GameResu |
|
|
0 => Color::WHITE, |
|
|
0 => Color::WHITE, |
|
|
1 => Color::BLACK, |
|
|
1 => Color::BLACK, |
|
|
_ => Color::BLACK, //impossible
|
|
|
_ => Color::BLACK, //impossible
|
|
|
//2 => Color::RED, 3 => Color::CYAN, 4 => Color::YELLOW, 5 => Color::GREEN, 6 => Color::BLUE, 7 => Color::MAGENTA, _ => Color::BLACK,
|
|
|
|
|
|
}, |
|
|
}, |
|
|
)?; |
|
|
)?; |
|
|
} |
|
|
} |
|
@ -49,22 +48,15 @@ impl Apr { |
|
|
pub fn new(_ctx: &mut Context, r: u8, c: u8) -> GameResult<Apr> { |
|
|
pub fn new(_ctx: &mut Context, r: u8, c: u8) -> GameResult<Apr> { |
|
|
// Load/create resources such as images here.
|
|
|
// Load/create resources such as images here.
|
|
|
let board = board::make_board(r, c); |
|
|
let board = board::make_board(r, c); |
|
|
let mut temp_vec: Vec<actor::Actor> = Vec::new(); |
|
|
let mut actors: Vec<actor::Actor> = Vec::new(); |
|
|
for i in 0..r { |
|
|
for i in 0..r { |
|
|
temp_vec.push(Apr::make_actor(_ctx, "/pawn.png", i, 0, 0)); |
|
|
actors.push(Apr::make_actor(_ctx, "/pawn.png", i, 0, 0)); |
|
|
} |
|
|
} |
|
|
Ok(Apr { |
|
|
Ok(Apr { |
|
|
grid: make_grid(_ctx, r, c, board.board.as_slice())?, |
|
|
grid: make_grid(_ctx, r, c, board.board.as_slice())?, |
|
|
board: board, |
|
|
board, |
|
|
should_update_grid: false, |
|
|
should_update_grid: false, |
|
|
|
|
|
actors, |
|
|
/*actors: vec![actor::Actor {
|
|
|
|
|
|
image: graphics::Image::new(_ctx, "/pawn.png")?, |
|
|
|
|
|
posn: actor::ActorPosn::BoardPosn { x: 0, y: 0 }, |
|
|
|
|
|
behaviour: 0, |
|
|
|
|
|
}],*/ |
|
|
|
|
|
//actors: vec![Apr::make_actor(_ctx, "/pawn.png", 0, 0, 0)],
|
|
|
|
|
|
actors: temp_vec, |
|
|
|
|
|
behaviours: vec![behaviour::Behaviour { |
|
|
behaviours: vec![behaviour::Behaviour { |
|
|
moves: vec![(0, 1)], |
|
|
moves: vec![(0, 1)], |
|
|
}], //the pawn can go ONE forwards
|
|
|
}], //the pawn can go ONE forwards
|
|
@ -72,11 +64,11 @@ impl Apr { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
pub fn make_actor(ctx: &mut Context, img_path: &str, _x: u8, _y: u8, b: u8) -> actor::Actor { |
|
|
pub fn make_actor(ctx: &mut Context, img_path: &str, _x: u8, _y: u8, b: u8) -> actor::Actor { |
|
|
return actor::Actor {
|
|
|
actor::Actor {
|
|
|
image: graphics::Image::new(ctx, img_path).unwrap(), |
|
|
image: graphics::Image::new(ctx, img_path).unwrap(), |
|
|
posn: actor::ActorPosn::BoardPosn { x: _x, y: _y }, |
|
|
posn: actor::ActorPosn::BoardPosn { x: _x, y: _y }, |
|
|
behaviour: b, |
|
|
behaviour: b, |
|
|
}; |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
pub fn set_colour(&mut self, r: usize, c: usize, col: u8) { |
|
|
pub fn set_colour(&mut self, r: usize, c: usize, col: u8) { |
|
|