fix rotation
This commit is contained in:
parent
5c87f27348
commit
0c759245c7
1 changed files with 8 additions and 4 deletions
12
js/Player.js
12
js/Player.js
|
@ -22,7 +22,7 @@ export class Player extends Cube {
|
||||||
if (demo) {
|
if (demo) {
|
||||||
listEnnemies.forEach((ennemy) => {
|
listEnnemies.forEach((ennemy) => {
|
||||||
const pos = ennemy.position.x - this.data.position.x;
|
const pos = ennemy.position.x - this.data.position.x;
|
||||||
if (pos < Math.random() * 2.8 + 0.2 && pos > 0) {
|
if (pos < Math.random() * 1.5 + 0.5 && pos > 0) {
|
||||||
dispatchEvent(jumpDemo);
|
dispatchEvent(jumpDemo);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -31,7 +31,7 @@ export class Player extends Cube {
|
||||||
// If we jump
|
// If we jump
|
||||||
if (this.movementData.state) {
|
if (this.movementData.state) {
|
||||||
// Rotation
|
// Rotation
|
||||||
this.data.rotation.y -= this.movementData.rotationVelocity;
|
this.data.rotation.y -= this.movementData.rotationVelocity / 1.6;
|
||||||
|
|
||||||
// If we're falling (2nd part of the jump)
|
// If we're falling (2nd part of the jump)
|
||||||
if (this.movementData.falling()) {
|
if (this.movementData.falling()) {
|
||||||
|
@ -69,8 +69,12 @@ export class Player extends Cube {
|
||||||
*/
|
*/
|
||||||
controlUser = (key) => {
|
controlUser = (key) => {
|
||||||
if (key.code == "Space" && !this.movementData.state) {
|
if (key.code == "Space" && !this.movementData.state) {
|
||||||
this.movementData.changeRotation(this.data.rotation.y - Math.PI);
|
this.movementData.changeRotation(
|
||||||
this.movementData.changeJump(this.data.position.y + Math.PI);
|
this.data.rotation.y - Math.PI / 2
|
||||||
|
);
|
||||||
|
this.movementData.changeJump(
|
||||||
|
3 * this.data.position.y + Math.PI / 2
|
||||||
|
);
|
||||||
this.movementData.changeState();
|
this.movementData.changeState();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Reference in a new issue