Tag Archives: Openpixels

OpenPixels: simple sprite sheet with Processing

/**
 * Openpixels example in Processing.
 * This simple example of how to get a sprite 
 * from a sprite sheet.
 */
 
PImage bg;
PImage sprite_sheet;
PImage player;
 
void setup() { 
  // load images
  bg = loadImage("kitchen.png");
  sprite_sheet = loadImage("guy.png");
 
  /* The sprite size is 32x49.
     Look guy.png, the "stand position" is at (36,102). */
 
  player = createImage(32, 49, ARGB);
  player.copy(sprite_sheet, 36, 102, 32, 49, 0, 0, 32, 49);
 
  // set screen size and background
  size(bg.width, bg.height);  
  background(bg);
 
  frameRate(30);
}
 
void draw() { 
  background(bg);
  image(player, 100, 50);
}

See more at OpenPixels.

Getting Openpixels

Openpixels is a project of mine to create a free and open source artistic framework for game projects in any language or platform. It is going pretty well.

You can just download a zip or tar.gz of the latest version.

You may want fork it or get a git working copy of it to later make your own contributions to the project. In this case:

apt-get install git-core
cd ~
git clone git://github.com/silveira/openpixels.git

You will see something like this:

Cloning into openpixels...
remote: Counting objects: 129, done.
remote: Compressing objects: 100% (126/126), done.
remote: Total 129 (delta 17), reused 0 (delta 0)
Receiving objects: 100% (129/129), 784.52 KiB, done.
Resolving deltas: 100% (17/17), done.

And now you have a repository clone at ~/openpixels and you can start hacking.