This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on May 29th, 2013  |  syntax: None  |  size: 1.03 KB  |  views: 39  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. public class Sprite {
  2.  
  3.         public final int SIZE;
  4.         private int x, y;
  5.         private int crap;
  6.         public int[] pixels;
  7.         private SpriteSheet sheet;
  8.        
  9.         public static Sprite grass = new Sprite(32, 0, 0, SpriteSheet.tiles);
  10.         public static Sprite grassRock = new Sprite(32, 1, 0, SpriteSheet.tiles);
  11.         public static Sprite grassFlower = new Sprite(32, 2, 0, SpriteSheet.tiles);
  12.         public static Sprite voidSprite = new Sprite(32, 0xff00ff);
  13.        
  14.         public Sprite(int size, int x, int y, SpriteSheet sheet){
  15.                 SIZE = size;
  16.                 pixels = new int[SIZE*SIZE];
  17.                 this.x = x * size;
  18.                 this.y = y * size;
  19.                 this.sheet = sheet;
  20.                 load();
  21.         }
  22.        
  23.         public Sprite(int size, int color){
  24.                 SIZE = size;
  25.                 pixels = new int[SIZE * SIZE];
  26.                 setColor(color);
  27.         }
  28.        
  29.         private void setColor(int color) {
  30.                 for (int i = 0; i < SIZE*SIZE; i ++){
  31.                         pixels [i] = color;
  32.                 }
  33.         }
  34.  
  35.         private void load() {
  36.                 for (int y = 0; y < SIZE; y++){
  37.                         for (int x = 0; x < SIZE; x++){
  38.                                 pixels[x + y * SIZE] = sheet.pixels[(x + this.x)+(y + this.y) * sheet.SIZE];
  39.                         }
  40.                 }
  41.         }
  42. }
clone this paste RAW Paste Data