-
Notifications
You must be signed in to change notification settings - Fork 0
/
sketch.js
65 lines (49 loc) · 1.38 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
const Engine = Matter.Engine;
const World= Matter.World;
const Bodies = Matter.Bodies;
var engine, world;
var box1, pig1;
var backgroundImg,platform;
function preload() {
backgroundImg = loadImage("sprites/bg.png");
}
function setup(){
var canvas = createCanvas(1200,400);
engine = Engine.create();
world = engine.world;
ground = new Ground(600,height,1200,20);
platform = new Ground(150, 305, 400, 70);
box1 = new Box(700,320,70,70);
box2 = new Box(920,320,70,70);
pig1 = new Pig(810, 350);
log1 = new Log(810,260,300, PI/2);
box3 = new Box(700,240,70,70);
box4 = new Box(920,240,70,70);
pig3 = new Pig(810, 220);
log3 = new Log(810,180,300, PI/2);
box5 = new Box(810,160,70,70);
log4 = new Log(760,120,150, PI/7);
log5 = new Log(870,120,150, -PI/7);
bird = new Bird(100,100);
}
function draw(){
background(backgroundImg);
Engine.update(engine);
console.log(box2.body.position.x);
console.log(box2.body.position.y);
console.log(box2.body.angle);
box1.display();
box2.display();
ground.display();
pig1.display();
log1.display();
box3.display();
box4.display();
pig3.display();
log3.display();
box5.display();
log4.display();
log5.display();
bird.display();
platform.display();
}