Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.thecherno.rain.graphics;
- public class Sprite {
- public final int SIZE;
- private int x, y;
- public int[] pixels;
- private Spritesheet sheet;
- public static Sprite grass = new Sprite(16, 0, 0, Spritesheet.tiles);
- public static Sprite voidSprite = new Sprite(16, 0x2B1BE0);
- public static Sprite player0 = new Sprite(16, 0, 10, Spritesheet.tiles);
- public static Sprite player1 = new Sprite(16, 1, 10, Spritesheet.tiles);
- public static Sprite player2 = new Sprite(16, 0, 11, Spritesheet.tiles);
- public static Sprite player3 = new Sprite(16, 1, 11, Spritesheet.tiles);
- public Sprite(int size, int x, int y, Spritesheet sheet) {
- SIZE = size;
- pixels = new int[SIZE * SIZE];
- this.x = x * size;
- this.y = y * size;
- this.sheet = sheet;
- load();
- }
- public Sprite(int size, int colour) {
- SIZE = size;
- pixels = new int[SIZE*SIZE];
- setColour(colour);
- }
- private void setColour(int colour) {
- for (int i = 0; i < SIZE*SIZE; i++) {
- pixels[i] = colour;
- }
- }
- private void load(){
- for (int y = 0; y < SIZE; y++){
- for (int x = 0; x < SIZE; x++){
- pixels[x+y*SIZE] = sheet.pixels[(x * this.x) + (y * this.y * this.SIZE)];
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement