I programmed "game of life" using a grid, which is basically just a lot of rectangles positioned side by side.
On a fixed size window it works fine.
The user clicks on the squares they want to start with, press Enter, and the game starts.
This is the Github repo, 'main.cpp' is the only interesting part, and it's less than 70 lines:
Now I want to do 2 things:
1) Be able to resize the window to any size, without the grid to stretch.
Basically, I want to print a big grid, and in any window size, see only a small part of the same grid.
I know there's a lot of threads about it, but none of them seemed to solve it for me.
I looked at the [https://www.sfml-dev.org/tutorials/2.6/graphics-view.php#showing-more-when-the-window-is-resized]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.
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?
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?
Thanks a lot in advance.