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){ | function circleCollide(x, y){ | ||||||
|  |   let colliding = false; | ||||||
|   objectsModule.objects.circles.forEach((circle)=>{ |   objectsModule.objects.circles.forEach((circle)=>{ | ||||||
|     if(norm(x, circle.x, y, circle.y)<=circle.radius){ |     if(norm(x, circle.x, y, circle.y)<=circle.r){ | ||||||
|       return true; |       colliding = true; | ||||||
|     } |     } | ||||||
|   }) |   }) | ||||||
|   return false; |   return colliding; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function squareCollide(x, y){ | function squareCollide(x, y){ | ||||||
|  |   let colliding = false; | ||||||
|   objectsModule.objects.squares.forEach((square)=>{ |   objectsModule.objects.squares.forEach((square)=>{ | ||||||
|     if(square.x <= x && x<=square.x+square.w && square.y<=y && y<=square.y+square.h){ |     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(){ | function generatePosition(){ | ||||||
|  | @ -52,7 +54,6 @@ function generatePosition(){ | ||||||
|     x = Math.floor(Math.random()*mapWidth); |     x = Math.floor(Math.random()*mapWidth); | ||||||
|     y = Math.floor(Math.random()*mapHeight); |     y = Math.floor(Math.random()*mapHeight); | ||||||
|     count++; |     count++; | ||||||
|     console.log(x,y, count); |  | ||||||
|     if(count >= 1000){ |     if(count >= 1000){ | ||||||
|       break; |       break; | ||||||
|     } |     } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue