Browse Source

Reimplement singleton classes and update copyrights

Signed-off-by: Chris Cromer <chris@cromer.cl>
tags/1.0.0
Chris Cromer 4 months ago
parent
commit
6c2665b1c5
40 changed files with 103 additions and 43 deletions
  1. +1
    -1
      build.gradle
  2. +1
    -1
      gradle.properties
  3. +1
    -1
      gradle/wrapper/gradle-wrapper.properties
  4. +1
    -1
      settings.gradle
  5. +1
    -1
      src/main/java/cl/cromer/azaraka/Azaraka.java
  6. +3
    -1
      src/main/java/cl/cromer/azaraka/Canvas.java
  7. +1
    -1
      src/main/java/cl/cromer/azaraka/Cell.java
  8. +1
    -1
      src/main/java/cl/cromer/azaraka/Constants.java
  9. +1
    -1
      src/main/java/cl/cromer/azaraka/MainWindow.java
  10. +4
    -4
      src/main/java/cl/cromer/azaraka/Scene.java
  11. +1
    -1
      src/main/java/cl/cromer/azaraka/ai/AI.java
  12. +1
    -1
      src/main/java/cl/cromer/azaraka/ai/AIException.java
  13. +1
    -1
      src/main/java/cl/cromer/azaraka/ai/EnemyAI.java
  14. +1
    -1
      src/main/java/cl/cromer/azaraka/ai/PlayerAI.java
  15. +1
    -1
      src/main/java/cl/cromer/azaraka/ai/PlayerAStarAI.java
  16. +1
    -1
      src/main/java/cl/cromer/azaraka/ai/PlayerBreadthFirstAI.java
  17. +1
    -1
      src/main/java/cl/cromer/azaraka/ai/package-info.java
  18. +1
    -1
      src/main/java/cl/cromer/azaraka/json/Json.java
  19. +1
    -1
      src/main/java/cl/cromer/azaraka/json/JsonCell.java
  20. +1
    -1
      src/main/java/cl/cromer/azaraka/json/package-info.java
  21. +1
    -1
      src/main/java/cl/cromer/azaraka/logging/HtmlFormatter.java
  22. +1
    -1
      src/main/java/cl/cromer/azaraka/logging/StringUtils.java
  23. +1
    -1
      src/main/java/cl/cromer/azaraka/logging/package-info.java
  24. +1
    -1
      src/main/java/cl/cromer/azaraka/object/Chest.java
  25. +1
    -1
      src/main/java/cl/cromer/azaraka/object/Enemy.java
  26. +1
    -1
      src/main/java/cl/cromer/azaraka/object/Gem.java
  27. +1
    -1
      src/main/java/cl/cromer/azaraka/object/Object.java
  28. +1
    -1
      src/main/java/cl/cromer/azaraka/object/Obstacle.java
  29. +30
    -1
      src/main/java/cl/cromer/azaraka/object/Player.java
  30. +30
    -1
      src/main/java/cl/cromer/azaraka/object/Portal.java
  31. +1
    -1
      src/main/java/cl/cromer/azaraka/object/package-info.java
  32. +1
    -1
      src/main/java/cl/cromer/azaraka/package-info.java
  33. +1
    -1
      src/main/java/cl/cromer/azaraka/sound/Sound.java
  34. +1
    -1
      src/main/java/cl/cromer/azaraka/sound/SoundException.java
  35. +1
    -1
      src/main/java/cl/cromer/azaraka/sound/package-info.java
  36. +1
    -1
      src/main/java/cl/cromer/azaraka/sprite/Animation.java
  37. +1
    -1
      src/main/java/cl/cromer/azaraka/sprite/AnimationException.java
  38. +1
    -1
      src/main/java/cl/cromer/azaraka/sprite/Sheet.java
  39. +1
    -1
      src/main/java/cl/cromer/azaraka/sprite/SheetException.java
  40. +1
    -1
      src/main/java/cl/cromer/azaraka/sprite/package-info.java

+ 1
- 1
build.gradle View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019 Chris Cromer
* Copyright 2020 Chris Cromer
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*


+ 1
- 1
gradle.properties View File

@@ -1,5 +1,5 @@
#
# Copyright 2019 Chris Cromer
# Copyright 2020 Chris Cromer
#
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
#


+ 1
- 1
gradle/wrapper/gradle-wrapper.properties View File

@@ -1,5 +1,5 @@
#
# Copyright 2019 Chris Cromer
# Copyright 2020 Chris Cromer
#
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
#


+ 1
- 1
settings.gradle View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019 Chris Cromer
* Copyright 2020 Chris Cromer
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*


+ 1
- 1
src/main/java/cl/cromer/azaraka/Azaraka.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019 Chris Cromer
* Copyright 2020 Chris Cromer
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*


