/*
** EPITECH PROJECT, 2018
** task01
** File description:
** I do task
*/
#include <stdlib.h>
#include "lib/s_sfml.h"
#include "lib/my_memory.h"
#include "game/memory.h"

sfml_t *init_sfml(int width, int height)
{
    sfml_t *sfml;
    sfVideoMode mode = {width, height, 32};

    sfml = (sfml_t*)malloc(sizeof(sfml_t));
    if (sfml == NULL)
	    return (NULL);
    sfml->width = width;
    sfml->height = height; 
    sfml->window = sfRenderWindow_create(mode, "runner",
    sfFullscreen | sfClose, NULL);
    sfRenderWindow_setMouseCursorVisible(sfml->window, 0);
    sfRenderWindow_setFramerateLimit(sfml->window, FRAME_RATE);
    sfml->vram = (uint32_t*)malloc(sizeof(uint32_t) * (width * height));
    sfml->texture = sfTexture_create(width, height);
    sfml->vram_sprite = sfSprite_create();
    sfml->sound = init_music("music/sikmu.ogg");
    sfml->debug = 0x00;
    sfml->key = 0x0000;
    return (sfml);
}

void free_sfml(sfml_t *sfml)
{
    sfRenderWindow_destroy(sfml->window);
    sfTexture_destroy(sfml->texture);
    sfSprite_destroy(sfml->vram_sprite);
    sfMusic_destroy(sfml->sound->music);
    free(sfml->vram);
    free(sfml);
}
