Skip to content

comejv/flock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flocking Simulator

This project is a flocking simulator using the Raylib library. It demonstrates basic behaviors of entities (agents) in a simulation where they exhibit flocking behavior, such as grouping and repelling. It supports dynamic changes to the simulation parameters and real-time display of various metrics.

Features

  • Entity Management: Add and remove entities dynamically.
  • Simulation Parameters: Adjust repulsion and group radii.
  • Real-time Metrics: Display FPS, simulation energy, and entity count.
  • Interactive Controls: Toggle various display options and modify parameters on the fly.

Dependencies

  • Raylib - for graphics and window management.
  • gcc - for compiling the C code.

Compilation

To compile flock you should first compile raylib (change PLUG to what you want, ON by default):

make raylib PLUG=ON

For Plugin Mode

To compile as a shared library with hot reload support, set PLUG to ON in the Makefile (default):

make PLUG=ON

For Standalone Executable

To compile as a standalone executable, ensure PLUG is set to OFF in the Makefile (when compiling raylib too):

make PLUG=OFF

Controls

  • R: Compile and reload sources using the same game state (only if compiled with PLUG)
  • F: Toggle FPS display
  • E: Toggle Energy display
  • N: Toggle Entity Count display
  • P: Add an entity (up to 1000 entities)
  • M: Remove the last entity
  • I: Toggle Radii Information display
  • UP Arrow: Increase repulsion radius
  • DOWN Arrow: Decrease repulsion radius (minimum: 10)
  • LEFT Arrow: Decrease group radius (minimum: 10)
  • RIGHT Arrow: Increase group radius
  • H: Toggle Help display

Project Structure

  • src/: Contains source code files.
  • headers/: Contains header files.
  • lib/raylib/src/: Contains Raylib source files.
  • plug/: Contains plugin source files (if using plugin mode).

Makefile Targets

  • make all: Compile the project (PLUG is ON).
  • make clean: Remove object files.
  • make cleanall: Remove all binaries and object files, clean raylib as well.
  • make raylib: Compile Raylib into a static library (as .so by default, .a if PLUG=OFF).
  • make help: Display help for available Makefile targets.

License

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