-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.c
62 lines (53 loc) · 1.69 KB
/
utils.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kmahdi <kmahdi@student.1337.ma> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/06/09 10:59:00 by kmahdi #+# #+# */
/* Updated: 2023/07/10 01:12:49 by kmahdi ### ########.fr */
/* */
/* ************************************************************************** */
#include "includes/cub3d.h"
void exit_msg(char *msg, int status)
{
printf("%s", msg);
exit(status);
}
void free_list(char **list)
{
int i;
i = 0;
while (list && list[i])
free(list[i++]);
free(list);
}
void mlx_put_pixel_to_img(t_img *img, int x, int y, int color)
{
char *dst;
if (x > 0 && x < WIDTH && y > 0 && y < HEIGHT)
{
dst = img->addr + (y * img->line_length + x
* (img->bits_per_pixel / 8));
*(unsigned int *)dst = color;
}
}
int exit_program(int key_code)
{
(void)key_code;
exit_msg("Exit the program with the X !!", 0);
return (0);
}
int convert_color(char **rgb)
{
unsigned char red;
unsigned char green;
unsigned char blue;
int value;
red = ft_cub_atoi(rgb[0]);
green = ft_cub_atoi(rgb[1]);
blue = ft_cub_atoi(rgb[2]);
value = ((red << 16) + (green << 8) + blue);
return (value);
}