/*
** EPITECH PROJECT, 2018
** task01
** File description:
** I do task
*/
#include "lib/my_graphics.h"
#include "game/kinematic.h"
#include "game/core.h"

void fade(sfml_t *sfml, uint8_t action)
{
	uint8_t *vram = (uint8_t*)sfml->vram;
	int32_t fade_alpha;
	uint8_t fade_color;
	int i;

	fade_alpha = 0xfe;
	while (fade_alpha >= 0){
		i = -1;
		fade_color = (action & FADE_OPEN) ? 0xff -
	fade_alpha : fade_alpha;
		while (++i < sfml->width * sfml->height){
			vram[(i << 2)] = (vram[(i << 2)]) ? fade_color : 0;
			vram[(i << 2) + 1] = (vram[(i << 2) + 1])
			? fade_color : 0;
			vram[(i << 2) + 2] = (vram[(i << 2) + 2])
			? fade_color : 0;
		}
		my_display_vram(sfml);
		fade_alpha -= FADE_SPEED;
	}
}
