game: add: use straight line colision (Not finished)

This commit is contained in:
2024-02-01 17:37:46 +01:00
parent beb0cd4702
commit 5f8c42d0c3
3 changed files with 87 additions and 43 deletions

View File

@ -57,12 +57,8 @@ class Ball
{
let distance = this.speed * (this.game.time.deltaTime() / 1000)
let angle_radian = this.angle * Math.PI / 180
console.log(angle_radian)
this.position.x = this.position.x + distance * Math.cos(angle_radian);
this.position.y = this.position.y + distance * Math.sin(angle_radian);
this.position.x = this.position.x + distance * Math.cos(this.angle);
this.position.y = this.position.y + distance * Math.sin(this.angle);
this.draw(ctx);
}