aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRudy Bousset <rbousset@z2r5p6.le-101.fr>2020-03-08 16:01:15 +0100
committerRudy Bousset <rbousset@z2r5p6.le-101.fr>2020-03-08 16:01:15 +0100
commitecfd8650cde7c9a92c5685150df46d7a3be19900 (patch)
tree2efa1afe47807d2c28e399efc4f18cb7c7457eaa
parentNormed (diff)
download42-cub3d-ecfd8650cde7c9a92c5685150df46d7a3be19900.tar.gz
42-cub3d-ecfd8650cde7c9a92c5685150df46d7a3be19900.tar.bz2
42-cub3d-ecfd8650cde7c9a92c5685150df46d7a3be19900.tar.xz
42-cub3d-ecfd8650cde7c9a92c5685150df46d7a3be19900.tar.zst
42-cub3d-ecfd8650cde7c9a92c5685150df46d7a3be19900.zip
Less retarded scaling and shit
-rw-r--r--inc/cub3d_defines.h2
-rw-r--r--src/ft_draw_hud.c37
-rw-r--r--src/ft_draw_scene.c10
-rw-r--r--src/ft_set_minimap_scale.c21
4 files changed, 57 insertions, 13 deletions
diff --git a/inc/cub3d_defines.h b/inc/cub3d_defines.h
index aee4e39..b2c1b8f 100644
--- a/inc/cub3d_defines.h
+++ b/inc/cub3d_defines.h
@@ -114,7 +114,7 @@ enum
** ====== CHARSET ======
*/
-# define FT_CHRST_VALID_PARSE "RNSEWFCLMD"
+# define FT_CHRST_VALID_PARSE "RNSEWFCLM"
# define FT_CHRST_MAP_ENTRY "012NSEWLD "
# define FT_CHRST_SPAWN "NSEW"
# define FT_CHRST_MAP_NON_WALL "02NESWLD"
diff --git a/src/ft_draw_hud.c b/src/ft_draw_hud.c
index fe73af8..4ae497a 100644
--- a/src/ft_draw_hud.c
+++ b/src/ft_draw_hud.c
@@ -10,7 +10,6 @@
/* */
/* ************************************************************************** */
-#include <libft.h>
#include <cub3d.h>
#include <mlx.h>
#include <stdint.h>
@@ -23,7 +22,7 @@ static void
uint32_t y;
int32_t col;
- col = 0x00373737;
+ col = 0x00353535;
x = 0;
y = wl->y_size - (map_h * scl) - 20;
while (x < (map_w * scl) + 20)
@@ -44,11 +43,45 @@ static void
}
}
+static void
+ ft_draw_stage_back(t_cub *clist)
+{
+ float x;
+ uint32_t y;
+ int32_t col;
+ uint16_t x_dest;
+ const uint16_t scl = clist->mlist.scale;
+
+ col = 0x00353535;
+ x = 0;
+ y = clist->wlist.y_size - (clist->mlist.map_h * scl) - 45;
+ x_dest = 1.5 * clist->mlist.scale + 70;
+ while (x_dest > (clist->mlist.map_w * scl) + 20)
+ {
+ x_dest--;
+ }
+ while (x < x_dest)
+ {
+ while (y < clist->wlist.y_size - (clist->mlist.map_h * scl) - 20)
+ {
+ *(int*)(clist->img.ptr +
+ ((uint8_t)x * 4 + (y * clist->img.sizeline))) = col;
+ y++;
+ }
+ y = clist->wlist.y_size - (clist->mlist.map_h * scl) - 45;
+ x += 1.0;
+ }
+}
+
int8_t
ft_draw_hud(t_cub *clist)
{
ft_draw_minimap_back(clist->mlist.map_h,
clist->mlist.map_w, &clist->wlist, clist);
ft_draw_map(clist->mlist.map, clist);
+ if (clist->mlist.isnlvl)
+ {
+ ft_draw_stage_back(clist);
+ }
return (0);
}
diff --git a/src/ft_draw_scene.c b/src/ft_draw_scene.c
index bcbf8a3..087457d 100644
--- a/src/ft_draw_scene.c
+++ b/src/ft_draw_scene.c
@@ -20,19 +20,19 @@ static int8_t
{
uint8_t len;
char *str;
- uint32_t x;
+ float x;
uint32_t y;
- x = 15;
- y = clist->wlist.y_size - (clist->mlist.map_h * clist->mlist.scale) - 20;
+ x = 0.5 * clist->mlist.scale;
+ y = clist->wlist.y_size - (clist->mlist.map_h * clist->mlist.scale) - 25;
len = 6 + ft_uintlen(clist->currlvl);
if (!(str = (char*)malloc((len + 1) * sizeof(char))))
return (-1);
ft_sprintf(str, "Stage %hd", clist->currlvl);
mlx_string_put(clist->wlist.wlx,
clist->wlist.winptr,
- x, y,
- 0x00ff0000,
+ (uint32_t)x, y,
+ 0x002288da,
str);
ft_memdel((void**)&str);
return (0);
diff --git a/src/ft_set_minimap_scale.c b/src/ft_set_minimap_scale.c
index 52c63e6..ed5ca1a 100644
--- a/src/ft_set_minimap_scale.c
+++ b/src/ft_set_minimap_scale.c
@@ -12,15 +12,26 @@
#include <cub3d.h>
+#include <libft.h>
void
ft_set_minimap_scale(t_cub *clist)
{
t_map *ml;
ml = &clist->mlist;
- ((ml->scale = (clist->wlist.x_size / (uint16_t)ml->map_w) - 1) < 1)
- ? (ml->scale = 1) : 0;
- (clist->wlist.y_size < (ml->map_h * ml->scale)) ? (ml->scale =
- (clist->wlist.y_size / (uint16_t)ml->map_h) - 1) : 0;
- (ml->scale >= 10) ? (ml->scale /= 4) : 0;
+ if (ml->map_w > ml->map_h)
+ {
+ ml->scale = (clist->wlist.x_size / (uint16_t)ml->map_w);
+ ml->scale = ((ml->scale - 1) < 1) ? (1) : (ml->scale);
+ ml->scale = (clist->wlist.y_size < (ml->map_h * ml->scale))
+ ? ((clist->wlist.y_size / (uint16_t)ml->map_h) - 1) : (ml->scale);
+ }
+ else
+ {
+ ml->scale = (clist->wlist.y_size / (uint16_t)ml->map_h);
+ ml->scale = ((ml->scale - 1) < 1) ? (1) : (ml->scale);
+ ml->scale = (clist->wlist.y_size < (ml->map_h * ml->scale))
+ ? ((clist->wlist.y_size / (uint16_t)ml->map_h) - 1) : (ml->scale);
+ }
+ ml->scale = (ml->scale >= 10) ? (ml->scale / 4) : (ml->scale);
}