diff options
author | San Jacobs | 2023-01-12 08:50:25 +0100 |
---|---|---|
committer | San Jacobs | 2023-01-12 08:50:25 +0100 |
commit | 6d0197d73345aa300523f1b2a2683cd1080b4548 (patch) | |
tree | 0f26279e0c4d5c4ed82894b802e808aadd2b29b7 | |
parent | d0fe67269297c7d08ddcf7ef709aa0cf8d524ef0 (diff) | |
download | odin-frogger-6d0197d73345aa300523f1b2a2683cd1080b4548.tar.gz odin-frogger-6d0197d73345aa300523f1b2a2683cd1080b4548.tar.bz2 odin-frogger-6d0197d73345aa300523f1b2a2683cd1080b4548.zip |
Difficulty and seed settings
-rw-r--r-- | main.odin | 25 | ||||
-rw-r--r-- | main.pdb | bin | 3862528 -> 3895296 bytes |
2 files changed, 20 insertions, 5 deletions
@@ -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[:]) Binary files differ |