Giter Club home page Giter Club logo

starlitdreams / random-walk-sdl2- Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 5 KB

This project is a random walk simulation using SDL2. It creates a graphical window where each step of the walk is colored based on its direction (up-left, up-right, down-left, down-right). The walk resets if it goes out of bounds. Built with SDL2, it features color-coded steps and boundary resets. Contributions are welcome!

License: MIT License

C++ 100.00%
cpp cpp-all cpp-programming cpp20 cpp23 programming random random-generation sdl sdl2 sdl2-image

random-walk-sdl2-'s Introduction

Random Walk Simulation with SDL2

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.

Features

  • 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.

Example

project_gif

Prerequisites

  • SDL2 library
  • Mingw-w64 or any compatible compiler
  • C++17 or later

Building and Running the Program

Windows

  1. Ensure you have the SDL2 library installed. You can download it from SDL2 Downloads or using MSYS
    pacman -S mingw-w64-x86_64-SDL2
  2. Clone this repository or download the source code.
    git clone https://github.com/starlitdreams/random-walk-sdl2.git
    cd random-walk-sdl2
  3. Open a terminal or command prompt and navigate to the directory containing the source code.
  4. 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
  5. After building the project, you can run the executable:
    random_walk.exe
    

License

This project is licensed under the MIT License. See the LICENSE file for details.

random-walk-sdl2-'s People

Contributors

starlitdreams avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.