random changes
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Fri, 12 Aug 2022 21:59:10 +0000 (16:59 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Fri, 12 Aug 2022 21:59:10 +0000 (16:59 -0500)
14 files changed:
.vscode/launch.json [new file with mode: 0644]
.vscode/tasks.json
doc/todo.org [new file with mode: 0644]
lib/onyx-net [deleted submodule]
run_tree/run.sh
server/run.sh
src/client/game.onyx
src/client/gfx/font.onyx
src/client/gfx/texture.onyx
src/client/globals.onyx
src/client/main.onyx
src/client/world/world.onyx
src/config.onyx
src/server/server.onyx

diff --git a/.vscode/launch.json b/.vscode/launch.json
new file mode 100644 (file)
index 0000000..24e8776
--- /dev/null
@@ -0,0 +1,30 @@
+{
+    "version": "0.2.0",
+    "configurations": [
+        {
+            "name": "Attach",
+            "type": "onyx",
+            "request": "attach",
+            "socketPath": "/tmp/ovm-debug.0000",
+            "stopOnEntry": true,
+            "debugServer": 5876
+        },
+        {
+            "name": "Launch",
+            "type": "onyx",
+            "request": "launch",
+            "wasmFile": "game.wasm",
+            "workingDir": "${workspaceFolder}/run_tree",
+            "stopOnEntry": true,
+            "preLaunchTask": "Build Game"
+        },
+        {
+            "name": "Launch Server",
+            "type": "onyx",
+            "request": "launch",
+            "wasmFile": "server.wasm",
+            "workingDir": "${workspaceFolder}/server",
+            "stopOnEntry": true
+        }
+    ]
+}
index 3eb74f17fdfa1c2c8b167ef7849b2913f2a47772..f55ab3a26c4deb545922632ac66ad33863bfac01 100644 (file)
                 "kind": "build",
                 "isDefault": true
             }
+        },
+        {
+            "label": "Build Game",
+            "type": "shell",
+            "problemMatcher": "$onyx",
+            "options": {
+                "cwd": "${workspaceFolder}/run_tree",
+                "shell": {
+                    "executable": "/bin/sh",
+                    "args": ["-c"]
+                }
+            },
+            "presentation": {
+                "echo": true,
+                "reveal": "silent",
+                "focus": false,
+                "panel": "shared",
+                "showReuseMessage": false,
+                "clear": false
+            },
+            "windows": {
+                "command": "run.bat",
+            },
+            "linux": {
+                "command": "./run.sh",
+                "args": ["build", "--debug"]
+            },
+            "group": {
+                "kind": "build",
+                "isDefault": true
+            }
         }
     ]
 }
\ No newline at end of file
diff --git a/doc/todo.org b/doc/todo.org
new file mode 100644 (file)
index 0000000..a15ac91
--- /dev/null
@@ -0,0 +1,6 @@
+
+* TODO Add pick-up-able items (guns, ammo, etc.)
+
+* TODO Add UI (hotbar, current item, etc.)
+
+* TODO Separate client and server with current code
diff --git a/lib/onyx-net b/lib/onyx-net
deleted file mode 160000 (submodule)
index 97c1582..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 97c1582fda5f2881588a1fc0296ba9401af8bb7e
index 61025bea08db042465f6d7026d870ae0a9e131e7..7370e6921649d0a18e96c38c8a0c1aad454c52b3 100755 (executable)
@@ -1,2 +1,6 @@
 
-onyx -V build -I ../src/client -o game.wasm $@ && onyx-run game.wasm
+case "$1" in
+    build) onyx -V build -I ../src/client -o game.wasm $@ ;;
+    debug) onyx-run --debug game.wasm ;;
+    *)     onyx-run game.wasm ;;
+esac
index 9464f8e1d00cf99bda319acc0b377d0d54c8c844..b740f252cd8d3d0f76e38c26dbc07f2589ec5bc4 100755 (executable)
@@ -1,3 +1,7 @@
 #!/bin/sh
 
-onyx -V build -I ../src/server -o server.wasm $@ && onyx-run server.wasm
\ No newline at end of file
+case "$1" in
+    build) onyx -V build -I ../src/server -o server.wasm $@ ;;
+    debug) onyx-run --debug server.wasm ;;
+    *)     onyx-run server.wasm ;;
+esac
index 0460890446f614c207b27347dc330d50c72fc059..48b44202fcf015fa1c3cec1e558ff8fb7433fe87 100644 (file)
@@ -8,7 +8,7 @@ use stb_truetype
     world_shader: Shader;
 
     chat_font: Font;
-    
+
     fog_color :: Vector3.{ 0.6, 0.6, 0.6 };
 }
 
@@ -16,7 +16,7 @@ use stb_truetype
 font: Font;
 player: Player;
 world: ^World;
