From 6d0197d73345aa300523f1b2a2683cd1080b4548 Mon Sep 17 00:00:00 2001 From: San Jacobs Date: Thu, 12 Jan 2023 08:50:25 +0100 Subject: Difficulty and seed settings --- main.odin | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'main.odin') diff --git a/main.odin b/main.odin index 2f0152d..2871e9f 100644 --- a/main.odin +++ b/main.odin @@ -25,7 +25,7 @@ block::'O' water::'~' player::'@' -difficulty::0.4 +difficulty:f32=0.4 log_length::0.6 main :: proc() { @@ -33,14 +33,15 @@ main :: proc() { //name: string = getln() //defer delete(name) //fmt.printf("Hello %v! Welcome to shitty frogger.\n\n", name) + fmt.println("Set difficulty [0.0 <-> 1.0]") + difficulty=getfloat() + fmt.println("Set seed") + rand_state=rand.create(u64(getint())) win : bool = false state : state_type - populate_board(&state) - - fmt.println(state) draw_board(state) for !win { @@ -52,7 +53,8 @@ main :: proc() { win = true } } - fmt.println("You win, brotha.") + fmt.println("\n You win, brotha.") + getln() } getln :: proc() -> string { @@ -76,6 +78,19 @@ getint :: proc() -> int { } } +getfloat :: proc() -> f32 { + buf: [256]u8 + for { + read_input := getln() + output, ok := strconv.parse_f32(read_input) + if ok { + return output + } else { + fmt.println("That's not a normal float, mate.") + } + } +} + getrune :: proc() -> rune { buf: [256]u8 bytes_read, ok := os.read(os.stdin, buf[:]) -- cgit v1.2.1