added logger
This commit is contained in:
@@ -1,10 +1,13 @@
|
|||||||
package de.miaurizius.jgame2d.core;
|
package de.miaurizius.jgame2d.core;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class Boot {
|
public class Boot {
|
||||||
|
|
||||||
public static void main() {
|
public static final Logger logger = Logger.getLogger("JDGame2D");
|
||||||
|
|
||||||
|
static void main() {
|
||||||
JFrame window = new JFrame();
|
JFrame window = new JFrame();
|
||||||
window.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
window.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
||||||
window.setResizable(false);
|
window.setResizable(false);
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import javax.sound.sampled.Clip;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class Sound {
|
public class Sound {
|
||||||
|
|
||||||
@@ -20,7 +22,7 @@ public class Sound {
|
|||||||
soundURL[3] = new File("assets/sounds/unlock.wav").toURI().toURL();
|
soundURL[3] = new File("assets/sounds/unlock.wav").toURI().toURL();
|
||||||
soundURL[4] = new File("assets/sounds/fanfare.wav").toURI().toURL();
|
soundURL[4] = new File("assets/sounds/fanfare.wav").toURI().toURL();
|
||||||
} catch(MalformedURLException e) {
|
} catch(MalformedURLException e) {
|
||||||
e.printStackTrace();
|
Boot.logger.log(Level.SEVERE, e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package de.miaurizius.jgame2d.entity;
|
package de.miaurizius.jgame2d.entity;
|
||||||
|
|
||||||
|
import de.miaurizius.jgame2d.core.Boot;
|
||||||
import de.miaurizius.jgame2d.core.Direction;
|
import de.miaurizius.jgame2d.core.Direction;
|
||||||
import de.miaurizius.jgame2d.core.GamePanel;
|
import de.miaurizius.jgame2d.core.GamePanel;
|
||||||
import de.miaurizius.jgame2d.core.KeyHandler;
|
import de.miaurizius.jgame2d.core.KeyHandler;
|
||||||
@@ -8,6 +9,7 @@ import javax.imageio.ImageIO;
|
|||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class Player extends Entity {
|
public class Player extends Entity {
|
||||||
|
|
||||||
@@ -55,7 +57,7 @@ public class Player extends Entity {
|
|||||||
right1 = ImageIO.read(new FileInputStream("assets/player/boy_right_1.png"));
|
right1 = ImageIO.read(new FileInputStream("assets/player/boy_right_1.png"));
|
||||||
right2 = ImageIO.read(new FileInputStream("assets/player/boy_right_2.png"));
|
right2 = ImageIO.read(new FileInputStream("assets/player/boy_right_2.png"));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
Boot.logger.log(Level.SEVERE, "Could not load image", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package de.miaurizius.jgame2d.object;
|
package de.miaurizius.jgame2d.object;
|
||||||
|
|
||||||
|
import de.miaurizius.jgame2d.core.Boot;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class BootsObj extends SuperObject {
|
public class BootsObj extends SuperObject {
|
||||||
|
|
||||||
@@ -11,7 +14,7 @@ public class BootsObj extends SuperObject {
|
|||||||
try {
|
try {
|
||||||
image = ImageIO.read(new FileInputStream("assets/objects/boots.png"));
|
image = ImageIO.read(new FileInputStream("assets/objects/boots.png"));
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
e.printStackTrace();
|
Boot.logger.log(Level.SEVERE, "Could not load image", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package de.miaurizius.jgame2d.object;
|
package de.miaurizius.jgame2d.object;
|
||||||
|
|
||||||
|
import de.miaurizius.jgame2d.core.Boot;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class ChestObj extends SuperObject {
|
public class ChestObj extends SuperObject {
|
||||||
|
|
||||||
@@ -11,7 +14,7 @@ public class ChestObj extends SuperObject {
|
|||||||
try {
|
try {
|
||||||
image = ImageIO.read(new FileInputStream("assets/objects/chest.png"));
|
image = ImageIO.read(new FileInputStream("assets/objects/chest.png"));
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
e.printStackTrace();
|
Boot.logger.log(Level.SEVERE, "Could not load image", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package de.miaurizius.jgame2d.object;
|
package de.miaurizius.jgame2d.object;
|
||||||
|
|
||||||
|
import de.miaurizius.jgame2d.core.Boot;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class DoorObj extends SuperObject {
|
public class DoorObj extends SuperObject {
|
||||||
|
|
||||||
@@ -11,7 +14,7 @@ public class DoorObj extends SuperObject {
|
|||||||
try {
|
try {
|
||||||
image = ImageIO.read(new FileInputStream("assets/objects/door.png"));
|
image = ImageIO.read(new FileInputStream("assets/objects/door.png"));
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
e.printStackTrace();
|
Boot.logger.log(Level.SEVERE, "Could not load image", e);
|
||||||
}
|
}
|
||||||
collision = true;
|
collision = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package de.miaurizius.jgame2d.object;
|
package de.miaurizius.jgame2d.object;
|
||||||
|
|
||||||
|
import de.miaurizius.jgame2d.core.Boot;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class KeyObj extends SuperObject {
|
public class KeyObj extends SuperObject {
|
||||||
|
|
||||||
@@ -11,7 +14,7 @@ public class KeyObj extends SuperObject {
|
|||||||
try {
|
try {
|
||||||
image = ImageIO.read(new FileInputStream("assets/objects/key.png"));
|
image = ImageIO.read(new FileInputStream("assets/objects/key.png"));
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
e.printStackTrace();
|
Boot.logger.log(Level.SEVERE, "Could not load image", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
package de.miaurizius.jgame2d.tile;
|
package de.miaurizius.jgame2d.tile;
|
||||||
|
|
||||||
|
import de.miaurizius.jgame2d.core.Boot;
|
||||||
import de.miaurizius.jgame2d.core.GamePanel;
|
import de.miaurizius.jgame2d.core.GamePanel;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class TileManager {
|
public class TileManager {
|
||||||
|
|
||||||
@@ -43,7 +45,7 @@ public class TileManager {
|
|||||||
tile[5] = new Tile();
|
tile[5] = new Tile();
|
||||||
tile[5].image = ImageIO.read(new FileInputStream("assets/tiles/sand.png"));
|
tile[5].image = ImageIO.read(new FileInputStream("assets/tiles/sand.png"));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
Boot.logger.log(Level.SEVERE, "Could not load tile", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +70,7 @@ public class TileManager {
|
|||||||
}
|
}
|
||||||
bReader.close();
|
bReader.close();
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
e.printStackTrace();
|
Boot.logger.log(Level.SEVERE, "Could not load map", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user