Giter Site home page Giter Site logo

jsgs's Introduction

JSGS is an experimental (WIP) javascript implementation of the Pico-8 fantasy console.

Demos

What's implemented?

  • Graphics api, font
  • Math api
  • Ram / Ram api
  • Reading cartridges, running lua code

What's missing / Quirks

  • Sound (Help needed)
  • sspr function
  • Cursor
  • stat function
  • Not 100% compatible with Pico-8's Lua flavor.
    • No shorthand assignments
    • all() is not implemented (help needed)

Extra features

  • Multiple screen (canvas) support
  • CRT Filter (optional)
  • On screen / Touch controller (very naìve now)
  • Custom color palette

How to use?

It's not yet packaged to be used by importing into your project. For now, the only way to run your cartridges is manually editing the cartridge url in src/index.js file. For cloning/installing/running the project, see "Development" section below.

Classes / Options

JSGS

The JSGS class is the class which we use for creating pico-8 machine instances.

const machine = new JSGS({
  os: new OS(), // an "OS" instance
  devices: {
    controller: new KeyboardController(), // a "Controller" instance
    ram: new Ram(0x8000), // a "Ram" instance
    cartridge: "http://example.com/cartridge.p8.png", // url to a p8.png cartridge
    screen: [new Screen({ size: 128 })], // An array of "Screen" instances
  },
});
Ram
// instantiate a 32kb ram
const ram = new Ram(0x8000);
Screen / CRTScreen
const screen = new Screen({
  size: 128, // a px size (number)
  palette: Screen.greenPalette // And array of 16 hex colors. Defaults to pico-8 palette
});

// Screen with crt filter
const crtScreen = new CRTScreen({
  size: 128,
});

// Mount to dom
screen.mountCanvas(element);
crtScreen.mountCanvas(element);

Development

Requirements

For development, you will need Node.js >=6.0.0 and NPM(comes bundled with Node.js) installed on your environment.

Install

Clone the project and install dependencies:

$ git clone https://github.com/burakcan/jsgs.git
$ cd jsgs
$ npm install

Start & watch

$ npm run start-dev

Now you can browse the app at http://localhost:4000

Build for production

$ npm run build

jsgs's People

Contributors

burakcan avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.