Angry Birds
(Part 2)
Sketch.js:
const Engine = Matter.Engine;
const World = Matter.World;
const Bodies = Matter.Bodies;
var engine, world;
var box1;
function setup() {
createCanvas(1200, 400);
engine = Engine.create();
world = engine.world;
//First Floor
box1 = new Box(800, 320, 70, 70);
box2 = new Box(1000, 320, 70, 70);
pig1 = new Pig(910, 350);
log1 = new Log(910, 270, 270, 90);
//Second Floor
box3 = new Box(826, 210, 70, 70);
box4 = new Box(990, 210, 70, 70);
pig2 = new Pig(910, 190, 50, 50);
log2 = new Log(910, 100, 300, 90);
bird = new Bird(200, 200);
ground = new Ground(600, height, 1200, 20);
}
function draw() {
background(0);
Engine.update(engine);
box1.display();
box2.display();
pig1.display();
log1.display();
box3.display();
box4.display();
pig2.display();
log2.display();
bird.display();
ground.display();
}
0 Comments: