Advertisement
Guest User

Untitled

a guest
Jun 20th, 2013
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. package com.thethiorix.rain.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. public static Sprite grass = new Sprite(16, 0, 0, SpriteSheet.tiles);
  11. public static Sprite voidSprite= new Sprite(16, 0xB87E0);
  12.  
  13. public Sprite(int size, int x, int y, SpriteSheet sheet) {
  14. SIZE = size;
  15. pixels = new int[SIZE * SIZE];
  16. this.x = x * size;
  17. this.y = y * size;
  18. this.sheet = sheet;
  19. load();
  20. }
  21.  
  22. public Sprite(int size, int color) {
  23. SIZE = size;
  24. pixels = new int[SIZE * SIZE];
  25. setColor(color);
  26. }
  27.  
  28. public void setColor(int color) {
  29. for (int i = 0; i < SIZE*SIZE; i++) {
  30. pixels[i] = color;
  31.  
  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.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement