#include <stdio.h>
#include <stdbool.h>
#include <assert.h>
+#include <time.h>
#include "nbody.h"
int main(int argc, char ** argv)
{
-
+ srand(time(NULL));
System system;
- System_Init(&system, (float[3]){320,240,0}, 0.1, 10, 1);
+ System_Init(&system, (float[3]){320,240,0}, 1.0, 1.0, 0.4,1);
#ifdef _GRAPHICS_H
Graphics_Init("N-Body", 640, 480);
#endif //_GRAPHICS_H
- assert(System_AddBody(&system, 1, (float[2]){0.0f,0.0f}, (float[2]){0.0f,0.0f})->exists);
- assert(System_AddBody(&system, 0.01, (float[2]){120.0f, -120.0f}, (float[2]){-1.1f, 1.0f})->exists);
+ for (unsigned a = 0; a < 100; ++a)
+ {
+ float m = ((float)(rand() % 100))/1000.0;
+ float x[DIMENSIONS];
+ float v[DIMENSIONS];
+ for (unsigned i = 0; i < DIMENSIONS; ++i)
+ {
+ x[i] = (float)(rand() % 640 - 320);
+ v[i] = (float)(rand() % 100 - 50) / 100;
+ }
+ System_AddBody(&system, m, x, v);
+ }
+ System_AddBody(&system, 1.1, (float[2]){0,0}, (float[2]){0,0});
+
while (true)
{