Adding Ghost to SpriteLocation
This commit is contained in:
35
src/main/java/se/urmo/game/graphics/SpriteSheet.java
Normal file
35
src/main/java/se/urmo/game/graphics/SpriteSheet.java
Normal file
@ -0,0 +1,35 @@
|
||||
package se.urmo.game.graphics;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
|
||||
public class SpriteSheet {
|
||||
private final BufferedImage[][] spriteSheet;
|
||||
@Getter
|
||||
private final SpriteLocation location;
|
||||
|
||||
public SpriteSheet(SpriteLocation location) {
|
||||
this.location = location;
|
||||
this.spriteSheet = location.loadSprites(location.getSize());
|
||||
}
|
||||
|
||||
public BufferedImage getSprite(int row, int col) {
|
||||
if (location == SpriteLocation.NONE) {
|
||||
return null;
|
||||
}
|
||||
if (row >= spriteSheet.length || col >= spriteSheet[0].length) {
|
||||
return null;
|
||||
}
|
||||
return spriteSheet[row][col];
|
||||
}
|
||||
|
||||
public BufferedImage[] getAnimation(int row) {
|
||||
if(location == SpriteLocation.NONE) return null;
|
||||
|
||||
if(row>= spriteSheet.length) return null;
|
||||
|
||||
return spriteSheet[row];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user