summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs39
1 files changed, 22 insertions, 17 deletions
diff --git a/src/main.rs b/src/main.rs
index edbb973..2bd1ef0 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -15,6 +15,8 @@ pub const TILE_SCALE: f32 = 3.0;
pub const TILE_HEIGHT: f32 = 16.0;
pub const TILE_WIDTH: f32 = 16.0;
pub const BORDER_SIZE: f32 = 3.0;
+pub const SHIFT_X: f32 = 50.0;
+pub const SHIFT_Y: f32 = 50.0;
#[derive(Clone, Copy)]
enum Occupant {
@@ -156,34 +158,37 @@ impl Game {
let mut y = 0.0;
for _ in 0..8 {
let mut column = Vec::new();
- column.push(Cell::new(Point2 { x: 0.0, y }));
column.push(Cell::new(Point2 {
- x: 1.0 * (TILE_WIDTH * TILE_SCALE + BORDER_SIZE),
- y,
+ x: SHIFT_X,
+ y: y + SHIFT_Y,
}));
column.push(Cell::new(Point2 {
- x: 2.0 * (TILE_WIDTH * TILE_SCALE + BORDER_SIZE),
- y,
+ x: 1.0 * (TILE_WIDTH * TILE_SCALE + BORDER_SIZE) + SHIFT_X,
+ y: y + SHIFT_Y,
}));
column.push(Cell::new(Point2 {
- x: 3.0 * (TILE_WIDTH * TILE_SCALE + BORDER_SIZE),
- y,
+ x: 2.0 * (TILE_WIDTH * TILE_SCALE + BORDER_SIZE) + SHIFT_X,
+ y: y + SHIFT_Y,
}));
column.push(Cell::new(Point2 {
- x: 4.0 * (TILE_WIDTH * TILE_SCALE + BORDER_SIZE),
- y,
+ x: 3.0 * (TILE_WIDTH * TILE_SCALE + BORDER_SIZE) + SHIFT_X,
+ y: y + SHIFT_Y,
}));
column.push(Cell::new(Point2 {
- x: 5.0 * (TILE_WIDTH * TILE_SCALE + BORDER_SIZE),
- y,
+ x: 4.0 * (TILE_WIDTH * TILE_SCALE + BORDER_SIZE) + SHIFT_X,
+ y: y + SHIFT_Y,
}));
column.push(Cell::new(Point2 {
- x: 6.0 * (TILE_WIDTH * TILE_SCALE + BORDER_SIZE),
- y,
+ x: 5.0 * (TILE_WIDTH * TILE_SCALE + BORDER_SIZE) + SHIFT_X,
+ y: y + SHIFT_Y,
}));
column.push(Cell::new(Point2 {
- x: 7.0 * (TILE_WIDTH * TILE_SCALE + BORDER_SIZE),
- y,
+ x: 6.0 * (TILE_WIDTH * TILE_SCALE + BORDER_SIZE) + SHIFT_X,
+ y: y + SHIFT_Y,
+ }));
+ column.push(Cell::new(Point2 {
+ x: 7.0 * (TILE_WIDTH * TILE_SCALE + BORDER_SIZE) + SHIFT_X,
+ y: y + SHIFT_Y,
}));
y += TILE_HEIGHT * TILE_SCALE + BORDER_SIZE;
@@ -261,9 +266,9 @@ impl EventHandler for Game {
for (j, cell) in row.iter_mut().enumerate() {
if cell.contains(position)
&& (((i + 1 == selected.0) && (j == selected.1))
- || ((i - 1 == selected.0) && (j == selected.1))
+ || ((i.overflowing_sub(1).0 == selected.0) && (j == selected.1))
|| ((i == selected.0) && (j + 1 == selected.1))
- || ((i == selected.0) && (j - 1 == selected.1)))
+ || ((i == selected.0) && (j.overflowing_sub(1)).0 == selected.1))
{
swap = Some((i, j));
}