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.y += dy*dt;
|
||||
|
||||
for(let square in squares)
|
||||
{
|
||||
squares.forEach(square => {
|
||||
if(square.collide(this))
|
||||
{
|
||||
this.x-=dx;
|
||||
this.y-=dy;
|
||||
this.x-=dx*dt;
|
||||
this.y-=dy*dt;
|
||||
this.dir=0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
for(let circle in circles)
|
||||
{
|
||||
});
|
||||
|
||||
circles.forEach(circle => {
|
||||
if(circle.collide(this))
|
||||
{
|
||||
this.x-=dx;
|
||||
this.y-=dy;
|
||||
this.x-=dx*dt;
|
||||
this.y-=dy*dt;
|
||||
this.dir=0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
get angle()
|
||||
|
|
Loading…
Reference in a new issue