-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdemo3.html
47 lines (43 loc) · 1.38 KB
/
demo3.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Anvil.js No Physics and No Light Demo</title>
<script src="../build/anvil.js"></script>
</head>
<body>
<canvas id="noPhysicsLightCanvas" width="800" height="600"></canvas>
<script>
const { Scene, Polygon, Input, SceneManager } = ANVIL;
const noPhysicsLightCanvas = document.getElementById("noPhysicsLightCanvas");
const noPhysicsLightScene = new Scene({
width: 800,
height: 600,
canvas: noPhysicsLightCanvas,
fpsMonitoringEnabled: true,
start: true,
});
// Create and add polygons
const polygon1 = new Polygon({
points: [[100, 100], [150, 100], [150, 150], [100, 150]],
backgroundColor: "#FF0000",
});
const polygon2 = new Polygon({
points: [[200, 200], [250, 200], [250, 250], [200, 250]],
backgroundColor: "#00FF00",
});
const clickInput = new Input("click", noPhysicsLightCanvas);
clickInput.on = (obj) => {
obj.state("backgroundColor", "#0000FF")
};
clickInput.activate(noPhysicsLightScene);
noPhysicsLightScene.addObject(polygon1);
noPhysicsLightScene.addObject(polygon2);
const sceneManager = new SceneManager({
initialScene: noPhysicsLightScene,
canvas: noPhysicsLightCanvas,
});
</script>
</body>
</html>