Get started with moonjs CDN
MIT licensed
MoonJS is a lightweight library for creating 2D games and interactive applications.
Tags:- moon
- mvvm
- user interface
- UI
Stable version
Copied!
How to start using moonjs CDN
<!DOCTYPE html>
<html>
<head>
<title>Get started with moonjs CDN - cdnhub.io</title>
<script src="https://cdn.cdnhub.io/moonjs/0.11.0/moon.min.js"></script>
</head>
<body>
<script>
// Create a new MoonJS world
const world = new moon.World();
// Create a body with a circular shape and a mass of 10
const body = new moon.Body(10);
body.position.set(100, 100);
body.shape = new moon.CircleShape(5);
// Add the body to the world
world.addBody(body);
// Create a ground body with a static shape and infinite mass
const ground = new moon.Body(Infinity);
ground.position.set(0, world.height);
ground.shape = new moon.BoxShape(world.width, 20);
// Add the ground body to the world
world.addBody(ground);
// Set gravity
world.gravity.set(0, 10);
// Run the simulation for 100 steps
world.step(100);
</script>
<style>
body { margin: 0; }
canvas { width: 100%; height: 100%; border: 1px solid black; }
</style>
</body>
</html>
Copied!
Copied!