A library inspired by the pico-8 API for writing games for the Kano Pixel.
Expect breaking changes every patch / minor until 1.0.0
You can setup a pixel-8 project thus:
mkdir demo
cd demo
npm init -y
yarn add pixel-eight
const { color, createMap, start } = require("pixel-eight");
const { bitmaps } = require("./exported-animation.json");
const map = createMap([
"cccccccccccccccc",
"c c",
"c c",
"c c",
"c c",
"c c",
"c c",
"cccccccccccccccc"
]);
start({
init: () => {
return { x: 1, y: 1 };
},
update: ({ x, y }, { pressed }) => {
if (pressed.down && !map.pget(x, y + 1)) {
y += 1;
}
if (pressed.up && y > 1 && !map.pget(x, y - 1)) {
y -= 1;
}
if (pressed.left && x > 1 && !map.pget(x - 1, y)) {
x -= 1;
}
if (pressed.right && !map.pget(x + 1, y)) {
x += 1;
}
return { x, y };
},
draw: (frame, { x, y }) => {
frame.bset(bitmaps[0]);
frame.mset(0, 0, map, 0);
frame.rect(1, 1, 15, 7, color.pink);
frame.pset(x, y, color.red);
}
});
If you put the above script in a example.js
file, you can then run it:
node ./example.js
If you install nodemon it makes for a good development environment as it'll restart each time you hit save.
yarn add -D nodemon
./node_modules/.bin/nodemon ./example.js
Please read our code of conduct which comes from Contributor Covenant.
If you have questions, suggestions or want to contribute changes please check the issues list to see if it's already been raised, if not please create an issue. Please try to provide lots of context when creating an issue, if it's a bug report please provide reproduction steps, if it's a feature request please describe why it's valuable.
Contact is best done through the repository's issues. Messages that are unsuitable for the issue tracker can be sent as direct message to my twitter profile.