I have a problem.
I’m making a game using slick 2d. I’m currently using a stateBasedGame model where I have a update loop and a render loop.
In this game I have a class called tileMap. I also have classes Entities and objects. These are the main components of the game. In the update loop they all interact with the input from the player and with each other. After that comes the render and this is what brings me to wonder.
I’m wondering weather I should keep all variables that concerns the actual rendering of a class inside the render method, to separate these variables from the actual object. This would aid greatly to the design of the game. However, I’m afraid it will consume a lot of resources, slow things down and even perhaps mess things up.
If I do this, my tileMap class would look like this:
class TileMap{
//things that actually concerns the class
private tile[][] tiles;
private Image spritesheet
//etc.
//constructor
TileMap (){
}
pubic update(){
//updates the map.
}
public render (){
int tilesToDrawX = otherobject.gettileX;
int tilesToDrawY = otherobject.gettileY;
//...
//perhaps ten ints here...
//logic.
}
}
else tileMap would look like this:
class TileMap{
//things that actually concerns the class + render variables, making it messy
private tile[][] tiles;
private Image spritesheet
int tilesToDrawX;
int tilesToDrawY;
//etc.
//constructor
TileMap (){
}
pubic update(){
//updates the map.
//prepare to render
int tilesToDrawX = otherobject.gettileX;
int tilesToDrawY = otherobject.gettileY;
}
public render (){
//just logic.
}
}
So any advice?