Physics Engine (Code)

 const Engine = Matter.Engine;

const World = Matter.World;
const Bodies = Matter.Bodies;

var engine, world;

function setup() {
  createCanvas(400400);

  engine = Engine.create();
  world = engine.world;

  var ground_options = {
    isStatic: true,
  };

  var ball_object = {
    restitution: 1.0,
  };

  ground = Bodies.rectangle(20039040020, ground_options);
  World.add(world, ground);

  ball = Bodies.circle(20010020, ball_object);
  World.add(world, ball);

  console.log(ground);
}

function draw() {
  background(0);

  Engine.update(engine);

  rectMode(CENTER);
  rect(ground.position.x, ground.position.y, 40020);

  ellipseMode(RADIUS);
  ellipse(ball.position.x, ball.position.y, 2020);
}

0 Comments: