I'm making a management sim game, something along the lines of Roller Coaster Tycoon. I want to know what the best way to structure my world objects is so to maximise performance.
Let's say I have 5,000 people in my game I could:
Make an object and store them in an array like so;
class person() {
this.x = 0;
this.y = 0;
this.thirst = 15;
this.hunger = 15;
// etc.. add methods:
public findPath(int destX, int destY) {
// and so on
}
people = new person[5000];
for (int = 0; i < 5000; i++) {
people[i] = new person;
}
Or should I make an object of people that contains many byte arrays representing attributes of people like so:
class people() {
this.hunger = new byte[5000]
this.thirst = new byte[5000]
getThirst(int i) {
return this.thirst[i]
}
// and so on....
Or am I totally off the mark?