Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pixel-eight

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pixel-eight

A library inspired by the pico-8 API for writing games for the Kano Pixel

  • 0.0.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

Pixel 8

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

Usage

You can setup a pixel-8 project thus:

mkdir demo
cd demo
npm init -y
yarn add pixel-eight

Example Program

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

Contributing

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

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.

Keywords

FAQs

Package last updated on 26 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc