@city41/ardusprites
convert pngs to sprites for ArduBoy programs
Last updated 2 years ago by mgreer .
MIT · Original npm · Tarball · package.json
$ cnpm install @city41/ardusprites -g
SYNC missed versions from official npm registry.

ardusprites

A simple tool that converts pngs into sprite data for ArduBoy programs.

This is basically a command line version of Team A.R.G.'s arduboy-sprite-converter. The main code that converts the data was taken from their tool.

how to use

  1. Create a sprite image containing all your tiles. It needs to be vertically oriented. You must name it <name>_<width>x<height>.png
  2. npm install -g @city41/ardusprites
  3. ardusprites -s <src directory of pngs> -o <dest file to write the sprite data to>

ie: ardusprites -s myGame/myPngs -o myGame/mySprites.h

How to create masks

When drawing your sprites, any pixel that is not pure white (255,255,255,255) and not pure black (0,0,0,255) will be part of the mask. I tend to make my sprites be white, black and a grey for the mask.

Generated data

This tool will generate three arrays per png: the sprites, the masks for the sprites, and the sprites and masks combined into one. If you don't need all three, no worries, just don't use the ones you don't need. When building your sketch, GCC won't include any unused arrays, so no worries about bloating your Sketch size.

how to use the resulting code in an ArduBoy program

You need to use the Sprites class as provided by Arduboy2. For example, if you want to render a sprite from mySprites.h

#include <SPI.h>
#include <EEPROM.h>
#include <Arduboy2.h>

#include "mySprites.h"

Sprites sprites;


void setup() {
    arduboy.begin();
    arduboy.setFrameRate(60);
}


void loop() {
    if (!arduboy.nextFrame()) {
        return;
    }

    arduboy.clear();

    sprites.drawOverwrite(
        /* x coord in pixels      */  0,
        /* y coord in pixels      */  0,
        /* pointer to sprite data */  myGameSprite_tiles,
        /* which frame to draw    */  0
    );

    arduboy.display();
}

Current Tags

  • 2.0.3                                ...           latest (2 years ago)

9 Versions

  • 2.0.3                                ...           2 years ago
  • 2.0.2                                ...           2 years ago
  • 2.0.1                                ...           2 years ago
  • 2.0.0                                ...           2 years ago
  • 1.1.1                                ...           2 years ago
  • 1.1.0                                ...           2 years ago
  • 1.0.2                                ...           2 years ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 1
This Week 1
This Month 15
Last Day 0
Last Week 10
Last Month 4
Dependencies (2)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |