Published
Edited
Dec 25, 2020
Importers
Also listed in…
Working Libraries
Insert cell
md`# Hello Kontra`
Insert cell
Insert cell
Insert cell
Insert cell
{
let {canvas} = KONTRA.init(mycanvas)
let sprite = KONTRA.Sprite({
x: 100, // starting x,y position of the sprite
y: 80,
color: 'red', // fill color of the sprite rectangle
width: 20, // width and height of the sprite rectangle
height: 40,
dx: 2 // move the sprite 2px to the right every frame
});
let loop = KONTRA.GameLoop({ // create the main game loop
update: function() { // update the game state
sprite.update();

// wrap the sprites position when it reaches
// the edge of the screen
if (sprite.x > canvas.width) {
sprite.x = -sprite.width;
}
},
render: function() { // render the game state
sprite.render();
}
});
loop.start();
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more