I am making a top-down game.Inside Player class I have a function:
public void update() { // called every frame
// some code...
Tile[] map = level.getMap(); // level is a private member
int mapWidth = level.getWidth();
// some collision code...
}
and I have:
public void setLevel(Level level) {
this.level = level;
}
Would it be faster (not only faster,but better written code) to do it like this (have a temporary array every frame) or to have just map and width stored as privates and then to initialize them in setLevel to level.getMap() and level.getWidth()?
Sorry for bad explanation, or/and if this is a simple question, I just want to check that out.
Thanks,
MatejaS