-player_manager: ^Player_Manager;
+player_manager: ^Player_Manager
 selected_block: Vector3i;
 
 player_shader: Shader;
@@ -103,7 +103,7 @@ game_update :: (_: rawptr, dt: f32) {
 }
 
 #local {
-    send_movement_timeout := 0.0f;    
+    send_movement_timeout := 0.0f;
 }
 
 
index 755c571f270e2169985b9a8dd101ee2a3baead3f..f9dee0d1ba7131f21c92553bab8ec303ee164fc4 100644 (file)
@@ -1,6 +1,5 @@
 
 use core
-use core.intrinsics.onyx {__zero_value}
 use stb_truetype
 use opengles
 
@@ -81,7 +80,7 @@ font_make :: (fd: FontDescriptor) -> Font {
     ttf_file := os.get_contents(fd.path);
     if ttf_file.count == 0 {
         println("Bad font");
-        return __zero_value(Font);
+        return .{};
     }
     defer cfree(ttf_file.data);
 
index da353b9325d73a5fef6b6399f1eba9f82855166c..0cf82726214f31fa519adb333fd68a3a465fc04e 100644 (file)
@@ -1,6 +1,5 @@
 
 use core
-use core.intrinsics.onyx { __zero_value as Zero }
 use opengles
 use stb_image
 
@@ -34,7 +33,7 @@ texture_lookup :: #match {}
     pixels := stbi_load(path, ^tex.width, ^tex.height, ^tex.channels, 4);
     if pixels == null {
         debug_log(.Warning, "Failed to load texture: {}", filename);
-        return Zero(Texture), false;
+        return .{}, false;
     }
     defer stbi_image_free(pixels);
 
@@ -85,4 +84,4 @@ texture_cache_clear :: () {
     }
 
     map.clear(^texture_cache);
-}
\ No newline at end of file
+}
index 8ea3318c5939a6b447b9d3c411da286a4af45fb0..4776e63849c482f2eafbb1702bbe4be9489d3707 100644 (file)
@@ -1,4 +1,5 @@
 
-@GlobalVariable window: glfw3.GLFWwindow_p;
+use glfw3 { GLFWwindow_p }
+@GlobalVariable window: GLFWwindow_p;
 
 debug_screen := false;
index 728a7be91f217519692cc5c7f13c5ba9b1717b54..6ae413bf2dcdbd39f072818c051353b20e8582a7 100644 (file)
@@ -7,12 +7,12 @@ use core.intrinsics.onyx { __initialize }
 State :: struct {
     data:   rawptr;
 
-    init:   (rawptr) -> void          = null_proc;
-    deinit: (rawptr) -> void          = null_proc;
-    enter:  (rawptr, ^State) -> void  = null_proc;
-    leave:  (rawptr) -> void          = null_proc;
-    update: (rawptr, dt: f32) -> void = null_proc;
-    draw:   (rawptr) -> void          = null_proc;
+    init:   (rawptr) -> void;
+    deinit: (rawptr) -> void;
+    enter:  (rawptr, ^State) -> void;
+    leave:  (rawptr) -> void;
+    update: (rawptr, dt: f32) -> void;
+    draw:   (rawptr) -> void;
 }
 
 #local state_stack: [..] State;
index c8e6faabd0234d35f202786250af2563e2bf8b2e..66d5d5d48722d8e5ad61daaa21e332a5274abfec 100644 (file)
@@ -12,7 +12,7 @@ World :: struct {
 
 world_make :: (allocator := context.allocator) -> ^World {
     world := new(World, allocator);
-    world.chunk_dist = 2;
+    world.chunk_dist = 1;
     world.center_chunk = .{0,0,0};
 
     sl := world.chunk_dist * 2 + 1;
index 12a4d4cbbc66d348b48bb19f65c622c17b68cfc4..9d0ad7c20fd97dac42578197b4b85ac1b45dcaf0 100644 (file)
@@ -1,6 +1,6 @@
 package runtime.vars
 
-Enable_Heap_Debug :: true
+// Enable_Heap_Debug :: true
 
 Game_Version :: 0x0001
 Game_Port :: cast(u16) 5123
index 3b5957ade202025f6a21d3ec3b28e3a1e82d51ce..abf004ecd2d340d3eb3cafb4fd5e1f92ca460d4c 100644 (file)
@@ -9,10 +9,10 @@ Player_Data :: struct {
     name: str;
     peer: ^onet.Peer;
 
-    position: Vector3 = .{0,0,0};
-    velocity: Vector3 = .{0,0,0};
-    facing:   Vector3 = .{0,0,0};
-    on_ground        := false;
+    position: Vector3;
+    velocity: Vector3;
+    facing:   Vector3;
+    on_ground: bool;
 }
 
 max_connected_players := 8;