-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsketch.js
More file actions
60 lines (42 loc) · 1.27 KB
/
Copy pathsketch.js
File metadata and controls
60 lines (42 loc) · 1.27 KB
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
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 ball;
var blower;
var blowerMouth;
var button;
function setup() {
var canvas = createCanvas(500, 500);
engine = Engine.create();
world = engine.world;
ball = new Ball(width / 2 + 80, height / 2 - 80, 80, 80);
blower = new Blower(width / 2 - 50, height / 2 + 50, 150, 20);
blowerMouth = new BlowerMouth(width / 2 + 70, height / 2 + 20, 100, 90);
button = createButton("Click to Blow");
button.position(width / 2, height - 100);
button.class("blowButton");
button.mousePressed(blow);
//buttonPressed(blow);
//button = mousePressed(blow);
//button.mousePressed();
}
function draw() {
background(59);
Engine.update(engine);
blower.show();
ball.show();
blowerMouth.show();
}
function blow() {
Matter.Body.applyForce(ball.body, {x:0, y:0}, {x:0, y:-0.05});
//Matter.Body.applyForce(ball.body, {x:0, y:0}, {x:0, y:0.05});
//Matter.Body.applyForce(ball.body, {x:0, y:0}, {x:0.05, y:0.05});
//Matter.Body.applyForce(ball.body, {x:0, y:0}, {x:-0.05, y:0});
}