npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bats_can_draw

v0.0.5

Published

pico 8-like functionality over Canvas

Downloads

2

Readme

bats-can-draw

Hey! This is just a quick starter kit for Pico-8-style gamedev on Canvas. It's an NPM package, plus

Namely that means:

  • Fixed framerate (Currently 60)
  • Pixel buffer for draw operations
  • You own the main loop
  • Fixed palette (Currently hardcoded: the pico 8 palette)
  • No scenegraph

I'll probably add some support for Pico-8 style IO later. (I haven't coded this yet)

What I coded

  • I set up the canvas to auto-resize to match the container.
  • I set the code up to run update() at about 60fps and draw() at the browser's chosen framerate
  • I wrote a little demo in main.ts that exploits these features
  • I added a .gitignore which you can adapt for your project
  • I added Pico-8-style keyboard input and graphics operations
  • I set up a little NPM package to include the common code that is not part of the starter kit.

Why you would use this

You might use this if:

  • You hate relinquishing main()
  • You like pushing pixels
  • You're porting a game to JavaScript from pygame or minifb
  • You like TypeScript and want to use that over JavaScript
  • You want hot reloading, breakpoints, and a working debugger, all of which exist in Chrome/Firefox, and which Parcel does not break
  • You want a trivial example of ES6 modules

Gotchas

Parcel seems immature and kind of unstable. When I used <link rel="stylesheet" href="reset.css"> to add my reset.css file, things broke. When I attempted to use parcel with npm, I got a completely broken installation.

In addition, Parcel doesn't use the real typescript compiler and has a default behavior of literally ignoring all type errors. (Note that VS Code will do the right thing and present you with all your errors, and respects the strict setting in tsconfig.json.)

Steps

  • Install Node+NPM and Yarn. (I use Node 16.13.1 LTS and Yarn 1.22.17)
  • Create a project folder (ex. kobolds. You can also just use the existing demo folder)
  • Copy the files in demo to the project folder (ex kobolds/src/index.html et al)
  • Initialize Yarn (yarn init -y)
  • Install Parcel (yarn add --dev parcel. I use 2.1.1)
  • Install bats-can-draw (yarn add file:.. if you just cloned from git and are using the actual demo folder; yarn add bats_can_draw otherwise)
  • Run Parcel from your project (cd kobolds, yarn parcel src/**/* --no-cache)
  • Navigate to Parcel's URL in your browser: http://localhost:1234

What you'll end up with

  • A package.json and yarn.lock file which collectively say "this project uses Parcel and bats-can-draw." You should version control these so other people can build your code on the exact same package configuration.
  • Some parcel-specific folders to not touch (.parcel-cache, dist)
  • Some NPM-specific folders to not touch (node_modules)

The package.json file you end up with will probably look something like this:

{
  "name": "demo",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "devDependencies": {
    "parcel": "^2.1.1"
  },
  "dependencies": {
    "bats_can_draw": "^0.0.1"
  }
}

Man, JavaScript tooling wreaks fucking havoc on your directory structure, doesn't it?

TODO

  • Text
  • Palette, clip, and camera commands
  • Spritesheets

Explicitly not in scope

  • Map/level editor support
  • Sound