Create subfolders for shot images and item images.
Before Width: | Height: | Size: 318 B After Width: | Height: | Size: 318 B |
Before Width: | Height: | Size: 308 B After Width: | Height: | Size: 308 B |
Before Width: | Height: | Size: 310 B After Width: | Height: | Size: 310 B |
Before Width: | Height: | Size: 310 B After Width: | Height: | Size: 310 B |
Before Width: | Height: | Size: 375 B After Width: | Height: | Size: 375 B |
Before Width: | Height: | Size: 251 B After Width: | Height: | Size: 251 B |
Before Width: | Height: | Size: 243 B After Width: | Height: | Size: 243 B |
Before Width: | Height: | Size: 253 B After Width: | Height: | Size: 253 B |
Before Width: | Height: | Size: 240 B After Width: | Height: | Size: 240 B |
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,9 +34,6 @@ 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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -16,6 +16,7 @@ public class EnemyFour extends Enemy{
|
|||
public EnemyFour(int x, int y, ArrayList<Point> 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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<String> fileList = new ArrayList<String>();
|
||||
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<String> fileList = new ArrayList<String>();
|
||||
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<String> list = new ArrayList<String>();
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|