-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsketch.js
73 lines (54 loc) · 1.9 KB
/
sketch.js
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
const Engine = Matter.Engine;
const Render = Matter.Render;
const World = Matter.World;
const Bodies = Matter.Bodies;
const Constraint = Matter.Constraint;
const Body = Matter.Body;
const Composites = Matter.Composites;
const Composite = Matter.Composite;
let engine;
let world;
var ground, bridge;
var leftWall, rightWall;
var jointPoint;
var jointLink;
var stones = [];
function setup() {
createCanvas(windowWidth, windowHeight);
engine = Engine.create();
world = engine.world;
frameRate(80);
ground = new Base(0, height - 10, width * 2, 20, "#795548", true);
leftWall = new Base(300, height / 2 + 50, 600, 100, "#8d6e63", true);
rightWall = new Base(width - 300, height / 2 + 50, 600, 100, "#8d6e63", true);
/*bridge = new Base(15, { x: width / 2 - 400, y: height / 2 });
jointPoint = new Base(width - 600, height / 2 + 10, 40, 20, "#8d6e63", true);*/
bridge = new Bridge(15, { x: width / 2 - 400, y: height / 2 });
jointPoint = new Base(width - 600, height / 2 + 10, 40, 20, "#8d6e63", true);
/*bridge = new Base(15, { x: width / 2 - 400, y: height / 2 });
jointPoint = new Bridge(width - 600, height / 2 + 10, 40, 20, "#8d6e63", true);*/
/*bridge = new Bridge(15, { x: width / 2 - 400, y: height / 2 });
jointPoint = new Bridge(width - 600, height / 2 + 10, 40, 20, "#8d6e63", true);*/
Matter.Composite.add(bridge.body, jointPoint);
//Matter.Composite.add(jointPoint);
// Matter.Composite.add(jointPoint, bridge.body);
//Matter.Composite.add(bridge.body);
jointLink = new Link(bridge, jointPoint);
for (var i = 0; i <= 8; i++) {
var x = random(width / 2 - 200, width / 2 + 300);
var y = random(-10, 140);
var stone = new Stone(x, y, 80, 80);
stones.push(stone);
}
}
function draw() {
background(51);
Engine.update(engine);
ground.show();
bridge.show();
leftWall.show();
rightWall.show();
for (var stone of stones) {
stone.show();
}
}