Skip to content

Commit

Permalink
fix: downl locale, size optimization,
Browse files Browse the repository at this point in the history
  • Loading branch information
L3P3 committed Aug 11, 2024
1 parent 132b3d8 commit 2a552f9
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 75 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
doc
src/old
dist/*
!dist/.gitkeep
node_modules
package-lock.json
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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".

Expand Down
6 changes: 3 additions & 3 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
);

Expand Down Expand Up @@ -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'})...`);

Expand Down
Empty file added dist/.gitkeep
Empty file.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand All @@ -13,7 +13,8 @@
"main": "./src/app.js",
"type": "module",
"scripts": {
"build": "node build.js"
"build": "node build.js",
"start": "esbuild --servedir=."
},
"keywords": [
"minecraft",
Expand Down
2 changes: 1 addition & 1 deletion src/game/m_game.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
121 changes: 54 additions & 67 deletions src/game/m_renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}` : ''
);
}

Expand Down

0 comments on commit 2a552f9

Please sign in to comment.