From 11489f9fd7228ebec8ab630f92d1cfdf8d1a20ba Mon Sep 17 00:00:00 2001 From: San Jacobs Date: Thu, 12 Jan 2023 02:41:36 +0100 Subject: Initial commit --- .vscode/tasks.json | 19 +++++++++++++ LICENCE.md | 3 ++ README.md | 5 ++++ main.exe | Bin 0 -> 369152 bytes main.odin | 59 ++++++++++++++++++++++++++++++++++++++++ main.pdb | Bin 0 -> 3821568 bytes odin-frogger-debug-session.rdbg | Bin 0 -> 543 bytes 7 files changed, 86 insertions(+) create mode 100644 .vscode/tasks.json create mode 100644 LICENCE.md create mode 100644 README.md create mode 100644 main.exe create mode 100644 main.odin create mode 100644 main.pdb create mode 100644 odin-frogger-debug-session.rdbg diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..16477da --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,19 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "type": "shell", + "command": "odin run .\\main.odin -file -strict-style -debug", + "group": "build", + "presentation": { + // Reveal the output only if unrecognized errors occur. + "reveal": "silent" + }, + // Use the standard MS compiler pattern to detect errors, warnings and infos + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/LICENCE.md b/LICENCE.md new file mode 100644 index 0000000..ac1f876 --- /dev/null +++ b/LICENCE.md @@ -0,0 +1,3 @@ +Luke Smith Licenceā„¢ + +If you ask, you can't use it. diff --git a/README.md b/README.md new file mode 100644 index 0000000..346843d --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# odin-frogger + +Really shitty turn-based frogger I'm writing in [odin](https://odin-lang.org/) to see if I like it. + +Also, yes. `.vscode/`. Cringe. I know. I just can't be bothered to set up autocomplete for odin in vim. \ No newline at end of file diff --git a/main.exe b/main.exe new file mode 100644 index 0000000..016fbd3 Binary files /dev/null and b/main.exe differ 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 +} diff --git a/main.pdb b/main.pdb new file mode 100644 index 0000000..6397bcf Binary files /dev/null and b/main.pdb differ diff --git a/odin-frogger-debug-session.rdbg b/odin-frogger-debug-session.rdbg new file mode 100644 index 0000000..b871545 Binary files /dev/null and b/odin-frogger-debug-session.rdbg differ -- cgit v1.2.1