collisions
This commit is contained in:
parent
cfc0ac7c0d
commit
4b42336b06
1 changed files with 9 additions and 10 deletions
19
js/class.js
19
js/class.js
|
@ -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()
|
||||||
|
|
Loading…
Reference in a new issue