-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from MAKMED1337/15-use-properties-instead-of-s…
…ome-constants Added .properties files
- Loading branch information
Showing
37 changed files
with
237 additions
and
104 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
core/src/com/po/fuck/model/constants/BalanceConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.po.fuck.model.constants; | ||
|
||
import java.nio.file.Paths; | ||
import java.util.Properties; | ||
|
||
import static com.po.fuck.model.constants.ConstantsLoader.loadProperties; | ||
import static com.po.fuck.model.constants.ConstantsLoader.loadFloat; | ||
import static com.po.fuck.model.constants.ConstantsLoader.loadInt; | ||
|
||
public final class BalanceConstants extends BaseConstants { | ||
private static final String PATH = Paths.get(PROPERTIES_FOLDER, "/balance.properties").toString(); | ||
private static final Properties PROPERTIES = loadProperties(PATH); | ||
|
||
public static final float BASIC_ENEMY_SPEED = loadFloat(PROPERTIES, "BASIC_ENEMY_SPEED"); | ||
public static final float BASIC_ENEMY_HEALTH = loadFloat(PROPERTIES, "BASIC_ENEMY_HEALTH"); | ||
public static final int BASIC_ENEMY_REWARD = loadInt(PROPERTIES, "BASIC_ENEMY_REWARD"); | ||
public static final float PLAYERS_HEALTH = loadFloat(PROPERTIES, "PLAYERS_HEALTH"); | ||
|
||
public static final float DEFAULT_SPEED = loadFloat(PROPERTIES, "DEFAULT_SPEED"); | ||
public static final int BOOST_DISTANCE = loadInt(PROPERTIES, "BOOST_DISTANCE"); | ||
public static final float BOOST_DURATION = loadFloat(PROPERTIES, "BOOST_DURATION"); | ||
public static final float BOOST_COOLDOWN = loadFloat(PROPERTIES, "BOOST_COOLDOWN"); | ||
|
||
public static final float COSMIC_BULLET_LIFE_TIME = loadFloat(PROPERTIES, "COSMIC_BULLET_LIFE_TIME"); | ||
public static final float COSMIC_BULLET_DAMAGE = loadFloat(PROPERTIES, "COSMIC_BULLET_DAMAGE"); | ||
public static final float COSMIC_BULLET_SPEED = loadFloat(PROPERTIES, "COSMIC_BULLET_SPEED"); | ||
public static final float LASER_BEAM_DAMAGE = loadFloat(PROPERTIES, "LASER_BEAM_DAMAGE"); | ||
public static final float LASER_BEAM_LIFE_TIME = loadFloat(PROPERTIES, "LASER_BEAM_LIFE_TIME"); | ||
public static final float DEFAULT_BULLET_LIFE_TIME = loadFloat(PROPERTIES, "DEFAULT_BULLET_LIFE_TIME"); | ||
public static final float GLOCK_COOLDOWN = loadFloat(PROPERTIES, "GLOCK_COOLDOWN"); | ||
public static final float LASERGUN_COOLDOWN = loadFloat(PROPERTIES, "LASERGUN_COOLDOWN"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.po.fuck.model.constants; | ||
|
||
import java.util.Properties; | ||
|
||
public class BaseConstants { | ||
protected static final String PROPERTIES_FOLDER = "../core/src/com/po/fuck/properties"; | ||
protected static <T> void addProperty(Properties properties, String name, T value) { | ||
properties.setProperty(name, value.toString()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.po.fuck.model.constants; | ||
|
||
import java.nio.file.Paths; | ||
import java.util.Properties; | ||
|
||
import static com.po.fuck.model.constants.ConstantsLoader.loadProperties; | ||
import static com.po.fuck.model.constants.ConstantsLoader.loadFloat;; | ||
|
||
public final class CameraConstants extends BaseConstants { | ||
private static final String PATH = Paths.get(PROPERTIES_FOLDER, "/camera.properties").toString(); | ||
private static final Properties PROPERTIES = loadProperties(PATH); | ||
|
||
public static final float SPEED = loadFloat(PROPERTIES, "SPEED"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.po.fuck.model.constants; | ||
|
||
import java.io.FileInputStream; | ||
import java.io.IOException; | ||
import java.util.Properties; | ||
|
||
public class ConstantsLoader { | ||
protected static Properties loadProperties(String filePath) { | ||
try { | ||
Properties properties = new Properties(); | ||
properties.load(new FileInputStream(filePath)); | ||
return properties; | ||
} catch (IOException io) { | ||
throw new RuntimeException("Unable to load properties file: " + filePath + " - " + io.getMessage()); | ||
} | ||
} | ||
|
||
protected static String loadConstant(Properties properties, String name) { | ||
String value = properties.getProperty(name); | ||
if(value == null) | ||
throw new RuntimeException(name + " is null"); | ||
return value; | ||
} | ||
|
||
protected static int loadInt(Properties properties, String name){ | ||
return Integer.valueOf(loadConstant(properties, name)); | ||
} | ||
|
||
protected static float loadFloat(Properties properties, String name){ | ||
return Float.valueOf(loadConstant(properties, name)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.po.fuck.model.constants; | ||
|
||
import java.nio.file.Paths; | ||
import java.util.Properties; | ||
|
||
import static com.po.fuck.model.constants.ConstantsLoader.loadProperties; | ||
import static com.po.fuck.model.constants.ConstantsLoader.loadInt; | ||
|
||
public final class GameScreen extends BaseConstants { | ||
private static final String PATH = Paths.get(PROPERTIES_FOLDER, "/gamescreen.properties").toString(); | ||
private static final Properties PROPERTIES = loadProperties(PATH); | ||
|
||
public static final int WIDTH = loadInt(PROPERTIES, "WIDTH"); | ||
public static final int HEIGHT = loadInt(PROPERTIES, "HEIGHT"); | ||
} |
17 changes: 17 additions & 0 deletions
17
core/src/com/po/fuck/model/constants/LayeringConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.po.fuck.model.constants; | ||
|
||
import java.nio.file.Paths; | ||
import java.util.Properties; | ||
|
||
import static com.po.fuck.model.constants.ConstantsLoader.loadProperties; | ||
import static com.po.fuck.model.constants.ConstantsLoader.loadInt; | ||
|
||
public final class LayeringConstants extends BaseConstants { | ||
private static final String PATH = Paths.get(PROPERTIES_FOLDER, "/layering.properties").toString(); | ||
private static final Properties PROPERTIES = loadProperties(PATH); | ||
|
||
public static final int BACKGROUND = loadInt(PROPERTIES, "BACKGROUND"); | ||
public static final int ENTITY = loadInt(PROPERTIES, "ENTITY"); | ||
public static final int WEAPON = loadInt(PROPERTIES, "WEAPON"); | ||
public static final int GUI = loadInt(PROPERTIES, "GUI"); | ||
} |
14 changes: 14 additions & 0 deletions
14
core/src/com/po/fuck/model/constants/PhysicsConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.po.fuck.model.constants; | ||
|
||
import java.nio.file.Paths; | ||
import java.util.Properties; | ||
|
||
import static com.po.fuck.model.constants.ConstantsLoader.loadProperties; | ||
import static com.po.fuck.model.constants.ConstantsLoader.loadInt; | ||
|
||
public final class PhysicsConstants extends BaseConstants { | ||
private static final String PATH = Paths.get(PROPERTIES_FOLDER, "/physics.properties").toString(); | ||
private static final Properties PROPERTIES = loadProperties(PATH); | ||
|
||
public static final int COLLISION_ITERATIONS = loadInt(PROPERTIES, "COLLISION_ITERATIONS"); | ||
} |
15 changes: 15 additions & 0 deletions
15
core/src/com/po/fuck/model/constants/PositionConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.po.fuck.model.constants; | ||
|
||
import java.nio.file.Paths; | ||
import java.util.Properties; | ||
|
||
import static com.po.fuck.model.constants.ConstantsLoader.loadProperties; | ||
import static com.po.fuck.model.constants.ConstantsLoader.loadFloat; | ||
|
||
public final class PositionConstants extends BaseConstants { | ||
private static final String PATH = Paths.get(PROPERTIES_FOLDER, "/position.properties").toString(); | ||
private static final Properties PROPERTIES = loadProperties(PATH); | ||
|
||
public static final float DEFAULT_DISTANCE_FACTOR = loadFloat(PROPERTIES, "DEFAULT_DISTANCE_FACTOR"); | ||
public static final float DEFAULT_MAX_DISTANCE_FROM_BODY = loadFloat(PROPERTIES, "DEFAULT_MAX_DISTANCE_FROM_BODY"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.po.fuck.model.constants; | ||
|
||
import java.nio.file.Paths; | ||
import java.util.Properties; | ||
|
||
import static com.po.fuck.model.constants.ConstantsLoader.loadProperties; | ||
import static com.po.fuck.model.constants.ConstantsLoader.loadInt; | ||
|
||
public final class TagsConstants extends BaseConstants { | ||
private static final String PATH = Paths.get(PROPERTIES_FOLDER, "/tags.properties").toString(); | ||
private static final Properties PROPERTIES = loadProperties(PATH); | ||
|
||
public static final int ENEMY_TEAM_TAG = loadInt(PROPERTIES, "ENEMY_TEAM_TAG"); | ||
public static final int PLAYER_TEAM_TAG = loadInt(PROPERTIES, "PLAYER_TEAM_TAG"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.