@@ 3,7 3,7 @@ use rand::Rng;
use raylib::Color;
use std::time;
-#[derive(PartialEq)]
+#[derive(PartialEq, Debug)]
enum SimonColor {
Yellow,
Blue,
@@ 15,6 15,8 @@ enum GameState {
WelcomeScreen,
DisplaySequence,
UserInput,
+ FailScreen,
+ WinScreen,
}
fn main() {
@@ 69,12 71,24 @@ fn main() {
for i in 0..userinputs.len() {
println!("{:?}\n {:?}", colors, userinputs);
if colors[i] != userinputs[i] {
- rl.draw_text(" - WRONG -", 150, 40, 60, Color::RED);
- std::process::exit(1);
+ state = GameState::FailScreen;
}
}
+ if userinputs.len() == colors.len() {
+ state = GameState::WinScreen;
+ }
}
}
+ GameState::FailScreen => {
+ if time::Instant::now() + time::Duration::from_secs(2) - starttime >= wait_dura {
+ rl.draw_text(" - WRONG -", 150, 40, 60, Color::RED);
+ } else {
+ std::process::exit(1);
+ }
+ }
+ GameState::WinScreen => {
+ rl.draw_text(" - YOU WIN -", 105, 40, 60, Color::GREEN);
+ }
}
rl.end_drawing();
}