aboutsummaryrefslogtreecommitdiff
path: root/main.odin
blob: 5357595aa49e2e43656710a2bf736d5c7e9b0ffd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package main

import "core:fmt"
import "core:os"
import "core:bufio"
import "core:io"
import "core:strconv"
import "core:strings"

instructions: string = "Use space to stay still, and HJKL to move."

main :: proc() {
    fmt.println("What's your name? ")
    name: string = getln()
    defer delete(name)
    fmt.printf("Hello %v! Welcome to shitty frogger.\n\n", name)

    fmt.println(instructions)

    // Two options for this implementation:
    // 1. Structs for rows that contain data about what direction they flow
    //   - Problem: No neat way to declare the lines with a custom length at runtime
    //   - Solution: Pointer shit maybe. Ugh.
    // 2. Separate array that contains booleans for what direction they flow
    //   - Problem: Data feels separate, which feels wonky, but might be fine
    // 
    // 
    // 
    // 
}

getln :: proc() -> string {
    buf: [256]u8
    bytes_read, ok := os.read(os.stdin, buf[:])
    //assert(ok)
    read_input := string(buf[:bytes_read-2])
    return strings.clone(read_input)
}

getint :: proc() -> int {
    buf: [256]u8
    for {
        read_input := getln()
        output, ok := strconv.parse_int(read_input)
        if ok {
            return output
        } else {
            fmt.println("That's not a normal whole number, mate.")
        }
    }
}

getrune :: proc() -> rune {
    buf: [256]u8
    bytes_read, ok := os.read(os.stdin, buf[:])
    //assert(ok)
    read_input := rune(buf[0])
    return read_input
}