From aaa791e77c16585fc4011a63ed9ce33376d4784c Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Wed, 25 Nov 2015 16:59:33 +0100 Subject: Restore asset path generation --- src/ch/epfl/maze/graphics/Animation.java | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) (limited to 'src/ch/epfl') diff --git a/src/ch/epfl/maze/graphics/Animation.java b/src/ch/epfl/maze/graphics/Animation.java index 497d417..9882231 100644 --- a/src/ch/epfl/maze/graphics/Animation.java +++ b/src/ch/epfl/maze/graphics/Animation.java @@ -220,9 +220,7 @@ public final class Animation { */ private BufferedImage loadImage(Animal animal) { // path = "img/superclass/class.png" - String superClassName = animal.getClass().getSuperclass().getSimpleName(); - String[] superClassComponents = Animation.splitCamelCase(superClassName); - String folder = superClassComponents[superClassComponents.length - 1]; + String folder = animal.getClass().getSuperclass().getSimpleName(); String file = animal.getClass().getSimpleName(); String path = "img/" + folder + File.separator + file + ".png"; @@ -240,22 +238,4 @@ public final class Animation { return img; } - /** - * Splits a camel case string - * http://stackoverflow.com/a/2560017/1348634 - * - * @param s A string - * @return An array of words - */ - private static String[] splitCamelCase(String s) { - return s.replaceAll( - String.format("%s|%s|%s", - "(?<=[A-Z])(?=[A-Z][a-z])", - "(?<=[^A-Z])(?=[A-Z])", - "(?<=[A-Za-z])(?=[^A-Za-z])" - ), - " " - ).split(" "); - } - } -- cgit v1.2.3