diff options
Diffstat (limited to 'main.odin')
-rw-r--r-- | main.odin | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/main.odin b/main.odin new file mode 100644 index 0000000..5357595 --- /dev/null +++ b/main.odin @@ -0,0 +1,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 +} |