+ 3
- 1
src/main/java/cl/cromer/azaraka/Canvas.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019 Chris Cromer
* Copyright 2020 Chris Cromer
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*
@@ -514,6 +514,8 @@ public class Canvas extends java.awt.Canvas implements Constants {
public void keyPressed(KeyEvent event) {
super.keyPressed(event);
if (event.getKeyCode() == KeyEvent.VK_ENTER) {
player.deleteInstance();
portal.deleteInstance();
azaraka.restart();
}
}


+ 1
- 1
src/main/java/cl/cromer/azaraka/Cell.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019 Chris Cromer
* Copyright 2020 Chris Cromer
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*


+ 1
- 1
src/main/java/cl/cromer/azaraka/Constants.java View File

@@ -41,7 +41,7 @@ public interface Constants {
/**
* Which type of AI to use
*/
PlayerAIType PLAYER_AI = PlayerAIType.ASTAR;
PlayerAIType PLAYER_AI = PlayerAIType.HUMAN;
/**
* Whether or not the enemies should be controlled by AI
*/


+ 1
- 1
src/main/java/cl/cromer/azaraka/MainWindow.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019 Chris Cromer
* Copyright 2020 Chris Cromer
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*


+ 4
- 4
src/main/java/cl/cromer/azaraka/Scene.java View File

@@ -135,7 +135,7 @@ public class Scene extends JComponent implements Constants {
cells.get(x).add(cell);

if (jsonCells[x][y].type.equals(Player.class.getName())) {
cells.get(x).get(y).setObject(new Player(null, cells.get(x).get(y)));
cells.get(x).get(y).setObject(Player.getInstance(null, cells.get(x).get(y)));
}
else if (jsonCells[x][y].type.equals(Enemy.class.getName())) {
cells.get(x).get(y).setObject(new Enemy(null, cells.get(x).get(y), null));
@@ -153,7 +153,7 @@ public class Scene extends JComponent implements Constants {
cells.get(x).get(y).setObject(new Obstacle(null, cells.get(x).get(y)));
}
else if (jsonCells[x][y].type.equals(Portal.class.getName())) {
cells.get(x).get(y).setObject(new Portal(null, cells.get(x).get(y)));
cells.get(x).get(y).setObject(Portal.getInstance(null, cells.get(x).get(y)));
}

for (int k = 0; k < jsonCells[x][y].textures.size(); k++) {
@@ -178,7 +178,7 @@ public class Scene extends JComponent implements Constants {
List<Object> objectArrayList = new ArrayList<>();

// The player has a fixed position
cells.get(2).get(1).setObject(new Player(this, cells.get(2).get(1)));
cells.get(2).get(1).setObject(Player.getInstance(this, cells.get(2).get(1)));
objectArrayList.add(cells.get(2).get(1).getObject());

for (int i = 0; i < OBSTACLES; i++) {
@@ -201,7 +201,7 @@ public class Scene extends JComponent implements Constants {
}

random = randomCoordinates();
cells.get(random[0]).get(random[1]).setObjectOnBottom(new Portal(this, cells.get(random[0]).get(random[1])));
cells.get(random[0]).get(random[1]).setObjectOnBottom(Portal.getInstance(this, cells.get(random[0]).get(random[1])));
objectArrayList.add(cells.get(random[0]).get(random[1]).getObjectOnBottom());

// Generate enough keys for the chests that will exist


+ 1
- 1
src/main/java/cl/cromer/azaraka/ai/AI.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019 Chris Cromer
* Copyright 2020 Chris Cromer
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*


+ 1
- 1
src/main/java/cl/cromer/azaraka/ai/AIException.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019 Chris Cromer
* Copyright 2020 Chris Cromer
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*


+ 1
- 1
src/main/java/cl/cromer/azaraka/ai/EnemyAI.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019 Chris Cromer
* Copyright 2020 Chris Cromer
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*


+ 1
- 1
src/main/java/cl/cromer/azaraka/ai/PlayerAI.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019 Chris Cromer
* Copyright 2020 Chris Cromer
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*


+ 1
- 1
src/main/java/cl/cromer/azaraka/ai/PlayerAStarAI.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019 Chris Cromer
* Copyright 2020 Chris Cromer
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*


+ 1
- 1
src/main/java/cl/cromer/azaraka/ai/PlayerBreadthFirstAI.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019 Chris Cromer
* Copyright 2020 Chris Cromer
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*


+ 1
- 1
src/main/java/cl/cromer/azaraka/ai/package-info.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019 Chris Cromer
* Copyright 2020 Chris Cromer
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*


+ 1
- 1
src/main/java/cl/cromer/azaraka/json/Json.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019 Chris Cromer
* Copyright 2020 Chris Cromer
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*


+ 1
- 1
src/main/java/cl/cromer/azaraka/json/JsonCell.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019 Chris Cromer
* Copyright 2020 Chris Cromer
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*


+ 1
- 1
src/main/java/cl/cromer/azaraka/json/package-info.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019 Chris Cromer
* Copyright 2020 Chris Cromer
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*


+ 1
- 1
src/main/java/cl/cromer/azaraka/logging/HtmlFormatter.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019 Chris Cromer
* Copyright 2020 Chris Cromer
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*


+ 1
- 1
src/main/java/cl/cromer/azaraka/logging/StringUtils.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019 Chris Cromer
* Copyright 2020 Chris Cromer
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*


+ 1
- 1
src/main/java/cl/cromer/azaraka/logging/package-info.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019 Chris Cromer
* Copyright 2020 Chris Cromer
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*


+ 1
- 1
src/main/java/cl/cromer/azaraka/object/Chest.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019 Chris Cromer
* Copyright 2020 Chris Cromer
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*


+ 1
- 1
src/main/java/cl/cromer/azaraka/object/Enemy.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019 Chris Cromer
* Copyright 2020 Chris Cromer
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*


+ 1
- 1
src/main/java/cl/cromer/azaraka/object/Gem.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019 Chris Cromer
* Copyright 2020 Chris Cromer
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*


+ 1
- 1
src/main/java/cl/cromer/azaraka/object/Object.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019 Chris Cromer
* Copyright 2020 Chris Cromer
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*


+ 1
- 1
src/main/java/cl/cromer/azaraka/object/Obstacle.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019 Chris Cromer
* Copyright 2020 Chris Cromer
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*


+ 30
- 1
src/main/java/cl/cromer/azaraka/object/Player.java View File

@@ -48,6 +48,10 @@ public class Player extends Object implements Constants {
* The current health of the player
*/
private int health = MAX_HEALTH;
/**
* The Player instance
*/
private static Player instance;

/**
* Initialize the player
@@ -55,7 +59,7 @@ public class Player extends Object implements Constants {
* @param scene The scene the player is in
* @param cell The cell the player is in
*/
public Player(Scene scene, Cell cell) {
private Player(Scene scene, Cell cell) {
super(scene, cell);
setLogger(getLogger(this.getClass(), LogLevel.PLAYER));
loadPlayerAnimation();
@@ -72,6 +76,31 @@ public class Player extends Object implements Constants {
}
}

/**
* Create the Player instance
*
* @param scene The scene the player is in
* @param cell The cell the player is in
* @return Returns the instance
*/
public static Player getInstance(Scene scene, Cell cell) {
if (instance == null) {
synchronized (Player.class) {
if (instance == null) {
instance = new Player(scene, cell);
}
}
}
return instance;
}

/**
* Delete the Player instance
*/
public void deleteInstance() {
instance = null;
}

/**
* Load the player animation
*/


+ 30
- 1
src/main/java/cl/cromer/azaraka/object/Portal.java View File

@@ -45,6 +45,10 @@ public class Portal extends Object implements Constants {
* The portal sound when a gem is purified
*/
private Sound sound;
/**
* The Portal instance
*/
private static Portal instance;

/**
* Initialize the portal
@@ -52,12 +56,37 @@ public class Portal extends Object implements Constants {
* @param scene The scene that contains the portal
* @param cell The cell the portal is in
*/
public Portal(Scene scene, Cell cell) {
private Portal(Scene scene, Cell cell) {
super(scene, cell);
setLogger(getLogger(this.getClass(), LogLevel.PORTAL));
loadPortalAnimations();
}

/**
* Create an instance of the portal
*
* @param scene The scene the portal is in
* @param cell The cell the portal is in
* @return Returns the Portal instance
*/
public static Portal getInstance(Scene scene, Cell cell) {
if (instance == null) {
synchronized (Portal.class) {
if (instance == null) {
instance = new Portal(scene, cell);
}
}
}
return instance;
}

/**
* Delete the Portal instance
*/
public void deleteInstance() {
instance = null;
}

/**
* Load the portal animation
*/


+ 1
- 1
src/main/java/cl/cromer/azaraka/object/package-info.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019 Chris Cromer
* Copyright 2020 Chris Cromer
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*


+ 1
- 1
src/main/java/cl/cromer/azaraka/package-info.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019 Chris Cromer
* Copyright 2020 Chris Cromer
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*


+ 1
- 1
src/main/java/cl/cromer/azaraka/sound/Sound.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019 Chris Cromer
* Copyright 2020 Chris Cromer
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*


+ 1
- 1
src/main/java/cl/cromer/azaraka/sound/SoundException.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019 Chris Cromer
* Copyright 2020 Chris Cromer
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*


+ 1
- 1
src/main/java/cl/cromer/azaraka/sound/package-info.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019 Chris Cromer
* Copyright 2020 Chris Cromer
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*


+ 1
- 1
src/main/java/cl/cromer/azaraka/sprite/Animation.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019 Chris Cromer
* Copyright 2020 Chris Cromer
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*


+ 1
- 1
src/main/java/cl/cromer/azaraka/sprite/AnimationException.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019 Chris Cromer
* Copyright 2020 Chris Cromer
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*


+ 1
- 1
src/main/java/cl/cromer/azaraka/sprite/Sheet.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019 Chris Cromer
* Copyright 2020 Chris Cromer
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*


+ 1
- 1
src/main/java/cl/cromer/azaraka/sprite/SheetException.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019 Chris Cromer
* Copyright 2020 Chris Cromer
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*


+ 1
- 1
src/main/java/cl/cromer/azaraka/sprite/package-info.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019 Chris Cromer
* Copyright 2020 Chris Cromer
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*


Loading…
Cancel
Save