Browse Source

tested traditional chess knight movement

master
SilverEmber 4 years ago
parent
commit
07defabce4
  1. 17
      src/apr.rs
  2. 4
      src/behaviour.rs

17
src/apr.rs

@ -58,6 +58,14 @@ impl Apr {
vec![(1, -1), (-1, -1)],
));
}
for i in 0..=1 {
// white side knights
actors.push(actor::Actor::new(_ctx, "/pawn.png", i, 0, 0));
behaviours.push(behaviour::Behaviour::new(
vec![(1, 2)],
vec![(1, -1), (-1, -1)],
));
}
for i in 0..r {
// black side pawns
actors.push(actor::Actor::new(_ctx, "/pawn2.png", i, c - 2, 0));
@ -66,6 +74,15 @@ impl Apr {
vec![(1, 1), (-1, 1)],
));
}
for i in 0..=1 {
// black side knights
actors.push(actor::Actor::new(_ctx, "/pawn2.png", i, c - 1, 0));
behaviours.push(behaviour::Behaviour::new(
vec![(1, 2)],
vec![(1, 1), (-1, 1)],
));
}
Ok(Apr {
grid: make_grid(_ctx, r, c, board.board.as_slice())?,
board,

4
src/behaviour.rs

@ -16,8 +16,8 @@ impl Behaviour {
// mind blanking need to add something to confirm which direction we are iterating through
// println!("Permissible: ({}, {})",(origin.0 as i8) + dir.0 * moveset.0,(origin.1 as i8) - dir.1 * moveset.1);
if (
((origin.0 as i8) + dir.0 * moveset.0) as u8,
((origin.1 as i8) - dir.1 * moveset.1) as u8,
((origin.0 as i8) + moveset.0 * dir.0) as u8,
((origin.1 as i8) - moveset.1 * dir.1) as u8,
) == destination
{
return true;

Loading…
Cancel
Save