var Engine = Matter.Engine,
Constraint = Matter.Constraint,
MouseConstraint = Matter.MouseConstraint;
birdImage=loadImage("image-1.png.png")
pigImage=loadImage("image-1.png (1).png")
const canvas=createCanvas(windowWidth, windowHeight);
ball=new Ball(250,windowHeight/2,50,50)
slingshot = new Slingshot(250,windowHeight/2,ball.body)
ground = new Ground(windowWidth/2,windowHeight-75,windowWidth*2,150)
World.add(world, ground);
const mouse=Mouse.create(canvas.elt)
const options={mouse:mouse}
mouse.pixelRatio = pixelDensity();
mConstraint=MouseConstraint.create(engine,options)
World.add(world,mConstraint)
pigs.push(new Pig(625,450,50,50))
pigs.push(new Pig(875, 440, 50, 50));
boxes.push(new Box(625,300,100,25))
boxes.push(new Box(580,440,25,75))
boxes.push(new Box(670,400,25,75))
boxes.push(new Box(875,300,100,25))
boxes.push(new Box(830,440,25,75))
boxes.push(new Box(920,400,25,75))
function mouseReleased() {
World.remove(world,ball.body)
ball=new Ball(250,windowHeight/2,50,50)
slingshot.attach(ball.body)
function moveAllBoxes() {
box.body.position.x = 10000
function goToNextLevel() {
pigs.push(new Pig(500,450,50,50))
pigs.push(new Pig(1000, 450, 50, 50))
pigs.push(new Pig(1200, 450, 50, 50))
boxes.push(new Box(500,300,100,25))
boxes.push(new Box(450,440,25,75))
boxes.push(new Box(550,400,25,75))
boxes.push(new Box(1000,300,100,25))
boxes.push(new Box(950,440,25,75))
boxes.push(new Box(1050,400,25,75))
pigs.push(new Pig(500,450,50,50))
pigs.push(new Pig(1000, 450, 50, 50))
pigs.push(new Pig(1200, 450, 50, 50))
boxes.push(new Box(600,400,100,25))
boxes.push(new Box(500,490,25,75))
boxes.push(new Box(550,400,25,75))
boxes.push(new Box(500,450,50,20))
pigs.push(new Pig(600,450,50,50))
pigs.push(new Pig(1000, 450, 50, 50))
boxes.push(new Box(1000,300,100,25))
boxes.push(new Box(950,440,25,75))
boxes.push(new Box(1050,400,25,75))
pigs.push(new Pig(700,450,50,50))
boxes.push(new Box(650,400,25,25))
boxes.push(new Box(700,400,25,75))
boxes.push(new Box(450,400,25,75))
pigs.push(new Pig(1000, 450, 50, 50))
pigs.push(new Pig(1000, 450, 50, 50))
boxes.push(new Box(1000,300,100,25))
boxes.push(new Box(950,440,25,75))
boxes.push(new Box(1050,400,25,75))
boxes.push(new Box(1000,300,100,25))
boxes.push(new Box(950,440,25,75))
boxes.push(new Box(1050,400,25,75))
let pigAmt = pigs.length;
for (let i = 0; i < pigAmt; i++) {
if (pigs[i].body.position.x > width || pigs[i].body.position.x < 0) {
return result === pigAmt;
text("Level: " + level, 50, 50);