-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
81 lines (75 loc) · 3.55 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<html>
<head>
<title>tiles-js</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<style>
* {border: 0px; width: 100%; height: 100%; margin: 0px;}
canvas {position: absolute; background: transparent;}
</style>
<script src="board.js"></script>
<script src="mathutils.js"></script>
<script src="geom.js"></script>
<script src="color.js"></script>
<script src="boardplane.js"></script>
<script src="generator.js"></script>
<script src="terrain.js"></script>
<script src="area.js"></script>
<script src="world.js"></script>
<script>
function updateCanvasSize(canvas) {
canvas.width = canvas.clientWidth;
canvas.height = canvas.clientHeight;
}
function start() {
var tileCanvas = document.getElementById("canvas");
var overlayCanvas = document.getElementById("canvasOverlay");
updateCanvasSize(tileCanvas);
updateCanvasSize(overlayCanvas);
function resizeCallback() {
updateCanvasSize(tileCanvas);
updateCanvasSize(overlayCanvas);
plane.updateSize();
plane.render();
}
window.addEventListener("resize", resizeCallback);
var bo = new Board(500, 500);
var tempBoard = new Board(500, 500);
tempBoard.iteratePositions((x, y) => tempBoard.set(x, y, 0));
var randGen = new RandomTerrainGenerator([0, 1], [150, 1]);
var adjMap = new Terrain8AdjMapper();
var terraGrow = new Operator(adjMap, new Terrain8LandGrow(2));
var terraSmoother = new Operator(adjMap, new Terrain8Smoother());
var terraMaxSmoother = new Operator(adjMap, new Terrain8MaxSmoother(0.5));
var terraSmootherPr = new Operator(adjMap, new Terrain8LandSmoother());
var forestSeeder = new Operator(adjMap, new Terrain8ForestSeeder());
var forestGrower = new Operator(adjMap, new Terrain8ForestGrow());
var grassGrow = new Operator(adjMap, new Terrain8GrassGrow());
var grassSeed = new Operator(adjMap, new Terrain8GrassSeed());
randGen.generate(bo);
terraGrow.apply(bo, tempBoard, 9);
terraSmoother.apply(bo, tempBoard, 4);
grassSeed.apply(bo, tempBoard, 1);
grassGrow.apply(bo, tempBoard, 5);
terraSmootherPr.apply(bo, tempBoard, 8);
terraMaxSmoother.apply(bo, tempBoard);
forestSeeder.apply(bo, tempBoard);
forestGrower.apply(bo, tempBoard, 6);
var plane = new TilePlane(bo, 20, tileCanvas, overlayCanvas);
resizeCallback();
plane.updateSize();
plane.render();
// function renderLoop() {
// plane.render();
// window.requestAnimationFrame(renderLoop);
// }
// window.requestAnimationFrame(renderLoop);
//startWaterAnim(board, plane);
}
</script>
</head>
<body onload="start()">
<canvas id="canvas"></canvas>
<canvas id="canvasOverlay"></canvas>
</body>
</html>