1
0
Fork
You've already forked gravity_simulator
0
Newton gravity simulator
  • C 91.7%
  • Batchfile 7.8%
  • Makefile 0.5%
2025年02月17日 21:01:07 +02:00
rules Fixed version 2025年02月17日 20:36:17 +02:00
src Add switching abillity 2025年02月17日 21:01:07 +02:00
compile_executable.bat Fixed version 2025年02月17日 20:36:17 +02:00
gravity_sim.exe Add switching abillity 2025年02月17日 21:01:07 +02:00
Makefile Fixed version 2025年02月17日 20:36:17 +02:00
readme.md Add switching abillity 2025年02月17日 21:01:07 +02:00
screenshot.png Fixed version 2025年02月17日 20:36:17 +02:00

Newton gravity simulator

Small game on c + raylib that simulates newton gravity

screenshot

Building

Linux:

dependencies:

  • gcc
  • make
  • raylib

clone repo:

git clone https://codeberg.org/NeYurii/gravity_simulator.git && cd gravity_simulator

bulding:

make

Windows:

Just install raylib, and run script compile_executable.bat

Usage

Linux:

Run compiled program and give rule file as an argument. Example:

./gravity_sim rules/planet

Windows:

Open rule file with program, or create some extension for rules and register game on them, or drug rule file on executable.

Rule files

Structure:

{ 
 name=[string]; 
 mass=[float]; 
 start_pos=[x],[y]; # Float, 0,0 - center, negative - up or right 
 start_vec=[x],[y]; # Like start_pos 
 is_static=[t or f]; # t - cant move, f - can move; default: f 
 radius=[integer]; # in pixels\
 color=[hex]; # 6-digits hex color code\
}

comments or other foreign characters aren`t allowed
parameters separated by ;

examples you can see in rules directory

In-game controls

Button Action
arrows move camera
RMB + cursor move move camera
r reset camera
wheel zoom
wheel click reset zoom
LMB on planet focus
LMB on void unfocus
TAB focus next
f toggle focus
i toggle planet parameters displaying
t toggle trajectory display
p toggle bodies display
space pause
esc quit