Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Sprite {
- public final int SIZE;
- private int x, y;
- private int width, height;
- public int[] pixels;
- private SpriteSheet sheet;
- public static Sprite grass = new Sprite(16, 0, 0, SpriteSheet.tiles);
- public static Sprite flower = new Sprite(16, 0, 1, SpriteSheet.tiles);
- public static Sprite stone = new Sprite(16, 0, 2, SpriteSheet.tiles);
- public static Sprite voidSprite = new Sprite(16, 0xff111111);
- // SpawnLevel Sprite here:
- public static Sprite spawn_grass = new Sprite(16, 0, 0, SpriteSheet.spawnLevel);
- public static Sprite spawn_stone = new Sprite(16, 0, 2, SpriteSheet.spawnLevel);
- public static Sprite spawn_flower = new Sprite(16, 0, 1, SpriteSheet.spawnLevel);
- public static Sprite spawn_water = new Sprite(16, 2, 0, SpriteSheet.spawnLevel);
- public static Sprite spawn_wood = new Sprite(16, 1, 2, SpriteSheet.spawnLevel);
- public static Sprite spawn_wall_1 = new Sprite(16, 2, 2, SpriteSheet.spawnLevel);
- public static Sprite spawn_wall_2 = new Sprite(16, 2, 1, SpriteSheet.spawnLevel);
- public static Sprite spawn_sand = new Sprite(16, 1, 1, SpriteSheet.spawnLevel);
- // projectile sprites here:
- public static Sprite projectile_player = new Sprite(16, 0, 0, SpriteSheet.projectile_player);
- // Particles
- public static Sprite particle_normal = new Sprite(3, 0xAAAAAA);
- // Zombie sprites here: 1:x , 2:y
- public static Sprite zombie_forward = new Sprite(32, 2, 2, SpriteSheet.tiles);
- public static Sprite zombie_back = new Sprite(32, 0, 2, SpriteSheet.tiles);
- public static Sprite zombie_side = new Sprite(32, 1, 2, SpriteSheet.tiles);
- public static Sprite zombie_forward_1 = new Sprite(32, 2, 3, SpriteSheet.tiles);
- public static Sprite zombie_forward_2 = new Sprite(32, 2, 4, SpriteSheet.tiles);
- public static Sprite zombie_back_1 = new Sprite(32, 0, 3, SpriteSheet.tiles);
- public static Sprite zombie_back_2 = new Sprite(32, 0, 4, SpriteSheet.tiles);
- public static Sprite zombie_side_1 = new Sprite(32, 1, 3, SpriteSheet.tiles);
- public static Sprite zombie_side_2 = new Sprite(32, 1, 4, SpriteSheet.tiles);
- // snake sprites here:
- public static Sprite snake_forward = new Sprite(32, 3, 2, SpriteSheet.tiles);
- public static Sprite snake_back = new Sprite(32, 5, 2, SpriteSheet.tiles);
- public static Sprite snake_side = new Sprite(32, 4, 2, SpriteSheet.tiles);
- public static Sprite snake_forward_1 = new Sprite(32, 5, 2, SpriteSheet.tiles);
- public static Sprite snake_forward_2 = new Sprite(32, 5, 3, SpriteSheet.tiles);
- public static Sprite snake_back_1 = new Sprite(32, 3, 2, SpriteSheet.tiles);
- public static Sprite snake_back_2 = new Sprite(32, 3, 3, SpriteSheet.tiles);
- public static Sprite snake_side_1 = new Sprite(32, 4, 2, SpriteSheet.tiles);
- public static Sprite snake_side_2 = new Sprite(32, 4, 3, SpriteSheet.tiles);
- // player Sprite here:
- public static Sprite player_forward = new Sprite(32, 2, 5, SpriteSheet.tiles);
- public static Sprite player_back = new Sprite(32, 0, 5, SpriteSheet.tiles);
- public static Sprite player_side = new Sprite(32, 1, 5, SpriteSheet.tiles);
- public static Sprite player_forward_1 = new Sprite(32, 2, 6, SpriteSheet.tiles);
- public static Sprite player_forward_2 = new Sprite(32, 2, 7, SpriteSheet.tiles);
- public static Sprite player_back_1 = new Sprite(32, 0, 6, SpriteSheet.tiles);
- public static Sprite player_back_2 = new Sprite(32, 0, 7, SpriteSheet.tiles);
- public static Sprite player_side_1 = new Sprite(32, 1, 6, SpriteSheet.tiles);
- public static Sprite player_side_2 = new Sprite(32, 1, 7, SpriteSheet.tiles);
- public Sprite(int size, int x, int y, SpriteSheet sheet) {
- SIZE = size;
- this.width = size;
- this.height = size;
- pixels = new int[SIZE * SIZE];
- this.x = x * size;
- this.y = y * size;
- this.sheet = sheet;
- load();
- }
- public Sprite(int width, int height, int colour) {
- SIZE = -1;
- this.width = width;
- this.height = height;
- pixels = new int[width * height];
- setColour(colour);
- }
- public Sprite(int size, int colour) {
- SIZE = size;
- this.width = size;
- this.height = size;
- pixels = new int[SIZE * SIZE];
- setColour(colour);
- }
- private void setColour(int colour) {
- for (int i = 0; i < width * height; i++) {
- pixels[i] = colour;
- }
- }
- public int getWidth() {
- return width;
- }
- public int getHeight() {
- return height;
- }
- 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) * sheet.SIZE];
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement