Kaboom

Kaboom is a JavaScript library that helps you make games fast and fun!
Start playing around with it in the Kaboom Playground
Examples
kaboom()
setGravity(2400)
loadSprite("bean", "sprites/bean.png")
const bean = add([
sprite("bean"),
pos(80, 40),
area(),
body(),
])
onKeyPress("space", () => {
bean.jump()
})
Kaboom uses a powerful component system to compose game objects and behaviors.
const player = add([
sprite("bean"),
pos(100, 200),
area(),
body(),
health(8),
"player",
"friendly",
{
dir: vec2(-1, 0),
dead: false,
speed: 240,
},
])
Blocky imperative syntax for describing behaviors
player.onCollide("enemy", () => {
player.hurt(1)
})
player.onUpdate(() => {
if (player.pos.y >= height()) {
destroy(player)
gameOver()
}
})
player.onCollide("enemy", () => {
player.hp -= 1
})
onUpdate("enemy", (e) => {
e.move(player.pos.sub(e.pos).unit().scale(e.speed))
})
onKeyDown("w", () => {
player.move(0, 100)
})
Usage
Start a Project With create-kaboom
The fastest way to start a Kaboom game is with create-kaboom
$ npm init kaboom mygame
This will create a directory called mygame for you, containing all the files we need
$ cd mygame
$ npm run dev
Then open http://localhost:5173 and edit src/game.js
Install as NPM Package
$ npm install kaboom
import kaboom from "kaboom"
kaboom()
add([
text("oh hi"),
pos(80, 40),
])
also works with CommonJS
const kaboom = require("kaboom")
Note that you'll need to use a bundler like esbuild or webpack to use Kaboom with NPM
Browser CDN
This exports a global kaboom function
<script src="https://unpkg.com/kaboom@3000/dist/kaboom.js"></script>
<script>
kaboom()
</script>
or use with es modules
<script type="module">
import kaboom from "https://unpkg.com/kaboom@3000/dist/kaboom.mjs"
kaboom()
</script>
works all CDNs that supports NPM packages, e.g. jsdelivr, skypack
Documentation
Dev
npm install to install dev packages
npm run dev to start dev server
- go to http://localhost:8000/ and pick an example
- edit examples in
examples/ to test
Check out CONTRIBUTION.md for full info.
Games
Collection of games made with Kaboom, selected by Kaboom, here.
Misc