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 Nov 19th, 2012  |  syntax: Java  |  size: 0.79 KB  |  views: 34  |  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. package net.anyspieceofinter.unnamedgameproject.graphics;
  2.  
  3. public class Sprite {
  4.        
  5.         public final int SIZE;
  6.         private int x, y;
  7.         public int[] pixels;
  8.         private Spritesheet sheet;
  9.        
  10.         //sprites in enviroment sheet
  11.         public static Sprite dirt = new Sprite(40, 0, 0, Spritesheet.enviroment);
  12.         public static Sprite square = new Sprite(40, 1, 0, Spritesheet.enviroment);
  13.        
  14.         public Sprite(int size, int x, int y, Spritesheet sheet) {
  15.                
  16.                 SIZE = size;
  17.                 this.x = x * size;
  18.                 this.y = y * size;
  19.                 pixels = new int[SIZE * SIZE];
  20.                 this.sheet = sheet;
  21.                 load();
  22.        
  23.         }
  24.        
  25.         private void load() {
  26.                
  27.                 for(int y = 0; y < SIZE; y++) {
  28.                        
  29.                         for(int x = 0; x < SIZE; x++) {
  30.                                
  31.                                 pixels[x + y * SIZE] = sheet.pixels[(x + this.x) + (y + this.y) * sheet.SIZE];
  32.                                
  33.                         }
  34.                        
  35.                 }
  36.                
  37.         }
  38.        
  39. }
clone this paste RAW Paste Data