Skip to content

Instantly share code, notes, and snippets.

@stmn
Last active February 12, 2022 19:27
Show Gist options
  • Save stmn/b5f782acad691964065c0a9efaeb3ce0 to your computer and use it in GitHub Desktop.
Save stmn/b5f782acad691964065c0a9efaeb3ce0 to your computer and use it in GitHub Desktop.
k.z() problem
import kaboom from "kaboom";
const k = kaboom({
canvas: document.getElementById('canvas'),
})
k.loadSpriteAtlas("./assets/sprites/Tileset.png", {
'traps': {
x: 0,
y: 0,
width: 32,
height: 32,
sliceX: 1,
sliceY: 1
},
})
k.loadSpriteAtlas('./assets/sprites/Tileset.png', {
'grass': {
x: 0,
y: 0,
width: 32,
height: 32,
sliceX: 1,
sliceY: 1,
}
})
k.scene('main', () => {
const map = [
"===========================",
"===========================",
"== ==",
"== ==",
"== ==",
"== == == ==",
"== == ==LLLLL== == ==",
"== ========= ==",
"== ========= ==",
"== == == ==",
"== =LL== ==LL= ==",
"== ===== @ ===== ==",
"== = ==",
"== ==",
"==LLLLL==LLLLLLLLL==LLLLL==",
"===========================",
"===========================",
];
// low fps
k.addLevel(map, {
width: 32,
height: 32,
"=": () => [
k.sprite("grass"),
k.z(11),
],
"L": () => [
k.sprite("traps"),
k.z(11),
],
})
// high fps
// k.addLevel(map, {
// width: 32,
// height: 32,
// "=": () => [
// k.sprite("grass"),
// k.z(10),
// ],
// "L": () => [
// k.sprite("traps"),
// k.z(9),
// ],
// })
}
)
k.go('main')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment