Small fixes
This commit is contained in:
parent
86a65fc39c
commit
0c381e26d3
17
game.js
17
game.js
@ -71,6 +71,7 @@ function handleKeys(params) {
|
|||||||
const ori = se3.roty(params.camera.orientation[1]);
|
const ori = se3.roty(params.camera.orientation[1]);
|
||||||
const tf = se3.apply(ori, dir);
|
const tf = se3.apply(ori, dir);
|
||||||
const maxSpeed = 0.1;
|
const maxSpeed = 0.1;
|
||||||
|
const airMovement = 0.08;
|
||||||
|
|
||||||
if (params.flying) {
|
if (params.flying) {
|
||||||
params.camera.position[0] += tf[0];
|
params.camera.position[0] += tf[0];
|
||||||
@ -80,14 +81,16 @@ function handleKeys(params) {
|
|||||||
params.camera.velocity[0] = tf[0];
|
params.camera.velocity[0] = tf[0];
|
||||||
params.camera.velocity[2] = tf[2];
|
params.camera.velocity[2] = tf[2];
|
||||||
} else {
|
} else {
|
||||||
params.camera.velocity[0] += tf[0] / 60;
|
const vel = params.camera.velocity;
|
||||||
params.camera.velocity[2] += tf[2] / 60;
|
|
||||||
|
|
||||||
if (Math.abs(params.camera.velocity[0]) > maxSpeed) {
|
vel[0] += tf[0] * airMovement;
|
||||||
params.camera.velocity[0] = Math.sign(params.camera.velocity[0]) * maxSpeed;
|
vel[2] += tf[2] * airMovement;
|
||||||
}
|
|
||||||
if (Math.abs(params.camera.velocity[2]) > maxSpeed) {
|
const curVel = Math.sqrt(vel[0] * vel[0] + vel[2] * vel[2]);
|
||||||
params.camera.velocity[2] = Math.sign(params.camera.velocity[2]) * maxSpeed;
|
|
||||||
|
if (curVel > maxSpeed) {
|
||||||
|
vel[0] *= maxSpeed / curVel;
|
||||||
|
vel[2] *= maxSpeed / curVel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
3
world.js
3
world.js
@ -115,9 +115,10 @@ function makeChunk(z, x) {
|
|||||||
data.set(Array(waterHeight - currentHeight).fill(BlockType.WATER), offset + currentHeight);
|
data.set(Array(waterHeight - currentHeight).fill(BlockType.WATER), offset + currentHeight);
|
||||||
currentHeight = waterHeight;
|
currentHeight = waterHeight;
|
||||||
} else {
|
} else {
|
||||||
data[offset + grassHeight - 1] = BlockType.GRASS;
|
|
||||||
if (hasATree(seed, z + i, x + j)) {
|
if (hasATree(seed, z + i, x + j)) {
|
||||||
trees.push([i, j, currentHeight]);
|
trees.push([i, j, currentHeight]);
|
||||||
|
} else {
|
||||||
|
data[offset + grassHeight - 1] = BlockType.GRASS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
data.set(Array(256 - currentHeight).fill(BlockType.AIR), offset + currentHeight);
|
data.set(Array(256 - currentHeight).fill(BlockType.AIR), offset + currentHeight);
|
||||||
|
Loading…
Reference in New Issue
Block a user