Platform
Resources
Pricing
Sign in
Contact us
Andrew Wooldridge
📜JavaScript developer. 🐲RPG fan. 📚Storyteller and 🕹game developer. 👨Father and Husband.
Workspace
Fork
Published
Kaboom Examples
By
Andrew Wooldridge
Edited
Jun 6, 2021
Fork of
Kaboom 0.5.1
1
Insert cell
Insert cell
Insert cell
<
canvas
id
=
"kb"
>
</
canvas
>
Insert cell
K
=
KABOOM
(
{
width
:
480
,
// width of canvas
height
:
480
,
// height of canvas
canvas
:
document
.
getElementById
(
"kb"
)
,
clearColor
:
[
0
,
0
,
0
,
1
]
,
crisp
:
true
}
)
;
Insert cell
{
K
.
scene
(
"main"
,
(
)
=>
{
// for(let i =0; i < numTiles; i++){
// K.add([
// K.sprite("tiles",{
// frame: i
// }),
// K.scale(4),
// K.pos(K.rand(0,420), K.rand(0,420))
// ])
// }
K
.
render
(
(
)
=>
{
K
.
drawSprite
(
"tiles"
,
{
pos
:
K
.
vec2
(
240
)
,
scale
:
K
.
time
(
)
,
origin
:
"center"
,
rot
:
K
.
time
(
)
,
frame
:
frame
,
}
)
;
}
)
}
)
;
K
.
start
(
"main"
)
;
}
Insert cell
tiles
=
K
.
loadSprite
(
"tiles"
,
await
FileAttachment
(
"colored_transparent_packed.png"
)
.
url
(
)
,
{
sliceX
:
48
,
sliceY
:
22
}
)
Insert cell
numTiles
=
1056
Insert cell
frame
=
Math
.
floor
(
Math
.
random
(
)
*
numTiles
)
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.
Try it for free
Learn more
Compare fork
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
K
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
tiles
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
numTiles
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
frame
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML