Hello JGO, since my last help topic (Where I couldn’t remember how to divide properly…) i’ve continued to work on a “Loader” for my project
The issue I’m having is once my ImageIcon[] array’s size hits a certain cap my percentage formula fails.
(Percentage formula meaning what percentage out of 100 is increased per resource loaded)
Here is how I’m “Test Loading” a ImageIcon[] array:
imgs1 = new ImageIcon[2000000]; // if array[] size is > 2000000 + (another zero) formula fails.
int objects2Load = imgs1.length;
double increment_formula = totalPercent / objects2Load;
boolean accurate_formula = Boolean.valueOf((increment_formula * objects2Load) == totalPercent);
print("At this rate (Loading " + objects2Load + " objects).");
print("Each object will increment the % by " + increment_formula);
if (!accurate_formula) {
System.err.println("Formula is not accurate");
System.exit(0);
}
print("Formula's accurate!");
sleep(1000);
/* Loading process */
while (percent < totalPercent) {
for (int i = 0; i < imgs1.length; i++) {
imgs1[i] = loadSprite("tiles/floor/tile_" + MathUtils.random(5) + ".png",
increment_formula, i);
}
}
The above code (Loading 2000000 ImageIcons) works properly, however if I add 1 more 0 “Zero” to the ImageIcon[]'s size my percentage formula does not function
Here is the method LoadSprite(String, int, int) for those who were wondering:
private ImageIcon loadSprite(String path, double percent_increment, int imgCount) {
percent += percent_increment;
progressBar.setValue((int) percent);
System.out.println("Image "+imgCount+" loaded"); // for debugging.
return new ImageIcon("res/sprite/" + path);
}
I believe this has to do with the data type I am using although I am not 100% sure / confused.
If somebody could help me that would be great :>
Or at least push me in the right direction.