Published
Edited
Dec 27, 2021
Insert cell
Insert cell
Insert cell
cnv = html`<canvas class="game" height="320" width="480"></canvas>`
Insert cell
k = Kaboom({
global: false,
width: 480,
height: 320,
canvas: cnv,
background: [0,0,256]
})
Insert cell
main = {
// k.scene("main", ()=> {
// k.add([
// k.text("oh hi", 32),
// k.pos(100, 100),
// ]);
// })

// k.go("main")
k.loadBean()
k.scene("main", ()=>{
const player = k.add([
k.sprite("bean"), // renders as a sprite
k.pos(120, 80), // position in world
k.area(), // has a collider
k.body(), // responds to physics and gravity
]);
k.onKeyPress("space", () => {
// .jump() is provided by the body() component
player.jump();
});
});
k.go("main")
}
Insert cell
Kaboom = (await import('https://cdn.skypack.dev/kaboom@next?min')).default
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more