From 7d2280bd34487eace72c3dad5d772c066660f509 Mon Sep 17 00:00:00 2001 From: Boris Stefanovic <owldev@bluewin.ch> Date: Mon, 6 Dec 2021 11:30:37 +0100 Subject: [PATCH] prep work --- main.c | 5 ++++- planet/planet.c | 34 +++++++++++++++++++++++++++++++++- planet/planet.h | 2 +- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 5b38f57..cbaf99c 100644 --- a/main.c +++ b/main.c @@ -20,12 +20,14 @@ int main() } // TODO : create your system - + // end : create system while (true) { gfx_present(ctxt); // TODO : draw the current state of your system + // end : draw state of system // TODO : update your system + // end : update system gfx_clear(ctxt, COLOR_BLACK); if (gfx_keypressed() == SDLK_ESCAPE) { @@ -34,6 +36,7 @@ int main() } // TODO : Free your system + // end : free system gfx_destroy(ctxt); return EXIT_SUCCESS; } diff --git a/planet/planet.c b/planet/planet.c index 7352906..c9b7767 100644 --- a/planet/planet.c +++ b/planet/planet.c @@ -4,4 +4,36 @@ #define G 6.67e-11 #define M_SOLEIL 1.989e30 -// TODO : magic \ No newline at end of file + +/* +typedef struct _planet +{ + double mass; + vec2 pos; // x(t) + vec2 prec_pos; // x(t - dt) +} planet_t; +typedef struct _system +{ + planet_t star; // ex. The sun + uint32_t nb_planets; // The number of orbiting planets + planet_t *planets; // An array of orbiting planets +} system_t; +*/ + + +// TODO : complete all implementations + + +planet_t create_planet(double mass, vec2 pos); + + +system_t create_system(double delta_t); + + +void show_system(struct gfx_context_t *ctxt, system_t *system); + + +void update_system(system_t *system, double delta_t); + + +void free_system(system_t *system); diff --git a/planet/planet.h b/planet/planet.h index f21984e..0b2b87f 100644 --- a/planet/planet.h +++ b/planet/planet.h @@ -26,4 +26,4 @@ void show_system(struct gfx_context_t *ctxt, system_t *system); void update_system(system_t *system, double delta_t); void free_system(system_t *system); -#endif \ No newline at end of file +#endif -- GitLab