|
|
|
@ -270,12 +270,12 @@ fn set_piece(
|
|
|
|
(0,-1).into(),
|
|
|
|
(0,-1).into(),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
Orientation::Right => [
|
|
|
|
Orientation::Right => [
|
|
|
|
(-1,0).into(),(0,0).into(),(0,1).into(),
|
|
|
|
(-1,0).into(),(0,0).into(),(1,0).into(),
|
|
|
|
(-1,-1).into(),
|
|
|
|
(-1,-1).into(),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
Orientation::Left => [
|
|
|
|
Orientation::Left => [
|
|
|
|
(1,1).into(),
|
|
|
|
(1,1).into(),
|
|
|
|
(-1,0).into(),(0,0).into(),(0,1).into(),
|
|
|
|
(-1,0).into(),(0,0).into(),(1,0).into(),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Shape::J => match o {
|
|
|
|
Shape::J => match o {
|
|
|
|
@ -294,40 +294,70 @@ fn set_piece(
|
|
|
|
(1,-1).into(),
|
|
|
|
(1,-1).into(),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
Orientation::Right => [
|
|
|
|
Orientation::Right => [
|
|
|
|
(-1,-1).into(),
|
|
|
|
(-1,1).into(),
|
|
|
|
(-1,0).into(),(0,0).into(),(1,0).into()
|
|
|
|
(-1,0).into(),(0,0).into(),(1,0).into()
|
|
|
|
],
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Shape::S => match o {
|
|
|
|
Shape::S => match o {
|
|
|
|
Orientation::Up | Orientation::Down => [
|
|
|
|
Orientation::Up => [
|
|
|
|
(0,0).into(),(1,0).into(),
|
|
|
|
(0,0).into(),(1,0).into(),
|
|
|
|
(-1,-1).into(),(0,-1).into(),
|
|
|
|
(-1,-1).into(),(0,-1).into(),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
Orientation::Left | Orientation::Right => [
|
|
|
|
Orientation::Down => [
|
|
|
|
(0,1).into(),
|
|
|
|
(0,1).into(),(1,1).into(),
|
|
|
|
(-1,0).into(),(0,0).into(),
|
|
|
|
(-1,0).into(),(0,0).into(),
|
|
|
|
(-1,-1).into(),
|
|
|
|
],
|
|
|
|
]
|
|
|
|
Orientation::Right => [
|
|
|
|
|
|
|
|
(-1,1).into(),
|
|
|
|
|
|
|
|
(-1,0).into(),(0,0).into(),
|
|
|
|
|
|
|
|
(0,-1).into(),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
Orientation::Left => [
|
|
|
|
|
|
|
|
(0,1).into(),
|
|
|
|
|
|
|
|
(0,0).into(),(1,0).into(),
|
|
|
|
|
|
|
|
(1,-1).into(),
|
|
|
|
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Shape::Z => match o {
|
|
|
|
Shape::Z => match o {
|
|
|
|
Orientation::Up | Orientation::Down => [
|
|
|
|
Orientation::Up => [
|
|
|
|
(-1,0).into(),(0,0).into(),
|
|
|
|
(-1,0).into(),(0,0).into(),
|
|
|
|
(0,-1).into(),(1,-1).into(),
|
|
|
|
(0,-1).into(),(1,-1).into(),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
Orientation::Left | Orientation::Right => [
|
|
|
|
Orientation::Down => [
|
|
|
|
(0,1).into(),
|
|
|
|
(-1,1).into(),(0,1).into(),
|
|
|
|
(0,0).into(),(1,0).into(),
|
|
|
|
(0,0).into(),(1,0).into(),
|
|
|
|
(1,-1).into(),
|
|
|
|
],
|
|
|
|
|
|
|
|
Orientation::Left => [
|
|
|
|
|
|
|
|
(1,1).into(),
|
|
|
|
|
|
|
|
(0,0).into(),(1,0).into(),
|
|
|
|
|
|
|
|
(0,-1).into(),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
Orientation::Right => [
|
|
|
|
|
|
|
|
(0,1).into(),
|
|
|
|
|
|
|
|
(-1,0).into(),(0,0).into(),
|
|
|
|
|
|
|
|
(-1,-1).into(),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// TODO: This does not match tetris!
|
|
|
|
Shape::I => match o {
|
|
|
|
Shape::I => match o {
|
|
|
|
Orientation::Up | Orientation::Down => [
|
|
|
|
Orientation::Up => [
|
|
|
|
(0,2).into(),
|
|
|
|
(0,2).into(),
|
|
|
|
(0,1).into(),
|
|
|
|
(0,1).into(),
|
|
|
|
(0,0).into(),
|
|
|
|
(0,0).into(),
|
|
|
|
(0,-1).into(),
|
|
|
|
(0,-1).into(),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
Orientation::Left | Orientation::Right => todo!()
|
|
|
|
Orientation::Down => [
|
|
|
|
|
|
|
|
(-1,2).into(),
|
|
|
|
|
|
|
|
(-1,1).into(),
|
|
|
|
|
|
|
|
(-1,0).into(),
|
|
|
|
|
|
|
|
(-1,-1).into(),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
Orientation::Left => [
|
|
|
|
|
|
|
|
(-2,0).into(),(-1,0).into(),(0,0).into(),(1,0).into(),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
Orientation::Right => [
|
|
|
|
|
|
|
|
(-2,1).into(),(-1,1).into(),(0,1).into(),(1,1).into(),
|
|
|
|
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
@ -378,7 +408,7 @@ fn kb_input(
|
|
|
|
match key_code {
|
|
|
|
match key_code {
|
|
|
|
// Up arrow should rotate if in falling mode
|
|
|
|
// Up arrow should rotate if in falling mode
|
|
|
|
// Only move up if in falling::off mode
|
|
|
|
// Only move up if in falling::off mode
|
|
|
|
KeyCode::ArrowUp => *o = o.next(),
|
|
|
|
KeyCode::ArrowUp => *o = o.prev(),
|
|
|
|
KeyCode::ArrowDown => *gp = gp.move_down(),
|
|
|
|
KeyCode::ArrowDown => *gp = gp.move_down(),
|
|
|
|
KeyCode::ArrowLeft => *gp = gp.move_left(),
|
|
|
|
KeyCode::ArrowLeft => *gp = gp.move_left(),
|
|
|
|
KeyCode::ArrowRight => *gp = gp.move_right(),
|
|
|
|
KeyCode::ArrowRight => *gp = gp.move_right(),
|
|
|
|
|