/* ** EPITECH PROJECT, 2018 ** task01 ** File description: ** I do task */ #include "game/draw.h" #include "game/core.h" static const uint8_t bullet_left[] = {64, 192, 64, 0, 0, 0, 0, 0}; static const uint8_t bullet_right[] = {128, 192, 128, 0, 0, 0, 0, 0}; static const uint8_t bullet_up[] = {64, 224, 0, 0, 0, 0, 0, 0}; static const uint8_t bullet_down[] = {224, 64, 0, 0, 0, 0, 0, 0}; static const uint8_t stone[] = {224, 160, 224, 0, 0, 0, 0, 0}; static const uint8_t thrower_up[] = {0, 0, 0, 0, 0, 60, 126, 126}; static const uint8_t thrower_down[] = {126, 126, 60, 0, 0, 0, 0, 0}; static const uint8_t thrower_right[] = {0, 192, 224, 224, 224, 224, 192, 0}; static const uint8_t thrower_left[] = {0, 3, 7, 7, 7, 7, 3, 0}; static const uint8_t *thrower[] = { thrower_down, thrower_up, thrower_down, thrower_right, thrower_left }; static const uint8_t *bullet[] = { bullet_up, bullet_down, bullet_right, bullet_left }; void draw_thrower(sfml_t *sfml, int x, int y, uint8_t direction) { int draw[4]; draw[0] = x; draw[1] = y; draw[2] = 3; draw[3] = 0x000000ff; draw_monochrome(sfml, thrower[direction], draw); } static void draw_stone(sfml_t *sfml, object_t *object) { int draw[4]; if (object == NULL) return; draw[0] = object->x - sfml->scene->camera->x; draw[1] = object->y - sfml->scene->camera->y; draw[3] = 0x000000ff; draw[2] = 3; draw_monochrome(sfml, stone, draw); } static void draw_bullet(sfml_t *sfml, object_t *object, uint8_t locate) { int draw[4]; draw[0] = object->x - sfml->scene->camera->x; draw[1] = object->y - sfml->scene->camera->y; draw[2] = 3; draw[3] = 0x000000ff; draw_monochrome(sfml, bullet[locate], draw); } static void draw_setup(sfml_t *sfml, thrower_t *thrower, int j) { if (thrower->action == ID_THROWER_STONE){ draw_stone(sfml, thrower->object[j]); return; } if (thrower->object[j] == NULL || thrower->object[j]->sleep == BULLET_STOP) return; draw_bullet(sfml, thrower->object[j], thrower->action - ID_THROWER_STONE - 1); } void draw_thrower_object(sfml_t *sfml) { int i; int j; i = -1; while (++i < sfml->scene->level->thrower_counter){ j = -1; while (++j < NB_OBJECT) draw_setup(sfml, sfml->scene->thrower[i], j); } }