Started from buttom go to the sky
This commit is contained in:
parent
96215449bd
commit
f811e55dea
4781 changed files with 10121 additions and 1743 deletions
42
stdme/src/blx/draw/draw.c
Normal file
42
stdme/src/blx/draw/draw.c
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* draw.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/12/21 20:19:59 by maiboyer #+# #+# */
|
||||
/* Updated: 2023/12/31 15:05:17 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "me/blx/blx.h"
|
||||
#include "me/blx/sprite.h"
|
||||
#include <mlx.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void blx_clear(t_blx *app, t_color col)
|
||||
{
|
||||
sprite_clear(&app->_data.screen, col);
|
||||
}
|
||||
|
||||
void blx_draw(t_blx *app, t_vi2d pos, t_color col)
|
||||
{
|
||||
t_usize i;
|
||||
t_usize j;
|
||||
|
||||
if (get_draw_mode(app) == MASK && col.a != 0)
|
||||
return ;
|
||||
i = 0;
|
||||
while (i < app->app.pixel_size)
|
||||
{
|
||||
j = 0;
|
||||
while (j < app->app.pixel_size)
|
||||
{
|
||||
sprite_draw(&app->_data.screen, vi2d(pos.x * app->app.pixel_size
|
||||
+ j, pos.y * app->app.pixel_size + i), col);
|
||||
j++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
34
stdme/src/blx/draw/draw_sprite.c
Normal file
34
stdme/src/blx/draw/draw_sprite.c
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* draw_sprite.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/12/26 22:12:31 by maiboyer #+# #+# */
|
||||
/* Updated: 2023/12/31 15:06:55 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "me/blx/blx.h"
|
||||
#include "me/blx/sprite.h"
|
||||
#include "me/types.h"
|
||||
|
||||
void draw_sprite(t_blx *app, t_vi2d pos, t_sprite *spr)
|
||||
{
|
||||
t_vi2d p;
|
||||
t_color col;
|
||||
|
||||
p.y = 0;
|
||||
while (p.y < spr->height)
|
||||
{
|
||||
p.x = 0;
|
||||
while (p.x < spr->width)
|
||||
{
|
||||
sprite_get_pixel(spr, p, &col);
|
||||
blx_draw(app, vi2d_add(pos, p), col);
|
||||
p.x++;
|
||||
}
|
||||
p.y++;
|
||||
}
|
||||
}
|
||||
82
stdme/src/blx/draw/draw_string.c
Normal file
82
stdme/src/blx/draw/draw_string.c
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* draw_string.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/12/27 19:02:59 by maiboyer #+# #+# */
|
||||
/* Updated: 2023/12/31 15:31:57 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "me/blx/blx.h"
|
||||
#include "me/blx/colors.h"
|
||||
#include "me/blx/sprite.h"
|
||||
#include "me/types.h"
|
||||
#include "me/vec2/vec2.h"
|
||||
#include <stdio.h>
|
||||
|
||||
static inline void inner(t_blx *app, char c, t_vi2d pixel_pos, t_color col)
|
||||
{
|
||||
t_vi2d o;
|
||||
t_color texel;
|
||||
t_vi2d offset;
|
||||
|
||||
o.x = (c - 32) % 16;
|
||||
o.y = (c - 32) / 16;
|
||||
texel = new_color(0, 0, 0);
|
||||
offset.y = 0;
|
||||
while (offset.y < 8)
|
||||
{
|
||||
offset.x = 0;
|
||||
while (offset.x < 8)
|
||||
{
|
||||
if (!sprite_get_pixel(&app->_data.font, vi2d(offset.x + o.x * 8,
|
||||
offset.y + o.y * 8), &texel) && texel.a == 0)
|
||||
blx_draw(app, vi2d_add(pixel_pos, offset), col);
|
||||
offset.x++;
|
||||
}
|
||||
offset.y++;
|
||||
}
|
||||
}
|
||||
|
||||
static inline t_draw_mode handle_draw_mode(t_blx *app, t_color col)
|
||||
{
|
||||
t_draw_mode m;
|
||||
|
||||
m = get_draw_mode(app);
|
||||
if (col.a != 0x00)
|
||||
set_draw_mode(app, ALPHA);
|
||||
else
|
||||
set_draw_mode(app, MASK);
|
||||
return (m);
|
||||
}
|
||||
|
||||
void blx_draw_string(t_blx *app, t_vi2d pos, t_const_str sText, t_color col)
|
||||
{
|
||||
t_vi2d s;
|
||||
t_draw_mode m;
|
||||
char c;
|
||||
|
||||
s.x = 0;
|
||||
s.y = 0;
|
||||
m = handle_draw_mode(app, col);
|
||||
while (*sText)
|
||||
{
|
||||
c = *sText++;
|
||||
if (c == '\n')
|
||||
{
|
||||
s.x = 0;
|
||||
s.y += 8;
|
||||
}
|
||||
else if (c == '\t')
|
||||
s.x += 8 * 4;
|
||||
else
|
||||
{
|
||||
inner(app, c, vi2d(pos.x + s.x, pos.y + s.y), col);
|
||||
s.x += 8;
|
||||
}
|
||||
}
|
||||
set_draw_mode(app, m);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue