I'm working on a game and I got the Main class which holds a number of object references arrays.
In the main class, I loop through every array and update the objects. The problem is that I have to hold an array for each type of object. It's comfortable to have an array for each type but it'd make the code ugly when I'll have dozens of types.
I thought about having a HashMap of String|Array, and every entry would have the object type name (String) and the array itself. Every object extends an abstract class I made called GameObject. My question is that efficient to work with hashmap? (meaning in every loop the Main class gets an array from the map and runs through it's objects.) By efficient I mean if HashMap's "get" method can slow down things.
Or maybe there are better solutions for holding lots of objects with different types?
I'm developing the game in Java, to Android, using LibGDX. Thank you!