tileOffsetY = (int) ((tileY - posY) * TyrelionMap.TILE_SIZE);
}
public void loadAnimations(String animation) {
animations = new Animation[12];
Animation running_up = new Animation();
Animation running_down = new Animation();
Animation running_left = new Animation();
Animation running_right = new Animation();
Animation standing_up = new Animation();
Animation standing_down= new Animation();
Animation standing_left = new Animation();
Animation standing_right = new Animation();
Animation talking_up = new Animation();
Animation talking_down= new Animation();
Animation talking_left = new Animation();
Animation talking_right = new Animation();
animations[ANIM_RUNNING_UP] = running_up;
animations[ANIM_RUNNING_DOWN] = running_down;
animations[ANIM_RUNNING_LEFT] = running_left;
animations[ANIM_RUNNING_RIGHT] = running_right;
animations[ANIM_STANDING_UP] = standing_up;
animations[ANIM_STANDING_DOWN] = standing_down;
animations[ANIM_STANDING_LEFT] = standing_left;
animations[ANIM_STANDING_RIGHT] = standing_right;
animations[ANIM_TALKING_UP] = talking_up;
animations[ANIM_TALKING_DOWN] = talking_down;
animations[ANIM_TALKING_LEFT] = talking_left;
animations[ANIM_TALKING_RIGHT] = talking_right;
setAnimation(ANIM_STANDING_DOWN);
File root = new File("res/anim/"+animation);
File[] categories = root.listFiles();
if (categories != null){
for (File category : categories) {
if (category.isDirectory() && !category.isHidden()) {
File[] anims = category.listFiles();
for (File elem : anims) {
File[] images = elem.listFiles();
if (images != null) {
for (File image : images) {
if (image.isFile() && !image.isHidden()) {
if ("running".equals(category.getName())) {
try {
if ("up".equals(elem.getName())) {
running_up.addFrame(new Image(image.getAbsolutePath()), 90);
}
if ("down".equals(elem.getName())) {
running_down.addFrame(new Image(image.getAbsolutePath()), 90);
}
if ("left".equals(elem.getName())) {
running_left.addFrame(new Image(image.getAbsolutePath()), 90);
}
if ("right".equals(elem.getName())) {
running_right.addFrame(new Image(image.getAbsolutePath()), 90);
}
} catch (SlickException e) {
e.printStackTrace();
}
} else if ("standing".equals(category.getName())) {
try {
if ("up".equals(elem.getName())) {
standing_up.addFrame(new Image(image.getAbsolutePath()), 90);
}
if ("down".equals(elem.getName())) {
standing_down.addFrame(new Image(image.getAbsolutePath()), 90);
}
if ("left".equals(elem.getName())) {
standing_left.addFrame(new Image(image.getAbsolutePath()), 90);
}
if ("right".equals(elem.getName())) {
standing_right.addFrame(new Image(image.getAbsolutePath()), 90);
}
} catch (SlickException e) {
e.printStackTrace();
}
} else if ("talking".equals(category.getName())) {
try {
if ("up".equals(elem.getName())) {
talking_up.addFrame(new Image(image.getAbsolutePath()), 180);
}
if ("down".equals(elem.getName())) {
talking_down.addFrame(new Image(image.getAbsolutePath()), 180);
}
if ("left".equals(elem.getName())) {
talking_left.addFrame(new Image(image.getAbsolutePath()), 180);
}
if ("right".equals(elem.getName())) {
talking_right.addFrame(new Image(image.getAbsolutePath()), 180);
}
} catch (SlickException e) {
e.printStackTrace();
}
}