diff options
author | alaric <alaric@netmythos.org> | 2024-04-08 00:12:12 -0700 |
---|---|---|
committer | alaric <alaric@netmythos.org> | 2024-04-08 00:12:12 -0700 |
commit | 2869f122c5e4bc3516c8427b3e35c45085823595 (patch) | |
tree | d5fff13976d7c4f48a429c6355be936069ce0388 | |
parent | 4aef5c2443bd6eb57c6be3ff9bfa422c3ce3d2cf (diff) | |
download | snake-master.tar.gz snake-master.zip |
-rw-r--r-- | UNLICENSE | 24 | ||||
-rw-r--r-- | src/shell.html | 10 | ||||
-rw-r--r-- | src/wasm_snake.zig | 6 |
3 files changed, 32 insertions, 8 deletions
diff --git a/UNLICENSE b/UNLICENSE new file mode 100644 index 0000000..68a49da --- /dev/null +++ b/UNLICENSE @@ -0,0 +1,24 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to <http://unlicense.org/> diff --git a/src/shell.html b/src/shell.html index 6fc484c..1499c8d 100644 --- a/src/shell.html +++ b/src/shell.html @@ -8,7 +8,7 @@ body { overflow: hidden; min-width: 1280px; - min-height: 720px; + min-height: 100vh; display: flex; flex-direction: column; margin: 0; @@ -17,10 +17,7 @@ box-sizing: border-box; display: flex; flex-grow: 1; - width: 1280px; - max-height: 720px; height: 100%; - border: solid 1px black; } </style> </head> @@ -28,8 +25,6 @@ <canvas id="app-canvas" tabindex="0"></canvas> <script src="webgl.js"></script> <script> - canvas.width = parseFloat(window.getComputedStyle(canvas).getPropertyValue("width")); - canvas.height = parseFloat(window.getComputedStyle(canvas).getPropertyValue("height")); let memory = null; let last_frame_time = Date.now(); @@ -122,6 +117,9 @@ const update = obj.instance.exports.update; function step() { + const canvas_style = window.getComputedStyle(canvas); + canvas.width = parseFloat(canvas_style.getPropertyValue("width")); + canvas.height = parseFloat(canvas_style.getPropertyValue("height")); const time = Date.now(); const elapsed = time - last_frame_time; update(elapsed / 1000); diff --git a/src/wasm_snake.zig b/src/wasm_snake.zig index 98ba1b4..25691b0 100644 --- a/src/wasm_snake.zig +++ b/src/wasm_snake.zig @@ -295,9 +295,10 @@ export fn update(delta_time: f32) void { } fn drawGrid() void { + const dims = webgl.getScreenSize(); grid_prog.use(); grid_prog.setUniform(.anim_t, anim_acc * 8); - grid_prog.setUniform(.matrix, comptime projectionMatrix2D(1280, 720)); + grid_prog.setUniform(.matrix, projectionMatrix2D(dims[0], dims[1])); grid_prog.setUniform(.scale, grid.scale); grid_prog.setUniform(.columns, grid.width); grid_prog.setUniform(.gap, grid.gap); @@ -307,8 +308,9 @@ fn drawGrid() void { } fn drawEntities() void { + const dims = webgl.getScreenSize(); general_prog.use(); - const proj = comptime projectionMatrix2D(1280, 720); + const proj = projectionMatrix2D(dims[0], dims[1]); general_prog.setUniform(.projection, proj); // Snake |