Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 300
- ________________
- | |
- | |
- | | 300
- | X |
- | |
- | |
- |_______________|
- const square = [ 150, 150 ];
- let avenues = [] // will contain start and end [[sx,sy],[ex,ey]]
- const n_avenues = RANDOM(4, 8); // number of avenues
- const n_av_from_square = RANDOM(0, avenues); // starting in the square
- for av in av_from_square
- avenues.push(square, [RANDOM(0, 200) + 100, RANDOM(0, 200) + 100])
- // we want avenues to have, at least 100 units length, thats why we randomize just te last 200 units of the whole town size
- 300
- ________________
- | \ |
- | \ |
- | \ | 300
- | X===== |
- | |
- | |
- |_______________|
- for av in (n_avenues - av_from_square){
- const av_to_intersect = avenues[RANDOM(0,avenues.length)];
- //check av_to... and get a perpendicular vector (explained bellow)
- av[0] = [ av_to_intersect[0][1], - av_to_intersect[0][0] ];
- av[1] = [ av_to_intersect[1][1], - av_to_intersect[1][0] ];
- }
- 300
- ________________
- | \ // |
- | \// || |
- | \ || | 300
- | //X===== |
- | // || |
- | || |
- |_______________|
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement