From 2a552f992b3147a7f3471c5bcf310fcf112d696c Mon Sep 17 00:00:00 2001 From: L3P3 Date: Sun, 11 Aug 2024 12:11:12 +0200 Subject: [PATCH] fix: downl locale, size optimization, --- .gitignore | 6 ++ README.md | 8 ++- build.js | 6 +- dist/.gitkeep | 0 package.json | 5 +- src/game/m_game.js | 2 +- src/game/m_renderer.js | 121 ++++++++++++++++++----------------------- 7 files changed, 73 insertions(+), 75 deletions(-) create mode 100644 .gitignore create mode 100644 dist/.gitkeep diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..eb3c800 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +doc +src/old +dist/* +!dist/.gitkeep +node_modules +package-lock.json diff --git a/README.md b/README.md index 1f5df47..9466881 100644 --- a/README.md +++ b/README.md @@ -61,13 +61,17 @@ Heavily inspired by and somewhat based on the work of [@xNotch](https://github.c - [ ] use gpu? - [ ] get a lawyer? -## How to use while developing +## How to run locally I highly recommend using Visual Studio Code and the extension "Live Server". Start it via "Go Live" and open "http://localhost:5500/app-dev.html" to see the result. +If you use another IDE that does not have a similar feature, you may once do `sudo apt install esbuild`, then run `npm start` and click the link and open `app-dev.html`. But I do not recommend this approach. + ## Build instructions -After cloning, you need to run `npm install` once to install the build tools. +Building is **not needed** unless my server is down and you want to mirror https://l3p3.de/minicraft! + +After cloning, you need to run `npm install` once to install the build tools. The build script is designed to run under Linux, see [the GitHub actions file](.github/workflows/build.yml) and [the build script itself](build.js) to learn more about the build environment. To bundle the app, run `npm run build`. The result will be put into the `/dist` directory and can be tested at "http://localhost:5500/app-prod.html". diff --git a/build.js b/build.js index b12ba35..42ff503 100644 --- a/build.js +++ b/build.js @@ -122,7 +122,8 @@ async function build_js(lang) { (await readFile(TMP_FILE, 'ascii')) .split('actions').join('a') .split('content').join('c') - .split('loaded').join('l'), + .split('loaded').join('l') + .split('downl').join('downloaded'), 'ascii' ); @@ -156,8 +157,7 @@ if( throw new Error('google closure compiler required!'); } -await exec('mkdir -p ./dist'); -await exec('rm ./dist/*'); +await exec('rm ./dist/app*'); console.log(`build ${version} (${prod ? 'production' : 'dev'})...`); diff --git a/dist/.gitkeep b/dist/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/package.json b/package.json index 6fb9799..37a24e7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "minicraft", - "version": "0.11.0", + "version": "0.11.1", "description": "voxel-based 3d game, written in javascript", "homepage": "https://l3p3.de/minicraft", "repository": { @@ -13,7 +13,8 @@ "main": "./src/app.js", "type": "module", "scripts": { - "build": "node build.js" + "build": "node build.js", + "start": "esbuild --servedir=." }, "keywords": [ "minecraft", diff --git a/src/game/m_game.js b/src/game/m_game.js index a0ac6ef..c70d942 100644 --- a/src/game/m_game.js +++ b/src/game/m_game.js @@ -764,7 +764,7 @@ export const game_message_send = (model, value) => { player.speed_z = 0; break; case 'version': - game_message_print(model, 'Minicraft ' + VERSION); + game_message_print(model, 'minicraft ' + VERSION); break; case '/exit': player.mouse_mode = MOUSE_MODE_NORMAL; diff --git a/src/game/m_renderer.js b/src/game/m_renderer.js index 2070aad..b02a318 100644 --- a/src/game/m_renderer.js +++ b/src/game/m_renderer.js @@ -541,73 +541,60 @@ export const renderer_render = (model, now) => { } model.diagnostics = ( - game.flag_diagnostics - ? 'Minicraft ' + VERSION + ' ' + ( - number_padStart2(model.fps, '\xa0') - ) + ' fps, T: ' + ( - number_padStart2(world.time_f * 24, '0') - ) + ':' + ( - number_padStart2((((world.time_f * 24) % 1) * 60), '0') - ) + '; ' + ( - world.flag_paused && - now % 1e3 < 500 - ? '' - : world.time - ) + '\n' + - - 'R: ' + resolution_x + 'x' + resolution_y + - ' (x' + config.resolution_scaling + '), D: ' + config.view_distance + ', ' + - //'S: ' + check_count + ', ' + - 'C: ' + world.chunks_checklist_index + '/' + world.chunks_checklist.length + ', ' + - 'M: ' + ( - number_square( - 1 << (CHUNK_WIDTH_L2 + world.size_l2) - ) - * CHUNK_HEIGHT >> 10 - ) + 'k\n' + - 'E: 0/0 M: ' + player.gamemode + '\n\n' + - - 'Position: ' + ( - number_toFixed2(player.position_x) - ) + ' ' + ( - number_toFixed2(player.position_y) - ) + ' ' + ( - number_toFixed2(player.position_z) - ) + '\n' + - - 'Angle: ' + ( - number_toFixed2(player.angle_h * Math_PI_180d) - ) + ' ' + ( - number_toFixed2(player.angle_v * Math_PI_180d) - ) + '\n' + - 'Block: ' + ( - player.block_focus_y < 0 - ? 0 - : player.block_focus_x + ' ' + - player.block_focus_y + ' ' + - player.block_focus_z + ' ' + - BLOCK_TYPE_FACE_LABELS[player.block_focus_face] + ': ' + - world_block_get( - world, - player.block_focus_x, - player.block_focus_y, - player.block_focus_z - ) - ) + '\n' + - 'Chunk abs: ' + ( - Math_floor(player.position_x) >> CHUNK_WIDTH_L2 - ) + ' ' + ( - Math_floor(player.position_z) >> CHUNK_WIDTH_L2 - ) + ' ' + ( - Math_floor(player.position_y) >> CHUNK_WIDTH_L2 - ) + ' rel: ' + ( - world.focus_x - ) + ' ' + ( - world.focus_z - ) + ' ' + ( - world.focus_y - ) - : '' + game.flag_diagnostics ? +`minicraft ${VERSION} ${ + number_padStart2(model.fps, '\xa0') +} fps, T: ${ + number_padStart2(world.time_f * 24, '0') +}:${ + number_padStart2((((world.time_f * 24) % 1) * 60), '0') +}; ${ + world.flag_paused && + now % 1e3 < 500 + ? '' + : world.time +} +R: ${resolution_x}x${resolution_y} (x${config.resolution_scaling}), D: ${config.view_distance}, C: ${world.chunks_checklist_index}/${world.chunks_checklist.length}, M: ${ + number_square( + 1 << (CHUNK_WIDTH_L2 + world.size_l2) + ) + * CHUNK_HEIGHT >> 10 +}k +E: 0/0 M: ${player.gamemode} + +Position: ${ + number_toFixed2(player.position_x) +} ${ + number_toFixed2(player.position_y) +} ${ + number_toFixed2(player.position_z) +} +Angle: ${ + number_toFixed2(player.angle_h * Math_PI_180d) +} ${ + number_toFixed2(player.angle_v * Math_PI_180d) +} +Block: ${ + player.block_focus_y < 0 + ? 0 + : player.block_focus_x + ' ' + + player.block_focus_y + ' ' + + player.block_focus_z + ' ' + + BLOCK_TYPE_FACE_LABELS[player.block_focus_face] + ': ' + + world_block_get( + world, + player.block_focus_x, + player.block_focus_y, + player.block_focus_z + ) +} +Chunk abs: ${ + Math_floor(player.position_x) >> CHUNK_WIDTH_L2 +} ${ + Math_floor(player.position_z) >> CHUNK_WIDTH_L2 +} ${ + Math_floor(player.position_y) >> CHUNK_WIDTH_L2 +} rel: ${world.focus_x} ${world.focus_z} ${world.focus_y}` : '' ); }