Skip to content
Snippets Groups Projects
Select Git revision
  • 6d16df21ca98d182260b3bc5bb762796c96e5149
  • main default protected
2 results

bpt.c

Blame
  • main.c 1.05 KiB
    #include "gfx/gfx.h"
    #include "vec2/vec2.h"
    #include "planet/planet.h"
    #include <stdio.h>
    #include <stdlib.h>
    #include <time.h>
    #include <SDL2/SDL.h>  
    
    #define SCREEN_WIDTH 1000
    #define SCREEN_HEIGHT 1000
    #define delta_t 8000 //en secondes
    
    
    
    int main()
    {
        srand(time(NULL));
        struct gfx_context_t *ctxt =
            gfx_create("Planetary system", SCREEN_WIDTH, SCREEN_HEIGHT);
        if (!ctxt)
        {
            fprintf(stderr, "Graphics initialization failed!\n");
            return EXIT_FAILURE;
        }
    
        // TODO : create your system
        system_t s = create_system();
        bool x = false;
            while (true){
                gfx_present(ctxt);
                gfx_clear(ctxt, COLOR_BLACK);
                // TODO : draw the current state of your system
                show_system(ctxt, &s);
                // TODO : update your system
                update_system(&s, delta_t, x);
                
                if (gfx_keypressed() == SDLK_ESCAPE){
                    break;
                }
            }
        // TODO : Free your system
        free(s.planets);
        gfx_destroy(ctxt);
        return EXIT_SUCCESS;
    }