WARNING: This is not yet a stable API. It is very likely to change between now and 1.0.0, so don't build anything ambitious with it yet.
A creative coding library for the web.
const game = Bramble.game.create()
const container = document.getElementById('bramble-container')
game.attachTo(container)
game.setSize(500, 500)
const id = 'song'
const assetType = 'sound'
const assetPath = 'test.mp3'
await game.assets.add(id, assetType, assetPath)
let hero = {
position: { x: 0, y: 0 },
size: 50,
colour: 'white'
}
let isPlaying = false
game.setUpdate(({ input, sfx }) => {
hero.position = input.mouse.position
// start / stop the music
if (input.mouse.left.justPressed || input.keyboard.space.justPressed) {
if (isPlaying) {
sfx.stop(id)
} else {
sfx.play(id)
}
isPlaying = !isPlaying
}
})
const blurAmount = 8
game.setRender(({ gfx }) => {
gfx.clear('black')
gfx.blur(() => {
gfx.circle(hero.position, hero.size, {
fill: { colour: hero.colour },
line: { width: 0 }
})
}, blurAmount)
})
game.start()
npm run build:prodnpm version major npm version minor or npm version patchnpm run releaseGenerated using TypeDoc