collisions

This commit is contained in:
Atsuyo-INSA 2023-12-05 15:18:25 +01:00
parent cfc0ac7c0d
commit 4b42336b06

View file

@ -75,26 +75,25 @@ class Player
this.x += dx*dt; this.x += dx*dt;
this.y += dy*dt; this.y += dy*dt;
for(let square in squares) squares.forEach(square => {
{
if(square.collide(this)) if(square.collide(this))
{ {
this.x-=dx; this.x-=dx*dt;
this.y-=dy; this.y-=dy*dt;
this.dir=0; this.dir=0;
return; return;
} }
} });
for(let circle in circles)
{ circles.forEach(circle => {
if(circle.collide(this)) if(circle.collide(this))
{ {
this.x-=dx; this.x-=dx*dt;
this.y-=dy; this.y-=dy*dt;
this.dir=0; this.dir=0;
return; return;
} }
} });
} }
get angle() get angle()