little cleanup
This commit is contained in:
parent
0962ba9d75
commit
0bc7eaa658
8
Makefile
8
Makefile
@ -6,7 +6,7 @@
|
|||||||
# By: houtworm <codam@houtworm.net> +#+ #
|
# By: houtworm <codam@houtworm.net> +#+ #
|
||||||
# +#+ #
|
# +#+ #
|
||||||
# Created: 2023/10/26 10:46:29 by houtworm #+# #+# #
|
# Created: 2023/10/26 10:46:29 by houtworm #+# #+# #
|
||||||
# Updated: 2023/11/05 10:27:42 by houtworm ######## odam.nl #
|
# Updated: 2023/11/05 11:49:30 by houtworm ######## odam.nl #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
@ -17,11 +17,13 @@ HEAD =-I ./include -I $(MLX)/include
|
|||||||
RM =rm -rf
|
RM =rm -rf
|
||||||
LIB =libft/libft.a getnextline/get_next_line.a mlx/build/libmlx42.a -ldl -lglfw -pthread -lm
|
LIB =libft/libft.a getnextline/get_next_line.a mlx/build/libmlx42.a -ldl -lglfw -pthread -lm
|
||||||
SRC =src/main/main.c\
|
SRC =src/main/main.c\
|
||||||
|
src/main/pickup.c\
|
||||||
src/main/init.c\
|
src/main/init.c\
|
||||||
src/main/error.c\
|
src/main/error.c\
|
||||||
src/main/cleanup.c\
|
src/main/cleanup.c\
|
||||||
src/parse/parse.c\
|
src/parse/parse.c\
|
||||||
src/parse/map.c\
|
src/parse/map.c\
|
||||||
|
src/parse/sprite.c\
|
||||||
src/draw/raycast.c\
|
src/draw/raycast.c\
|
||||||
src/draw/world.c\
|
src/draw/world.c\
|
||||||
src/draw/texture.c\
|
src/draw/texture.c\
|
||||||
@ -30,8 +32,8 @@ SRC =src/main/main.c\
|
|||||||
src/input/move.c\
|
src/input/move.c\
|
||||||
src/input/turn.c\
|
src/input/turn.c\
|
||||||
src/input/rest.c\
|
src/input/rest.c\
|
||||||
src/sprite/sprite.c\
|
src/sprite/check.c\
|
||||||
src/sprite/drawsprite.c
|
src/sprite/draw.c
|
||||||
OBJ =$(SRC:src/%.c=obj/%.o)
|
OBJ =$(SRC:src/%.c=obj/%.o)
|
||||||
|
|
||||||
all: libft getnextline mlx/build/mlx42.a $(NAME)
|
all: libft getnextline mlx/build/mlx42.a $(NAME)
|
||||||
|
6
cub3d.h
6
cub3d.h
@ -6,7 +6,7 @@
|
|||||||
/* By: houtworm <codam@houtworm.net> +#+ */
|
/* By: houtworm <codam@houtworm.net> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2023/10/26 10:46:35 by houtworm #+# #+# */
|
/* Created: 2023/10/26 10:46:35 by houtworm #+# #+# */
|
||||||
/* Updated: 2023/11/05 11:42:29 by houtworm ######## odam.nl */
|
/* Updated: 2023/11/05 11:52:12 by houtworm ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -104,6 +104,10 @@ void ft_cleanup(t_varlist *vl);
|
|||||||
// PARSE
|
// PARSE
|
||||||
t_varlist ft_parseconfigfile(t_varlist vl, char *filename);
|
t_varlist ft_parseconfigfile(t_varlist vl, char *filename);
|
||||||
char **ft_getmap(t_varlist *vl, int fd);
|
char **ft_getmap(t_varlist *vl, int fd);
|
||||||
|
char ft_addwalktroughdecor(t_varlist *vl, int x, int y, int number);
|
||||||
|
char ft_addsoliddecor(t_varlist *vl, int x, int y, int number);
|
||||||
|
char ft_addpickup(t_varlist *vl, int x, int y, int number);
|
||||||
|
char ft_addenemy(t_varlist *vl, int x, int y, int number);
|
||||||
// INPUT
|
// INPUT
|
||||||
void ft_processinput(t_varlist *vl);
|
void ft_processinput(t_varlist *vl);
|
||||||
void ft_processturn(t_varlist *vl, double rotspeed);
|
void ft_processturn(t_varlist *vl, double rotspeed);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: houtworm <codam@houtworm.net> +#+ */
|
/* By: houtworm <codam@houtworm.net> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2023/10/26 14:13:07 by houtworm #+# #+# */
|
/* Created: 2023/10/26 14:13:07 by houtworm #+# #+# */
|
||||||
/* Updated: 2023/11/05 11:42:14 by houtworm ######## odam.nl */
|
/* Updated: 2023/11/05 11:50:09 by houtworm ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -21,51 +21,6 @@ void ft_replaceimage(t_varlist *vl)
|
|||||||
vl->img = mlx_new_image(vl->mlx, vl->w, vl->h);
|
vl->img = mlx_new_image(vl->mlx, vl->w, vl->h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ft_pickup(t_varlist *vl, int i)
|
|
||||||
{
|
|
||||||
if (vl->sprite[i].number < 4)
|
|
||||||
vl->treasure++;
|
|
||||||
else if (vl->sprite[i].number < 7)
|
|
||||||
ft_putendl("Yummy\n");
|
|
||||||
else if (vl->sprite[i].number == 7)
|
|
||||||
ft_putendl("Found gold key\n");
|
|
||||||
else if (vl->sprite[i].number == 8)
|
|
||||||
ft_putendl("Found blue key\n");
|
|
||||||
else if (vl->sprite[i].number == 9)
|
|
||||||
vl->mgun = 1;
|
|
||||||
else if (vl->sprite[i].number == 10)
|
|
||||||
vl->ggun = 1;
|
|
||||||
else if (vl->sprite[i].number == 11)
|
|
||||||
vl->ammo += 10;
|
|
||||||
while (vl->sprite[i].x)
|
|
||||||
{
|
|
||||||
vl->sprite[i] = vl->sprite[i + 1];
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
vl->spritecount--;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ft_checkpickup(t_varlist *vl)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
while (vl->sprite[i].x)
|
|
||||||
{
|
|
||||||
if (vl->sprite[i].type == 2)
|
|
||||||
{
|
|
||||||
if ((int)vl->sprite[i].x == (int)vl->posx)
|
|
||||||
{
|
|
||||||
if ((int)vl->sprite[i].y == (int)vl->posy)
|
|
||||||
{
|
|
||||||
ft_pickup(vl, i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void mainloop(void *param)
|
void mainloop(void *param)
|
||||||
{
|
{
|
||||||
t_varlist *vl;
|
t_varlist *vl;
|
||||||
|
58
src/main/pickup.c
Normal file
58
src/main/pickup.c
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* :::::::: */
|
||||||
|
/* pickup.c :+: :+: */
|
||||||
|
/* +:+ */
|
||||||
|
/* By: houtworm <codam@houtworm.net> +#+ */
|
||||||
|
/* +#+ */
|
||||||
|
/* Created: 2023/10/26 14:13:07 by houtworm #+# #+# */
|
||||||
|
/* Updated: 2023/11/05 11:50:21 by houtworm ######## odam.nl */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "../../cub3d.h"
|
||||||
|
|
||||||
|
void ft_pickup(t_varlist *vl, int i)
|
||||||
|
{
|
||||||
|
if (vl->sprite[i].number < 4)
|
||||||
|
vl->treasure++;
|
||||||
|
else if (vl->sprite[i].number < 7)
|
||||||
|
ft_putendl("Yummy\n");
|
||||||
|
else if (vl->sprite[i].number == 7)
|
||||||
|
ft_putendl("Found gold key\n");
|
||||||
|
else if (vl->sprite[i].number == 8)
|
||||||
|
ft_putendl("Found blue key\n");
|
||||||
|
else if (vl->sprite[i].number == 9)
|
||||||
|
vl->mgun = 1;
|
||||||
|
else if (vl->sprite[i].number == 10)
|
||||||
|
vl->ggun = 1;
|
||||||
|
else if (vl->sprite[i].number == 11)
|
||||||
|
vl->ammo += 10;
|
||||||
|
while (vl->sprite[i].x)
|
||||||
|
{
|
||||||
|
vl->sprite[i] = vl->sprite[i + 1];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
vl->spritecount--;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ft_checkpickup(t_varlist *vl)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (vl->sprite[i].x)
|
||||||
|
{
|
||||||
|
if (vl->sprite[i].type == 2)
|
||||||
|
{
|
||||||
|
if ((int)vl->sprite[i].x == (int)vl->posx)
|
||||||
|
{
|
||||||
|
if ((int)vl->sprite[i].y == (int)vl->posy)
|
||||||
|
{
|
||||||
|
ft_pickup(vl, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
@ -6,7 +6,7 @@
|
|||||||
/* By: houtworm <codam@houtworm.net> +#+ */
|
/* By: houtworm <codam@houtworm.net> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2023/10/26 17:33:50 by houtworm #+# #+# */
|
/* Created: 2023/10/26 17:33:50 by houtworm #+# #+# */
|
||||||
/* Updated: 2023/11/05 11:45:14 by houtworm ######## odam.nl */
|
/* Updated: 2023/11/05 11:50:41 by houtworm ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -47,48 +47,6 @@ char ft_setplayerpos(t_varlist *vl, char dir, int x, int y)
|
|||||||
return ('0');
|
return ('0');
|
||||||
}
|
}
|
||||||
|
|
||||||
char ft_addwalktroughdecor(t_varlist *vl, int x, int y, int number)
|
|
||||||
{
|
|
||||||
vl->sprite[vl->spritecount].x = x + 0.5;
|
|
||||||
vl->sprite[vl->spritecount].y = y + 0.5;
|
|
||||||
vl->sprite[vl->spritecount].number = number;
|
|
||||||
vl->sprite[vl->spritecount].type = 1;
|
|
||||||
vl->spritecount++;
|
|
||||||
return ('0');
|
|
||||||
}
|
|
||||||
|
|
||||||
char ft_addsoliddecor(t_varlist *vl, int x, int y, int number)
|
|
||||||
{
|
|
||||||
vl->sprite[vl->spritecount].x = x + 0.5;
|
|
||||||
vl->sprite[vl->spritecount].y = y + 0.5;
|
|
||||||
vl->sprite[vl->spritecount].number = number;
|
|
||||||
vl->sprite[vl->spritecount].type = 1;
|
|
||||||
vl->spritecount++;
|
|
||||||
return ('2');
|
|
||||||
}
|
|
||||||
|
|
||||||
char ft_addpickup(t_varlist *vl, int x, int y, int number)
|
|
||||||
{
|
|
||||||
vl->sprite[vl->spritecount].x = x + 0.5;
|
|
||||||
vl->sprite[vl->spritecount].y = y + 0.5;
|
|
||||||
vl->sprite[vl->spritecount].number = number;
|
|
||||||
vl->sprite[vl->spritecount].type = 2;
|
|
||||||
if (number < 4)
|
|
||||||
vl->tottreasure++;
|
|
||||||
vl->spritecount++;
|
|
||||||
return ('0');
|
|
||||||
}
|
|
||||||
|
|
||||||
char ft_addenemy(t_varlist *vl, int x, int y, int number)
|
|
||||||
{
|
|
||||||
vl->sprite[vl->spritecount].x = x + 0.5;
|
|
||||||
vl->sprite[vl->spritecount].y = y + 0.5;
|
|
||||||
vl->sprite[vl->spritecount].number = number;
|
|
||||||
vl->sprite[vl->spritecount].type = 3;
|
|
||||||
vl->enemies++;
|
|
||||||
vl->spritecount++;
|
|
||||||
return ('2');
|
|
||||||
}
|
|
||||||
char **ft_getmap(t_varlist *vl, int fd)
|
char **ft_getmap(t_varlist *vl, int fd)
|
||||||
{
|
{
|
||||||
int y;
|
int y;
|
||||||
|
56
src/parse/sprite.c
Normal file
56
src/parse/sprite.c
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* :::::::: */
|
||||||
|
/* sprite.c :+: :+: */
|
||||||
|
/* +:+ */
|
||||||
|
/* By: houtworm <codam@houtworm.net> +#+ */
|
||||||
|
/* +#+ */
|
||||||
|
/* Created: 2023/10/26 17:33:50 by houtworm #+# #+# */
|
||||||
|
/* Updated: 2023/11/05 11:50:59 by houtworm ######## odam.nl */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "../../cub3d.h"
|
||||||
|
|
||||||
|
char ft_addwalktroughdecor(t_varlist *vl, int x, int y, int number)
|
||||||
|
{
|
||||||
|
vl->sprite[vl->spritecount].x = x + 0.5;
|
||||||
|
vl->sprite[vl->spritecount].y = y + 0.5;
|
||||||
|
vl->sprite[vl->spritecount].number = number;
|
||||||
|
vl->sprite[vl->spritecount].type = 1;
|
||||||
|
vl->spritecount++;
|
||||||
|
return ('0');
|
||||||
|
}
|
||||||
|
|
||||||
|
char ft_addsoliddecor(t_varlist *vl, int x, int y, int number)
|
||||||
|
{
|
||||||
|
vl->sprite[vl->spritecount].x = x + 0.5;
|
||||||
|
vl->sprite[vl->spritecount].y = y + 0.5;
|
||||||
|
vl->sprite[vl->spritecount].number = number;
|
||||||
|
vl->sprite[vl->spritecount].type = 1;
|
||||||
|
vl->spritecount++;
|
||||||
|
return ('2');
|
||||||
|
}
|
||||||
|
|
||||||
|
char ft_addpickup(t_varlist *vl, int x, int y, int number)
|
||||||
|
{
|
||||||
|
vl->sprite[vl->spritecount].x = x + 0.5;
|
||||||
|
vl->sprite[vl->spritecount].y = y + 0.5;
|
||||||
|
vl->sprite[vl->spritecount].number = number;
|
||||||
|
vl->sprite[vl->spritecount].type = 2;
|
||||||
|
if (number < 4)
|
||||||
|
vl->tottreasure++;
|
||||||
|
vl->spritecount++;
|
||||||
|
return ('0');
|
||||||
|
}
|
||||||
|
|
||||||
|
char ft_addenemy(t_varlist *vl, int x, int y, int number)
|
||||||
|
{
|
||||||
|
vl->sprite[vl->spritecount].x = x + 0.5;
|
||||||
|
vl->sprite[vl->spritecount].y = y + 0.5;
|
||||||
|
vl->sprite[vl->spritecount].number = number;
|
||||||
|
vl->sprite[vl->spritecount].type = 3;
|
||||||
|
vl->enemies++;
|
||||||
|
vl->spritecount++;
|
||||||
|
return ('2');
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* :::::::: */
|
/* :::::::: */
|
||||||
/* sprite.c :+: :+: */
|
/* check.c :+: :+: */
|
||||||
/* +:+ */
|
/* +:+ */
|
||||||
/* By: houtworm <codam@houtworm.net> +#+ */
|
/* By: houtworm <codam@houtworm.net> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
@ -1,7 +1,7 @@
|
|||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* :::::::: */
|
/* :::::::: */
|
||||||
/* drawsprite.c :+: :+: */
|
/* draw.c :+: :+: */
|
||||||
/* +:+ */
|
/* +:+ */
|
||||||
/* By: houtworm <codam@houtworm.net> +#+ */
|
/* By: houtworm <codam@houtworm.net> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
Loading…
Reference in New Issue
Block a user