orton_runner/src/game/collision_show.c

62 lines
1.4 KiB
C

/*
** EPITECH PROJECT, 2018
** task01
** File description:
** I do task
*/
#include "lib/my_graphics.h"
#include "game/game.h"
#include "game/core.h"
static void collision_show_thrower(sfml_t *sfml,
object_t *object, camera_t *camera, uint8_t action)
{
int rect[5];
int i;
int j;
if (object == NULL ||
(action != ID_THROWER_STONE && object->sleep == BULLET_STOP))
return;
rect[0] = object->x - camera->x;
rect[1] = object->y - camera->y;
rect[2] = object->x - camera->x + 24;
rect[3] = object->y - camera->y + 24;
rect[4] = 2;
my_rectangle(sfml, rect, 0xff0000ff, 0x00000000);
}
static void thrower_show(sfml_t *sfml)
{
int i;
int j;
i = -1;
while (++i < sfml->scene->level->thrower_counter){
j = -1;
while (++j < NB_OBJECT)
collision_show_thrower(sfml,
sfml->scene->thrower[i]->object[j], sfml->scene->camera,
sfml->scene->thrower[i]->action);
}
}
void collision_show(sfml_t *sfml)
{
int rect[5];
if ((!(sfml->key & PRES_A) && sfml->key & KEY_A)){
sfml->key &= ~KEY_A;
sfml->debug ^= 0x01;
}
if (!(sfml->debug & 0x01))
return;
rect[0] = sfml->scene->player->x - sfml->scene->camera->x + 8;
rect[1] = sfml->scene->player->y - sfml->scene->camera->y;
rect[2] = sfml->scene->player->x - sfml->scene->camera->x + 56;
rect[3] = sfml->scene->player->y - sfml->scene->camera->y + 64;
rect[4] = 2;
my_rectangle(sfml, rect, 0xff0000ff, 0x00000000);
thrower_show(sfml);
}