automatonWindow.clear()
for(Person currentPerson : *evolutionIterator){
//Set cell color according to it's status
personCell.setPosition(x, y);
automatonWindow.draw(personCell);
}
automatonWindow.display()
Hey! Here's a simple way of doing this that nobody has mentioned. Say you have a 50 by 50 grid of gray squares. When a square is clicked, it turns white. Here's a simple way of cutting down render calls a TON:
- Create an image (PNG or JPG) of your 50 by 50 grid.
- Render this image as a Sprite instead of 2500 separate squares.
- When you click, use an algorithm to detect which cell you clicked.
- Draw a WHITE RECTANGLESHAPE on top of the grid with the width and height of one cell at the position of the cell clicked.
Uhmm so what about when there are many white cells... Isn't it the sameOne workaround (don’t recommend) is to swap once half the tiles are white. By then, you can have the image be a WHITE grid image and just render individual grey tiles which you REMOVE when clicked.
Fine point, but you can easily break the single grey grid texture into four 25x25 textures.Hey! Here's a simple way of doing this that nobody has mentioned. Say you have a 50 by 50 grid of gray squares. When a square is clicked, it turns white. Here's a simple way of cutting down render calls a TON:
- Create an image (PNG or JPG) of your 50 by 50 grid.
- Render this image as a Sprite instead of 2500 separate squares.
- When you click, use an algorithm to detect which cell you clicked.
- Draw a WHITE RECTANGLESHAPE on top of the grid with the width and height of one cell at the position of the cell clicked.
the problem doing it is that you kill exactly the purpose of tiles: repetition of small parts (tilesets) to avoid large textures. also, many videocards can't handle textures bigger than 8192x8192, so for 50x50 tiles you max tile size will be 163,84x163,84. for 100x100 maps, it will be 81,92x81,92 :P
@Stauricus: Uhhh i dont really get it... So it's better to handle multiple smaller sprites than a big one? Sorry if my question sounds silly but i'm still quite new