intra to gitea
This commit is contained in:
+44
-23
@@ -6,7 +6,7 @@
|
||||
/* By: jle-neze <[email protected]> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/09/12 18:18:26 by jle-neze #+# #+# */
|
||||
/* Updated: 2025/09/12 18:18:52 by jle-neze ### ########.fr */
|
||||
/* Updated: 2025/10/29 15:30:00 by jle-neze ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -14,46 +14,67 @@
|
||||
|
||||
void draw_background(t_game *g)
|
||||
{
|
||||
int x, y, half = g->gfx.h / 2;
|
||||
int x;
|
||||
int y;
|
||||
int half;
|
||||
|
||||
for (y = 0; y < g->gfx.h; y++)
|
||||
y = 0;
|
||||
half = g->gfx.h / 2;
|
||||
while (y < g->gfx.h)
|
||||
{
|
||||
for (x = 0; x < g->gfx.w; x++)
|
||||
x = 0;
|
||||
while (x < g->gfx.w)
|
||||
{
|
||||
if (y < half)
|
||||
img_put_pixel(&g->gfx.frame, x, y, g->colors.ceil);
|
||||
else
|
||||
img_put_pixel(&g->gfx.frame, x, y, g->colors.floor);
|
||||
x++;
|
||||
}
|
||||
y++;
|
||||
}
|
||||
}
|
||||
|
||||
/* aussi exposée dans raycast.c, mais on garde la déclaration ici pour réutiliser ailleurs */
|
||||
void draw_vline(t_game *g, int x, int y0, int y1, int color)
|
||||
void draw_vline(t_game *g, int x, t_vline v)
|
||||
{
|
||||
if (y0 < 0) y0 = 0;
|
||||
if (y1 >= g->gfx.h) y1 = g->gfx.h - 1;
|
||||
for (int y = y0; y <= y1; y++)
|
||||
img_put_pixel(&g->gfx.frame, x, y, color);
|
||||
int y;
|
||||
|
||||
if (v.y0 < 0)
|
||||
v.y0 = 0;
|
||||
if (v.y1 >= g->gfx.h)
|
||||
v.y1 = g->gfx.h - 1;
|
||||
y = v.y0;
|
||||
while (y <= v.y1)
|
||||
{
|
||||
img_put_pixel(&g->gfx.frame, x, y, v.color);
|
||||
y++;
|
||||
}
|
||||
}
|
||||
|
||||
void draw_tex_vline(t_game *g, int x, int y0, int y1,
|
||||
t_tex *tex, int tex_x, double step, double tex_pos)
|
||||
void draw_tex_vline(t_game *g, int x, t_texline l)
|
||||
{
|
||||
if (y0 < 0)
|
||||
int y;
|
||||
int tex_y;
|
||||
unsigned int color;
|
||||
|
||||
if (l.y0 < 0)
|
||||
{
|
||||
tex_pos += step * (-y0);
|
||||
y0 = 0;
|
||||
l.tex_pos += l.step * (-l.y0);
|
||||
l.y0 = 0;
|
||||
}
|
||||
if (y1 >= g->gfx.h)
|
||||
y1 = g->gfx.h - 1;
|
||||
for (int y = y0; y <= y1; y++)
|
||||
if (l.y1 >= g->gfx.h)
|
||||
l.y1 = g->gfx.h - 1;
|
||||
y = l.y0;
|
||||
while (y <= l.y1)
|
||||
{
|
||||
int tex_y = (int)tex_pos;
|
||||
if (tex_y < 0) tex_y = 0;
|
||||
if (tex_y >= tex->h) tex_y = tex->h - 1;
|
||||
unsigned int color = tex_get_pixel(tex, tex_x, tex_y);
|
||||
tex_y = (int)l.tex_pos;
|
||||
if (tex_y < 0)
|
||||
tex_y = 0;
|
||||
if (tex_y >= l.tex->h)
|
||||
tex_y = l.tex->h - 1;
|
||||
color = tex_get_pixel(l.tex, l.tex_x, tex_y);
|
||||
img_put_pixel(&g->gfx.frame, x, y, (int)color);
|
||||
tex_pos += step;
|
||||
l.tex_pos += l.step;
|
||||
y++;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user