Просмотр исходного кода

generate towers and cities.

cities aren't very exciting yet. and they don't perform well.
Lucas Stadler лет назад: 12
Родитель
Сommit
79b6906e02
1 измененных файлов с 27 добавлено и 0 удалено
  1. 27 0
      js/pixl/public/trixl.html

+ 27 - 0
js/pixl/public/trixl.html

@ -91,6 +91,13 @@
91 91
			});
92 92
		}
93 93
94
		var rand = function(lo, hi) {
95
			var both = hi !== undefined,
96
			    l = both ? lo : 0,
97
			    h = both ? hi : lo;
98
			return l + Math.round(Math.random() * (h - l));
99
		}
100
94 101
		var rgbFromCss = function(color) {
95 102
			var el = document.createElement('div');
96 103
			el.style.color = color;
@ -268,6 +275,26 @@
268 275
			trixl.generate.many(1000, -100, 100);
269 276
		}
270 277
278
		trixl.generate.tower = function(pos, width, height, color) {
279
			range(height).map(function() {
280
				trixl.world.set([
281
					rand(pos[0], pos[0] + width),
282
					rand(pos[1], pos[1] + height),
283
					rand(pos[2], pos[2] + width)
284
				], {color: color || [Math.random(), Math.random(), Math.random(), 1]});
285
			});
286
		}
287
288
		trixl.generate.city = function(n, width, height) {
289
			range(n).map(function() {
290
				var pos = [rand(width), 0, rand(width)];
291
				var w = rand(5, 20);
292
				var h = rand(height);
293
294
				trixl.generate.tower(pos, w, h);
295
			});
296
		}
297
271 298
		trixl.geometry = {};
272 299
273 300
		trixl.geometry.circle = function(pos, radius, color) {