This project is an implementation of Conway's Game of Life using C and SDL2. It features a graphical interface with a grid where users can click on cells to toggle their state (alive or dead), move around the grid, and start or stop the simulation.
- Graphical interface with SDL2
- Click on cells to toggle between alive and dead states
- Move around the grid using arrow keys
- Start and stop the simulation with the spacebar
- Zoom in and out with the mouse scroll wheel
- Infinite grid
- Resizable window
- Cells with white borders for better visualization
- C compiler (GCC recommended)
- CMake (version 3.28 or higher)
- SDL2 library
sudo apt-get install libsdl2-dev
brew install sdl2
sudo pacman -S sdl2
Clone this repository to your local machine:
git clone https://github.com/yourusername/game-of-life.git
cd game-of-life
- Create a build directory:
mkdir build
cd build
- Run CMake to configure the project:
cmake ..
- Build the project using
make
:
make
After building the project, you can run the executable:
./game_of_life
- Mouse Click: Toggle the state of a cell between alive and dead.
- Arrow Keys: Move around the grid.
- Spacebar: Start and stop the simulation.
- Mouse Scroll Wheel: Zoom in and out.
game-of-life/
│
├── includes/
│ ├── grid.h
│ ├── renderer.h
│ └── game.h
│
├── src/
│ ├── main.c
│ ├── grid.c
│ ├── renderer.c
│ └── game.c
│
├── tests/
│ ├── test_grid.c
│ ├── test_renderer.c
│ └── test_game.c
│
├── assets/
│ └── (any images or resources if needed)
│
├── cmake/
│ └── FindCUnit.cmake
│
├── .github/
│ └── workflows/
│ └── ci.yml
│
├── CMakeLists.txt
└── README.md
If you would like to contribute to this project, feel free to fork the repository and submit a pull request with your improvements.
This project is licensed under the MIT License. See the LICENSE file for more details.
- SDL2 for providing a simple and powerful multimedia library.
- Conway's Game of Life, a cellular automaton devised by the British mathematician John Horton Conway.