implement ingame menu

This commit is contained in:
LabyStudio
2022-02-03 16:02:55 +01:00
parent 64b84c3f64
commit 5eb1d03e5d
14 changed files with 179 additions and 69 deletions
+7 -3
View File
@@ -31,7 +31,7 @@ window.Minecraft = class {
this.worldRenderer.scene.add(this.world.group);
// Create player
this.player = new Player(this.world);
this.player = new Player(this, this.world);
this.pickedBlock = 1;
// Initialize
@@ -48,6 +48,10 @@ window.Minecraft = class {
this.requestNextFrame();
}
hasInGameFocus() {
return this.window.mouseLocked && this.currentScreen === null;
}
requestNextFrame() {
let scope = this;
requestAnimationFrame(function () {
@@ -88,7 +92,7 @@ window.Minecraft = class {
onRender(partialTicks) {
// Player rotation
if (this.window.mouseLocked && !(this.currentScreen === "null")) {
if (this.hasInGameFocus()) {
this.player.turn(this.window.mouseMotionX, this.window.mouseMotionY);
this.window.mouseMotionX = 0;
@@ -112,7 +116,7 @@ window.Minecraft = class {
if (screen === null) {
this.window.requestFocus();
} else {
screen.init(this, this.window.width, this.window.height);
screen.setup(this, this.window.width, this.window.height);
}
}