Advertisement
Guest User

Untitled

a guest
May 27th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. 300
  2. ________________
  3. | |
  4. | |
  5. | | 300
  6. | X |
  7. | |
  8. | |
  9. |_______________|
  10.  
  11. const square = [ 150, 150 ];
  12.  
  13. let avenues = [] // will contain start and end [[sx,sy],[ex,ey]]
  14. const n_avenues = RANDOM(4, 8); // number of avenues
  15. const n_av_from_square = RANDOM(0, avenues); // starting in the square
  16.  
  17. for av in av_from_square
  18. avenues.push(square, [RANDOM(0, 200) + 100, RANDOM(0, 200) + 100])
  19. // we want avenues to have, at least 100 units length, thats why we randomize just te last 200 units of the whole town size
  20.  
  21. 300
  22. ________________
  23. | \ |
  24. | \ |
  25. | \ | 300
  26. | X===== |
  27. | |
  28. | |
  29. |_______________|
  30.  
  31. for av in (n_avenues - av_from_square){
  32. const av_to_intersect = avenues[RANDOM(0,avenues.length)];
  33.  
  34. //check av_to... and get a perpendicular vector (explained bellow)
  35. av[0] = [ av_to_intersect[0][1], - av_to_intersect[0][0] ];
  36. av[1] = [ av_to_intersect[1][1], - av_to_intersect[1][0] ];
  37.  
  38. }
  39.  
  40. 300
  41. ________________
  42. | \ // |
  43. | \// || |
  44. | \ || | 300
  45. | //X===== |
  46. | // || |
  47. | || |
  48. |_______________|
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement