Getting Started
Install KernelPlay.js and build your first game in minutes.
Installation
Install via npm (recommended) or use the CDN for quick prototyping.
bash
npm install kernelplay-js --save
html
<script type="importmap">
{
"imports": {
"kernelplay-js": "https://cdn.jsdelivr.net/npm/kernelplay-js/dist/kernelplay.es.js",
}
}
</script>
Basic Setup
Create a scene, add an entity with components, and start the game loop.
js
import { Game, Scene, Entity } from "kernelplay-js";
import { TransformComponent, BoxRenderComponent } from "kernelplay-js";
class MyScene extends Scene {
init() {
const box = new Entity();
box.addComponent("transform", new TransformComponent({
position: { x: 400, y: 300 }
}));
box.addComponent("renderer", new BoxRenderComponent({ color: "red" }));
this.addEntity(box);
}
}
class MyGame extends Game {
init() {
const scene = new MyScene("Main");
this.sceneManager.addScene(scene);
this.sceneManager.startScene("Main");
}
}
new MyGame({ width: 800, height: 600, fps: 60 }).start();
✅ That's all it takes!
Your game loop, canvas, and renderer are all handled automatically. Continue reading to explore components, physics, and scripting.