fixed the bad stuff
This commit is contained in:
parent
b4f6db070a
commit
25dbbc4f4b
@ -13,7 +13,6 @@ fn main() {
|
||||
taquin_game.init_grid();
|
||||
draw_game(&taquin_game);
|
||||
|
||||
// enable_raw_mode().expect("Could not enable raw mode");
|
||||
while playing {
|
||||
let mut message = "";
|
||||
let mut user_cheated: bool = false;
|
||||
|
||||
@ -21,7 +21,7 @@ pub struct TaquinGame {
|
||||
impl TaquinGame {
|
||||
pub fn new() -> Self {
|
||||
return TaquinGame {
|
||||
empty_coord: [COLUMNS - 1, ROWS - 1],
|
||||
empty_coord: [0, 0],
|
||||
grid: [[0; COLUMNS]; ROWS],
|
||||
rng: rand::rng(),
|
||||
score: 0,
|
||||
@ -46,25 +46,25 @@ impl TaquinGame {
|
||||
let mut valid_direction = false;
|
||||
|
||||
match direction {
|
||||
Directions::Up => {
|
||||
Directions::Down => {
|
||||
if row + 1 < ROWS {
|
||||
row += 1;
|
||||
valid_direction = true;
|
||||
}
|
||||
}
|
||||
Directions::Down => {
|
||||
Directions::Up => {
|
||||
if row > 0 {
|
||||
row -= 1;
|
||||
valid_direction = true;
|
||||
}
|
||||
}
|
||||
Directions::Left => {
|
||||
Directions::Right => {
|
||||
if column + 1 < COLUMNS {
|
||||
column += 1;
|
||||
valid_direction = true;
|
||||
}
|
||||
}
|
||||
Directions::Right => {
|
||||
Directions::Left => {
|
||||
if column > 0 {
|
||||
column -= 1;
|
||||
valid_direction = true;
|
||||
@ -82,7 +82,7 @@ impl TaquinGame {
|
||||
|
||||
pub fn is_grid_done(&mut self) -> bool {
|
||||
let mut error_found = false;
|
||||
let mut value = 1;
|
||||
let mut value = 0;
|
||||
|
||||
for i in 0..ROWS {
|
||||
if !error_found {
|
||||
@ -102,12 +102,12 @@ impl TaquinGame {
|
||||
}
|
||||
|
||||
if !error_found {
|
||||
if self.score > 0 && (self.high_score == 0 || self.score > self.high_score) {
|
||||
if self.score > 0 && (self.high_score == 0 || self.score < self.high_score) {
|
||||
self.high_score = self.score;
|
||||
}
|
||||
}
|
||||
|
||||
return error_found;
|
||||
return !error_found;
|
||||
}
|
||||
|
||||
pub fn init_grid(&mut self) {
|
||||
@ -150,7 +150,7 @@ impl TaquinGame {
|
||||
pub fn resolve(&mut self) {
|
||||
let mut value = 0;
|
||||
self.score = 0;
|
||||
self.empty_coord = [ROWS - 1, COLUMNS - 1];
|
||||
self.empty_coord = [0, 0];
|
||||
|
||||
for i in 0..ROWS {
|
||||
for j in 0..COLUMNS {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user