From: Brendan Hansen Date: Fri, 12 Aug 2022 21:59:10 +0000 (-0500) Subject: random changes X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=11aa1d3e19b2f6ac818a2c5d63370c41a242a302;p=voxel-shooter.git random changes --- diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..24e8776 --- /dev/null +++ b/.vscode/launch.json @@ -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 + } + ] +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 3eb74f1..f55ab3a 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -31,6 +31,37 @@ "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 index 0000000..a15ac91 --- /dev/null +++ b/doc/todo.org @@ -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 index 97c1582..0000000 --- a/lib/onyx-net +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 97c1582fda5f2881588a1fc0296ba9401af8bb7e diff --git a/run_tree/run.sh b/run_tree/run.sh index 61025be..7370e69 100755 --- a/run_tree/run.sh +++ b/run_tree/run.sh @@ -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 diff --git a/server/run.sh b/server/run.sh index 9464f8e..b740f25 100755 --- a/server/run.sh +++ b/server/run.sh @@ -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 diff --git a/src/client/game.onyx b/src/client/game.onyx index 0460890..48b4420 100644 --- a/src/client/game.onyx +++ b/src/client/game.onyx @@ -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; } diff --git a/src/client/gfx/font.onyx b/src/client/gfx/font.onyx index 755c571..f9dee0d 100644 --- a/src/client/gfx/font.onyx +++ b/src/client/gfx/font.onyx @@ -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); diff --git a/src/client/gfx/texture.onyx b/src/client/gfx/texture.onyx index da353b9..0cf8272 100644 --- a/src/client/gfx/texture.onyx +++ b/src/client/gfx/texture.onyx @@ -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 +} diff --git a/src/client/globals.onyx b/src/client/globals.onyx index 8ea3318..4776e63 100644 --- a/src/client/globals.onyx +++ b/src/client/globals.onyx @@ -1,4 +1,5 @@ -@GlobalVariable window: glfw3.GLFWwindow_p; +use glfw3 { GLFWwindow_p } +@GlobalVariable window: GLFWwindow_p; debug_screen := false; diff --git a/src/client/main.onyx b/src/client/main.onyx index 728a7be..6ae413b 100644 --- a/src/client/main.onyx +++ b/src/client/main.onyx @@ -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; diff --git a/src/client/world/world.onyx b/src/client/world/world.onyx index c8e6faa..66d5d5d 100644 --- a/src/client/world/world.onyx +++ b/src/client/world/world.onyx @@ -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; diff --git a/src/config.onyx b/src/config.onyx index 12a4d4c..9d0ad7c 100644 --- a/src/config.onyx +++ b/src/config.onyx @@ -1,6 +1,6 @@ package runtime.vars -Enable_Heap_Debug :: true +// Enable_Heap_Debug :: true Game_Version :: 0x0001 Game_Port :: cast(u16) 5123 diff --git a/src/server/server.onyx b/src/server/server.onyx index 3b5957a..abf004e 100644 --- a/src/server/server.onyx +++ b/src/server/server.onyx @@ -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;