diff --git a/res/images/Item.png b/res/images/items/item.png similarity index 100% rename from res/images/Item.png rename to res/images/items/item.png diff --git a/res/images/Item2.png b/res/images/items/item2.png similarity index 100% rename from res/images/Item2.png rename to res/images/items/item2.png diff --git a/res/images/Item3.png b/res/images/items/item3.png similarity index 100% rename from res/images/Item3.png rename to res/images/items/item3.png diff --git a/res/images/Item4.png b/res/images/items/item4.png similarity index 100% rename from res/images/Item4.png rename to res/images/items/item4.png diff --git a/res/images/shot.png b/res/images/shots/ballshot.png similarity index 100% rename from res/images/shot.png rename to res/images/shots/ballshot.png diff --git a/res/images/shot02.png b/res/images/shots/laser_blue.png similarity index 100% rename from res/images/shot02.png rename to res/images/shots/laser_blue.png diff --git a/res/images/shot03.png b/res/images/shots/laser_green.png similarity index 100% rename from res/images/shot03.png rename to res/images/shots/laser_green.png diff --git a/res/images/shot04.png b/res/images/shots/laser_red.png similarity index 100% rename from res/images/shot04.png rename to res/images/shots/laser_red.png diff --git a/res/images/shot05.png b/res/images/shots/laser_yellow.png similarity index 100% rename from res/images/shot05.png rename to res/images/shots/laser_yellow.png diff --git a/src/de/teamteamteam/spacescooter/background/item/TestItem1.java b/src/de/teamteamteam/spacescooter/background/item/TestItem1.java index 809fe9c..fea29c4 100644 --- a/src/de/teamteamteam/spacescooter/background/item/TestItem1.java +++ b/src/de/teamteamteam/spacescooter/background/item/TestItem1.java @@ -6,7 +6,7 @@ public class TestItem1 extends Items{ public TestItem1(int x, int y) { super(x, y); - this.setImage("images/Item.png"); + this.setImage("images/items/item.png"); } @Override diff --git a/src/de/teamteamteam/spacescooter/background/item/TestItem2.java b/src/de/teamteamteam/spacescooter/background/item/TestItem2.java index 2e8c199..6e19222 100644 --- a/src/de/teamteamteam/spacescooter/background/item/TestItem2.java +++ b/src/de/teamteamteam/spacescooter/background/item/TestItem2.java @@ -8,7 +8,7 @@ public class TestItem2 extends Items{ public TestItem2(int x, int y) { super(x, y); - this.setImage("images/Item2.png"); + this.setImage("images/items/item2.png"); } @Override diff --git a/src/de/teamteamteam/spacescooter/background/item/TestItem3.java b/src/de/teamteamteam/spacescooter/background/item/TestItem3.java index 74f68ec..51951f7 100644 --- a/src/de/teamteamteam/spacescooter/background/item/TestItem3.java +++ b/src/de/teamteamteam/spacescooter/background/item/TestItem3.java @@ -8,7 +8,7 @@ public class TestItem3 extends Items{ public TestItem3(int x, int y) { super(x, y); - this.setImage("images/Item3.png"); + this.setImage("images/items/item3.png"); } @Override diff --git a/src/de/teamteamteam/spacescooter/background/item/TestItem4.java b/src/de/teamteamteam/spacescooter/background/item/TestItem4.java index cacdda7..94f9eb3 100644 --- a/src/de/teamteamteam/spacescooter/background/item/TestItem4.java +++ b/src/de/teamteamteam/spacescooter/background/item/TestItem4.java @@ -8,7 +8,7 @@ public class TestItem4 extends Items{ public TestItem4(int x, int y) { super(x, y); - this.setImage("images/Item4.png"); + this.setImage("images/items/item4.png"); } @Override diff --git a/src/de/teamteamteam/spacescooter/entity/Player.java b/src/de/teamteamteam/spacescooter/entity/Player.java index 541251e..1ccbadb 100644 --- a/src/de/teamteamteam/spacescooter/entity/Player.java +++ b/src/de/teamteamteam/spacescooter/entity/Player.java @@ -17,6 +17,7 @@ public class Player extends ShootingEntity implements KeyboardListener { public Player(int x, int y) { super(x, y); this.setImage("images/ship.png"); + this.setPrimaryShotImage("images/shots/laser_blue.png"); this.setShootDelay(20); this.setShootSpawn(50, 16); this.setShootDirection(Shot.RIGHT); diff --git a/src/de/teamteamteam/spacescooter/entity/ShootingEntity.java b/src/de/teamteamteam/spacescooter/entity/ShootingEntity.java index 582828b..6c6175c 100644 --- a/src/de/teamteamteam/spacescooter/entity/ShootingEntity.java +++ b/src/de/teamteamteam/spacescooter/entity/ShootingEntity.java @@ -13,7 +13,7 @@ public abstract class ShootingEntity extends LivingEntity { private int shootDirection; private int damageValue = 5; private int shootSpeed; - private String primaryShotImage = "images/shot02.png"; + private String primaryShotImage; public ShootingEntity(int x, int y) { super(x, y); @@ -34,18 +34,15 @@ public abstract class ShootingEntity extends LivingEntity { } } - /** - * Override this method in the actual enemy class to change the type of shot the entity creates. - */ public void createShot() { new Shot( - this.x + this.shootSpawnX, - this.y + this.shootSpawnY, - this.shootDirection, - this.shootSpeed, - this.damageValue, - this.primaryShotImage - ); + this.x + this.shootSpawnX, + this.y + this.shootSpawnY, + this.shootDirection, + this.shootSpeed, + this.damageValue, + this.primaryShotImage + ); } public void setCanShoot(boolean canShoot) { diff --git a/src/de/teamteamteam/spacescooter/entity/enemy/Enemy.java b/src/de/teamteamteam/spacescooter/entity/enemy/Enemy.java index a767401..2871e27 100644 --- a/src/de/teamteamteam/spacescooter/entity/enemy/Enemy.java +++ b/src/de/teamteamteam/spacescooter/entity/enemy/Enemy.java @@ -12,7 +12,6 @@ public abstract class Enemy extends ShootingEntity { this.name = "EnemyOne"; this.willShoot = r.nextBoolean(); this.setShootDirection(Shot.LEFT); - this.setPrimaryShotImage("images/shot03.png"); } protected String name; diff --git a/src/de/teamteamteam/spacescooter/entity/enemy/EnemyFour.java b/src/de/teamteamteam/spacescooter/entity/enemy/EnemyFour.java index 1affc54..192a493 100644 --- a/src/de/teamteamteam/spacescooter/entity/enemy/EnemyFour.java +++ b/src/de/teamteamteam/spacescooter/entity/enemy/EnemyFour.java @@ -16,6 +16,7 @@ public class EnemyFour extends Enemy{ public EnemyFour(int x, int y, ArrayList points) { super(x, y); this.setImage("images/enemy01.png"); + this.setPrimaryShotImage("images/shots/laser_yellow.png"); this.setShootSpeed(4); this.setShootDelay(42); this.setShootSpawn(-10, 10); diff --git a/src/de/teamteamteam/spacescooter/entity/enemy/EnemyOne.java b/src/de/teamteamteam/spacescooter/entity/enemy/EnemyOne.java index 3fed60e..4691ba7 100644 --- a/src/de/teamteamteam/spacescooter/entity/enemy/EnemyOne.java +++ b/src/de/teamteamteam/spacescooter/entity/enemy/EnemyOne.java @@ -5,6 +5,7 @@ public class EnemyOne extends Enemy { public EnemyOne(int x, int y) { super(x, y); this.setImage("images/nyancat.png"); + this.setPrimaryShotImage("images/shots/laser_red.png"); this.setShootSpeed(2); this.setShootDelay(42); this.setShootSpawn(-8, 10); diff --git a/src/de/teamteamteam/spacescooter/entity/enemy/EnemyThree.java b/src/de/teamteamteam/spacescooter/entity/enemy/EnemyThree.java index b01d0cb..039762b 100644 --- a/src/de/teamteamteam/spacescooter/entity/enemy/EnemyThree.java +++ b/src/de/teamteamteam/spacescooter/entity/enemy/EnemyThree.java @@ -20,6 +20,7 @@ public class EnemyThree extends Enemy{ super(x, y); random = new Random(); this.setImage("images/enemy02.png"); + this.setPrimaryShotImage("images/shots/laser_red.png"); this.setShootSpeed(4); this.setShootDelay(42); this.setShootSpawn(-10, 10); diff --git a/src/de/teamteamteam/spacescooter/entity/enemy/EnemyTwo.java b/src/de/teamteamteam/spacescooter/entity/enemy/EnemyTwo.java index 14d3d43..2095680 100644 --- a/src/de/teamteamteam/spacescooter/entity/enemy/EnemyTwo.java +++ b/src/de/teamteamteam/spacescooter/entity/enemy/EnemyTwo.java @@ -10,6 +10,7 @@ public class EnemyTwo extends Enemy{ super(x, y); Random random = new Random(); this.setImage("images/enemy02.png"); + this.setPrimaryShotImage("images/shots/laser_green.png"); this.setShootSpeed(4); this.setShootDelay(42); this.setShootSpawn(-10, 10); diff --git a/src/de/teamteamteam/spacescooter/utility/CodeEnvironment.java b/src/de/teamteamteam/spacescooter/utility/CodeEnvironment.java index aa1bcad..4100bd7 100644 --- a/src/de/teamteamteam/spacescooter/utility/CodeEnvironment.java +++ b/src/de/teamteamteam/spacescooter/utility/CodeEnvironment.java @@ -44,17 +44,29 @@ public class CodeEnvironment { } /** - * Return a list of files based on a given folder. + * Return a relative path list of files based on a given folder. */ private static String[] getFileListFromFolder(File folder) { ArrayList fileList = new ArrayList(); String rootPath = folder.getAbsolutePath() + File.separator; + String[] folderContents = CodeEnvironment.getAbsoluteFileListFromFolder(folder); + for(String element : folderContents) { + fileList.add(element.replace(rootPath, "")); + } + return fileList.toArray(new String[fileList.size()]); + } + + /** + * Recursively generate an absolute path list of elements within a folder. + */ + private static String[] getAbsoluteFileListFromFolder(File folder) { + ArrayList fileList = new ArrayList(); File[] folderContents = folder.listFiles(); for(File f : folderContents) { if(f.isDirectory()) { - String[] filesInDirectory = CodeEnvironment.getFileListFromFolder(f); + String[] filesInDirectory = CodeEnvironment.getAbsoluteFileListFromFolder(f); for(String entry : filesInDirectory) { - fileList.add(entry.replace(rootPath, "")); + fileList.add(entry); } } else { fileList.add(f.toString()); @@ -64,7 +76,7 @@ public class CodeEnvironment { } /** - * Returns a list of files that are contained within the current jar. + * Returns a relative path list of files that are contained within the current jar. */ private static String[] getFileListFromJar(URL jar) { List list = new ArrayList(); diff --git a/src/de/teamteamteam/spacescooter/utility/Loader.java b/src/de/teamteamteam/spacescooter/utility/Loader.java index 5d09d9d..ded2c88 100644 --- a/src/de/teamteamteam/spacescooter/utility/Loader.java +++ b/src/de/teamteamteam/spacescooter/utility/Loader.java @@ -45,11 +45,17 @@ public class Loader { * Return the loaded BufferedImage by its relative filename. */ public static BufferedImage getBufferedImageByFilename(String filename) { + BufferedImage image = null; if(CodeEnvironment.isJar()) { - return Loader.images.get(filename); + image = Loader.images.get(filename); } else { - return Loader.images.get(filename.replace("/", File.separator)); + image = Loader.images.get(filename.replace("/", File.separator)); } + + if(image == null) { + System.err.println("Could not get BufferedImage by filename: '" + filename + "'"); + } + return image; } /** @@ -95,7 +101,7 @@ public class Loader { try { BufferedImage image = ImageIO.read(Loader.class.getClassLoader().getResourceAsStream(filename)); Loader.images.put(filename, image); - } catch (IOException e) { + } catch (Exception e) { System.err.println("Unable to load BufferedImage: " + filename); e.printStackTrace(); }