Started Parallel Programming Self Assessment
[matches/honours.git] / course / semester2 / pprog / assignment0 / main.c
1 /**
2  * @file main.c
3  * @purpose Main program for N-Body simulator (single threaded)
4  * @author Sam Moore
5  * @date August 2012
6  */
7
8 #include <stdlib.h>
9 #include <stdio.h>
10 #include <stdbool.h>
11 #include <assert.h>
12
13 #include "nbody.h"
14
15 int main(int argc, char ** argv)
16 {
17
18         System system;
19         System_Init(&system, (float[3]){320,240,0}, 0.1, 10, 1);
20         #ifdef _GRAPHICS_H
21                 Graphics_Init("N-Body", 640, 480);
22         #endif //_GRAPHICS_H
23
24         assert(System_AddBody(&system, 1, (float[2]){0.0f,0.0f}, (float[2]){0.0f,0.0f})->exists);
25         assert(System_AddBody(&system, 0.01, (float[2]){120.0f, -120.0f}, (float[2]){-1.1f, 1.0f})->exists);
26         while (true)
27         {
28
29                 System_Step(&system);
30                 //System_WriteData(&system, stdout);
31                 #ifdef _GRAPHICS_H
32                         Graphics_Clear(1, 1, 1); //Clear screen
33                         System_Draw(&system); //Draw system
34                         Graphics_Update(); //Update screen
35                         Process_Events(); //Process SDL events
36                 #endif //_GRAPHICS_H
37
38         }
39         System_Destroy(&system);
40         return 0;
41 }
42

UCC git Repository :: git.ucc.asn.au