Ajout logique de l'affichage du tour
This commit is contained in:
parent
ba312a3aef
commit
98842df868
@ -1,10 +1,14 @@
|
||||
use rand::prelude::*;
|
||||
use std::{thread, time::Duration};
|
||||
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
let turns: Vec<i8> = gen_turn_array();
|
||||
for turn in turns {
|
||||
println!("{}", turn);
|
||||
let mut amnt: i8 = 0;
|
||||
let good_answer: bool = true;
|
||||
|
||||
while good_answer {
|
||||
show_game(amnt, turns.clone());
|
||||
amnt += 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,3 +22,26 @@ fn gen_turn_array() -> Vec<i8> {
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
fn show_game(amnt: i8, turns: Vec<i8>) {
|
||||
for i in 0..amnt {
|
||||
print!("{esc}[2J{esc}[1;1H", esc = 27 as char); //Clear the screen
|
||||
let turn: i8 = turns[i as usize];
|
||||
match turn {
|
||||
1 => {
|
||||
println!("VERT");
|
||||
}
|
||||
2 => {
|
||||
println!("ROUGE");
|
||||
}
|
||||
3 => {
|
||||
println!("JAUNE");
|
||||
}
|
||||
4 => {
|
||||
println!("BLEU");
|
||||
}
|
||||
_ => println!("Error parsing turn."),
|
||||
}
|
||||
thread::sleep(Duration::from_millis(1000));
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user