Update added propeller, birds and boxes
This commit is contained in:
@ -16,13 +16,21 @@ function drawGround(){
|
||||
////////////////////////////////////////////////////////////////
|
||||
function setupPropeller(){
|
||||
// your code here
|
||||
propeller = Bodies.rectangle(150, 480, 200, 15, {isStatic: true, angle: 0});
|
||||
World.add(engine.world, [propeller]);
|
||||
}
|
||||
////////////////////////////////////////////////////////////////
|
||||
//updates and draws the propeller
|
||||
function drawPropeller(){
|
||||
Body.setAngle(propeller, angle);
|
||||
Body.setAngularVelocity(propeller, angleSpeed);
|
||||
push();
|
||||
// your code here
|
||||
fill(255);
|
||||
//translate(propeller.position.x, propeller.position.y);
|
||||
//rotate(propeller.angle);
|
||||
drawVertices(propeller.vertices);
|
||||
pop();
|
||||
angle += angleSpeed;
|
||||
}
|
||||
////////////////////////////////////////////////////////////////
|
||||
function setupBird(){
|
||||
@ -35,19 +43,47 @@ function setupBird(){
|
||||
////////////////////////////////////////////////////////////////
|
||||
function drawBirds(){
|
||||
push();
|
||||
//your code here
|
||||
for (let i = 0; i < birds.length; i++)
|
||||
{
|
||||
drawVertices(birds[i].vertices);
|
||||
if(isOffScreen(birds[i]))
|
||||
{
|
||||
World.remove(engine.world, birds[i]);
|
||||
birds.splice(i, 1);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
pop();
|
||||
console.log("# Birds: ", birds.length);
|
||||
console.log("# World Bodies: ", engine.world.bodies.length);
|
||||
}
|
||||
////////////////////////////////////////////////////////////////
|
||||
//creates a tower of boxes
|
||||
function setupTower(){
|
||||
//you code here
|
||||
boxes = Composites.stack(500, 100, 3, 6, 0, 0,
|
||||
function(x,y){
|
||||
let partA = Bodies.rectangle(x, y, 80, 80, {density: 0.001});
|
||||
colors.push(Math.trunc(random(100, 255)));
|
||||
return Body.create({parts: [partA]});
|
||||
});
|
||||
Composite.add(engine.world, [boxes]);
|
||||
}
|
||||
////////////////////////////////////////////////////////////////
|
||||
//draws tower of boxes
|
||||
function drawTower(){
|
||||
push();
|
||||
//your code here
|
||||
for (let i = 0; i < boxes.bodies.length; i++) {
|
||||
fill(0, colors[i], 0);
|
||||
noStroke();
|
||||
drawVertices(boxes.bodies[i].vertices);
|
||||
if(isOffScreen(boxes.bodies[i]))
|
||||
{
|
||||
World.remove(engine.world, boxes.bodies[i]);
|
||||
boxes.bodies.splice(i, 1);
|
||||
colors.splice(i, 1);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
pop();
|
||||
}
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user