BlockTextures.pde 467 B

12345678910111213141516171819
  1. public class BlockTextures {
  2. private PImage terrain;
  3. private HashMap<Integer, PImage> sprites;
  4. public BlockTextures() {
  5. terrain = loadImage("terrain.png");
  6. sprites = new HashMap<Integer, PImage>();
  7. for (int row = 0; row < 16; row++) {
  8. for (int column = 0; column < 16; column++) {
  9. sprites.put((16*row)+column, terrain.get(column*16, row*16, 16, 16));
  10. }
  11. }
  12. }
  13. public PImage get(int id) {
  14. return sprites.get(id);
  15. }
  16. }