This project is a simple random walk simulation using SDL2. The program creates a graphical window and simulates a random walk where each step is colored differently based on the direction taken.
- Random Walk Simulation: The program randomly chooses a direction (up-left, up-right, down-left, down-right) for each step of the walk.
- Color-Coded Steps: Each direction has a unique color associated with it:
- Up-left: Pink (245, 169, 184)
- Up-right: Light Blue (91, 206, 250)
- Down-left: White (255, 255, 255)
- Down-right: Black (0, 0, 0)
- Boundary Reset: The walk resets to the center if it goes beyond the defined boundary.
- SDL2 library
- Mingw-w64 or any compatible compiler
- C++17 or later
- Ensure you have the SDL2 library installed. You can download it from SDL2 Downloads or using MSYS
pacman -S mingw-w64-x86_64-SDL2
- Clone this repository or download the source code.
git clone https://github.com/starlitdreams/random-walk-sdl2.git cd random-walk-sdl2
- Open a terminal or command prompt and navigate to the directory containing the source code.
- Compile the code using the following command:
chcp 65001 > $null; & "C:\msys64\mingw64\bin\g++.exe" -fdiagnostics-color=always -g "path_to_your_source_code\random_walk.cpp" -o "path_to_your_output_directory\random_walk.exe" -lmingw32 -lSDL2main -lSDL2 -mwindows -LC:\msys64\mingw64\lib -IC:\msys64\mingw64\include\SDL2 -Dmain=SDL_main
- After building the project, you can run the executable:
random_walk.exe
This project is licensed under the MIT License. See the LICENSE file for details.