summaryrefslogtreecommitdiff
path: root/src/ch/epfl/maze/graphics
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2015-11-25 16:59:33 +0100
committerPacien TRAN-GIRARD2015-11-25 16:59:33 +0100
commitaaa791e77c16585fc4011a63ed9ce33376d4784c (patch)
tree2a30527c5d0e8bdfa2d6f0789167d17e28e261b8 /src/ch/epfl/maze/graphics
parentc7bff348ec66e535a7146cf48907f4c8d785d623 (diff)
downloadmaze-solver-aaa791e77c16585fc4011a63ed9ce33376d4784c.tar.gz
Restore asset path generation
Diffstat (limited to 'src/ch/epfl/maze/graphics')
-rw-r--r--src/ch/epfl/maze/graphics/Animation.java22
1 files changed, 1 insertions, 21 deletions
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 {
220 */ 220 */
221 private BufferedImage loadImage(Animal animal) { 221 private BufferedImage loadImage(Animal animal) {
222 // path = "img/superclass/class.png" 222 // path = "img/superclass/class.png"
223 String superClassName = animal.getClass().getSuperclass().getSimpleName(); 223 String folder = animal.getClass().getSuperclass().getSimpleName();
224 String[] superClassComponents = Animation.splitCamelCase(superClassName);
225 String folder = superClassComponents[superClassComponents.length - 1];
226 String file = animal.getClass().getSimpleName(); 224 String file = animal.getClass().getSimpleName();
227 String path = "img/" + folder + File.separator + file + ".png"; 225 String path = "img/" + folder + File.separator + file + ".png";
228 226
@@ -240,22 +238,4 @@ public final class Animation {
240 return img; 238 return img;
241 } 239 }
242 240
243 /**
244 * Splits a camel case string
245 * http://stackoverflow.com/a/2560017/1348634
246 *
247 * @param s A string
248 * @return An array of words
249 */
250 private static String[] splitCamelCase(String s) {
251 return s.replaceAll(
252 String.format("%s|%s|%s",
253 "(?<=[A-Z])(?=[A-Z][a-z])",
254 "(?<=[^A-Z])(?=[A-Z])",
255 "(?<=[A-Za-z])(?=[^A-Za-z])"
256 ),
257 " "
258 ).split(" ");
259 }
260
261} 241}