diff options
Diffstat (limited to 'main.odin')
-rw-r--r-- | main.odin | 25 |
1 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[:]) |