srv
This commit is contained in:
parent
b910476caf
commit
3ef3d50b59
1 changed files with 7 additions and 6 deletions
|
@ -23,21 +23,23 @@ function norm(x1, x2, y1, y2){
|
|||
}
|
||||
|
||||
function circleCollide(x, y){
|
||||
let colliding = false;
|
||||
objectsModule.objects.circles.forEach((circle)=>{
|
||||
if(norm(x, circle.x, y, circle.y)<=circle.radius){
|
||||
return true;
|
||||
if(norm(x, circle.x, y, circle.y)<=circle.r){
|
||||
colliding = true;
|
||||
}
|
||||
})
|
||||
return false;
|
||||
return colliding;
|
||||
}
|
||||
|
||||
function squareCollide(x, y){
|
||||
let colliding = false;
|
||||
objectsModule.objects.squares.forEach((square)=>{
|
||||
if(square.x <= x && x<=square.x+square.w && square.y<=y && y<=square.y+square.h){
|
||||
return true;
|
||||
colliding = true;
|
||||
}
|
||||
})
|
||||
return false;
|
||||
return colliding;
|
||||
}
|
||||
|
||||
function generatePosition(){
|
||||
|
@ -52,7 +54,6 @@ function generatePosition(){
|
|||
x = Math.floor(Math.random()*mapWidth);
|
||||
y = Math.floor(Math.random()*mapHeight);
|
||||
count++;
|
||||
console.log(x,y, count);
|
||||
if(count >= 1000){
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue