Hello World with Matter.js

A basic example with matter.js. Note: this does not actually use p5.js at all.

Source Code for this Sketch

const { Bodies, Body, Composite, Engine, Render, Runner, World } = Matter

let engine = Engine.create()
let runner = Runner.create()
let render = Render.create({
	canvas: canvas,
	engine: engine,
	options: {
		background: null,
		wireframes: false,
		// showStats: true,
		// showPerformance: true,
	},
})

let boxA = Bodies.circle(400, 200, 80)
let boxB = Bodies.circle(450, 50, 80)
let ground = Bodies.rectangle(400, 610, 600, 60, { isStatic: true })

Composite.add(engine.world, [boxA, boxB, ground])

Render.run(render)
Runner.run(runner, engine)

You may use all or part of the p5 code seen on this page for your own creations, without restriction. Attribution is appreciated but not required.

This sketch also includes the following sources: p5common.js matter.js . Sources are available under their respective licenses.

See all p5.js sketches