Advertisement
Guest User

SpriteSheet

a guest
May 29th, 2013
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. public class SpriteSheet {
  2.  
  3. private String path;
  4. final int SIZE;
  5. public int[] pixels;
  6.  
  7. public static SpriteSheet tiles = new SpriteSheet("/textures/SpriteSheet.png", 256);
  8.  
  9. public SpriteSheet(String path, int size) {
  10. this.path = path;
  11. this.SIZE = size;
  12. pixels = new int[SIZE*SIZE];
  13. load();
  14. }
  15.  
  16. private void load() {
  17. try {
  18. BufferedImage image = ImageIO.read(SpriteSheet.class.getResource(path));
  19. int w = image.getWidth();
  20. int h = image.getHeight();
  21. image.getRGB(0, 0, w, h, pixels, 0, w);
  22. }
  23. catch (IOException e) {
  24. e.printStackTrace();
  25. }
  26. }
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement