I’m writing a small java game and am storing global game settings in a class structure like the one below:
public class Globals {
public static int tileSize = 16;
public static String screenshotDir = "..\\somepath\\..";
public static String screenshotNameFormat = "gameNamexxx.png";
public static int maxParticles = 300;
public static float gravity = 980f;
// etc
}
While this is very convenient to work with I’d like to know if this is the accepted pattern.
Store it in a
.propertiesfile.config.properties
Reading it
Using it
To simplify things, and to keep your changes minimal, you can also do something like this: