-
Notifications
You must be signed in to change notification settings - Fork 0
/
render_shapes.c
90 lines (82 loc) · 2.32 KB
/
render_shapes.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* render_shapes.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hgrissen <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/01/21 17:46:46 by hgrissen #+# #+# */
/* Updated: 2021/02/19 11:54:31 by hgrissen ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
void draw_rect(int x, int y, int clr)
{
int i;
int j;
i = x;
if (x < 0 || x > g_prm.w || y < 0 || y > g_prm.h)
i = x + TILE_SIZE / MINI_MAP;
while (i < x + (TILE_SIZE / MINI_MAP))
{
j = y;
while (j < y + (TILE_SIZE / MINI_MAP))
{
if (i % (x + TILE_SIZE / MINI_MAP) == 0 || (i + 1)
% (x + TILE_SIZE / MINI_MAP) == 0
|| j % (y + TILE_SIZE / MINI_MAP) == 0
|| (j + 1) % (y + TILE_SIZE / MINI_MAP) == 0)
{
my_mlx_pixel_put(&g_img, i, j, 0x000000);
}
else
my_mlx_pixel_put(&g_img, i, j, clr);
j++;
}
i++;
}
}
void drawcircle(int xc, int yc, int x, int y)
{
my_mlx_pixel_put(&g_img, xc + x, yc + y, C_SPRITE);
my_mlx_pixel_put(&g_img, xc - x, yc + y, C_SPRITE);
my_mlx_pixel_put(&g_img, xc + x, yc - y, C_SPRITE);
my_mlx_pixel_put(&g_img, xc - x, yc - y, C_SPRITE);
my_mlx_pixel_put(&g_img, xc + y, yc + x, C_SPRITE);
my_mlx_pixel_put(&g_img, xc - y, yc + x, C_SPRITE);
my_mlx_pixel_put(&g_img, xc + y, yc - x, C_SPRITE);
my_mlx_pixel_put(&g_img, xc - y, yc - x, C_SPRITE);
}
void circlebres(int xc, int yc, int r, int clr)
{
int x;
int y;
int d;
x = 0;
y = r;
clr = 0;
d = 3 - 2 * r;
drawcircle(xc, yc, x, y);
while (y >= x)
{
x++;
if (d > 0)
{
y--;
d = d + 4 * (x - y) + 10;
}
else
d = d + 4 * x + 6;
drawcircle(xc, yc, x, y);
}
}
void draw_ver(int x, int start, int end, int clr)
{
int i;
i = start;
while (i < end)
{
my_mlx_pixel_put(&g_img, x, i, clr);
i++;
}
}