Skip to content
Snippets Groups Projects
Commit 1ac257db authored by florian.burgener's avatar florian.burgener
Browse files

Add sleeping time in the main loop

parent 840846af
No related branches found
No related tags found
No related merge requests found
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
#include "Vector2.h" #include "Vector2.h"
#include "gfx/gfx.h" #include "gfx/gfx.h"
#define SCREEN_WIDTH 1500 #define SCREEN_WIDTH 1000
#define SCREEN_HEIGHT 1500 #define SCREEN_HEIGHT 1000
const double G = 6.67430 * 1E-11; const double G = 6.67430 * 1E-11;
SolarSystem *solar_system_create(double interval) { SolarSystem *solar_system_create(double interval) {
...@@ -22,7 +22,7 @@ SolarSystem *solar_system_create(double interval) { ...@@ -22,7 +22,7 @@ SolarSystem *solar_system_create(double interval) {
double perihelion_1 = 149.6 * 1E9 * (1 - 0.01671123); double perihelion_1 = 149.6 * 1E9 * (1 - 0.01671123);
solar_system->objects[1] = celestial_object_create(5.972 * 1E24, vector2_create(-perihelion_1, 0)); solar_system->objects[1] = celestial_object_create(5.972 * 1E24, vector2_create(-perihelion_1, 0));
double perihelion_2 = 227.9 * 1E9 * (1 - 0.0934); double perihelion_2 = 227.9 * 1E9 * (1 - 0.02934);
solar_system->objects[2] = celestial_object_create(6.39 * 1E23, vector2_create(-perihelion_2, 0)); solar_system->objects[2] = celestial_object_create(6.39 * 1E23, vector2_create(-perihelion_2, 0));
return solar_system; return solar_system;
......
...@@ -2,13 +2,14 @@ ...@@ -2,13 +2,14 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
#include <unistd.h>
#include "SolarSystem.h" #include "SolarSystem.h"
#include "Vector2.h" #include "Vector2.h"
// #include "gfx/gfx.h" // #include "gfx/gfx.h"
#define SCREEN_WIDTH 1500 #define SCREEN_WIDTH 1000
#define SCREEN_HEIGHT 1500 #define SCREEN_HEIGHT 1000
int main() { int main() {
// srand(time(NULL)); // srand(time(NULL));
...@@ -21,7 +22,7 @@ int main() { ...@@ -21,7 +22,7 @@ int main() {
return EXIT_FAILURE; return EXIT_FAILURE;
} }
SolarSystem *solar_system = solar_system_create(10000 * 3); SolarSystem *solar_system = solar_system_create(10000);
while (true) { while (true) {
gfx_present(context); gfx_present(context);
...@@ -32,6 +33,8 @@ int main() { ...@@ -32,6 +33,8 @@ int main() {
if (gfx_keypressed() == SDLK_ESCAPE) { if (gfx_keypressed() == SDLK_ESCAPE) {
break; break;
} }
sleep(0.01);
} }
gfx_destroy(context); gfx_destroy(context);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment