implement ingame menu
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user