I looked at the documentation (https://www.sfml-dev.org/tutorials/2.6/graphics-view.php#showing-more-when-the-window-is-resized), but when I used the following code in the event loop, it did nothing, and I fail to see why.
Hard to say what did or didn't work without knowing what you did exactly.
2) Be able to drag with the mouse (or even WASD keys) the grid around, so it's ""infinite"".
I don't really know what to start on this one. I understand that I need to simply make the grid really big,
so that it looks infinite, but how can I shift the view based on mouse dragging or keys being pressed?
Did you have a look at the events tutorial to see how to react to key or mouse inputs?
Then you can move the view, check the API documentation for the detailed API call.
Note though that you'll always have a limited space to operate in, as you have to do the simulation of all the cells as well, and thus the space can't be even close to infinite ;)
Also, bonus question: in game of life, most of the cells are empty most of the time.
From a resource perspective, does it make sense to redraw only changed rectangles, instead of redrawing the entire grid every time?
It's okay to redraw every time, but if you end up with a large grid, it might make sense to really only draw what you see at the given moment.
Additionally, if you run into performance issues, then you could consider using a vertex array.
Hard to say what did or didn't work without knowing what you did exactly.
Apologies, I updated the repo on Github now. The only change is adding this case in the event loop:
case sf::Event::Resized:
{
sf::FloatRect visibleArea(0.f, 0.f, evnt.size.width, evnt.size.height);
window.setView(sf::View(visibleArea));
}
Which, as it seems, still stretches the grid when resizing, as seen here (https://streamable.com/kncfya).
Did you have a look at the events tutorial to see how to react to key or mouse inputs?
Then you can move the view, check the API documentation for the detailed API call.
Note though that you'll always have a limited space to operate in, as you have to do the simulation of all the cells as well, and thus the space can't be even close to infinite ;)
I'm aware of KeyPressed event and of view.move, I thought the solution is more complex. I'll try them out once I sort the first problem, since calling "move" now just wrap the grids, just like in the video above.
I guess I'm missing something crucial about view.
Thanks a lot