Skip to content

Commit

Permalink
Added rc_rendering in play_sprite function but it will stuck
Browse files Browse the repository at this point in the history
  • Loading branch information
Tsunghao-C committed Sep 4, 2024
1 parent a6d4efc commit 02a1a44
Show file tree
Hide file tree
Showing 10 changed files with 132 additions and 338 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# By: tsuchen <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/08/15 12:02:08 by tsuchen #+# #+# #
# Updated: 2024/09/03 16:36:38 by tsuchen ### ########.fr #
# Updated: 2024/09/04 09:59:33 by tsuchen ### ########.fr #
# #
# **************************************************************************** #

Expand All @@ -32,7 +32,7 @@ SRCS_RC = raycasting.c render_wall.c render_utils.c

SRCS_VEC = vector.c vector_2.c vector_3.c

SRCS_FRM = lst_add_back.c lst_clear.c lst_last.c lst_new.c lst_size.c
SRCS_FRM = frame_lst_utils.c sprite.c

PATH_M = srcs/
PATH_PS = srcs/parser/
Expand Down
4 changes: 3 additions & 1 deletion includes/cub3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: tsuchen <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/15 00:19:44 by tsuchen #+# #+# */
/* Updated: 2024/09/04 09:44:06 by tsuchen ### ########.fr */
/* Updated: 2024/09/04 10:25:44 by tsuchen ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -160,5 +160,7 @@ void rc_mlx_pixel_put(t_image *image, int x, int y, int color);
void rc_stripe_pixel_put(t_data *data, int x, double ray_dist);
/* Mini Map */
void put_mini_map(t_data *data);
/* Sprite */
void play_sprite_forward(t_data *data, int map_x, int map_y);

#endif
10 changes: 8 additions & 2 deletions srcs/events/mouse_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: tsuchen <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/02 11:59:13 by jteissie #+# #+# */
/* Updated: 2024/09/04 09:38:09 by tsuchen ### ########.fr */
/* Updated: 2024/09/04 11:41:01 by tsuchen ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -46,9 +46,15 @@ static void change_door_state(t_data *data, t_vec *p_ray)
door_x = data->p_pos.x + p_ray->x;
door_y = data->p_pos.y + p_ray->y;
if (data->map[door_x][door_y] == 'D')
data->map[door_x][door_y] = 'O';
{
play_sprite_forward(data, door_x, door_y);
// data->map[door_x][door_y] = 'S';
}
else if (data->map[door_x][door_y] == 'O')
{
// play_sprite_backward(data, door_x, door_y);
data->map[door_x][door_y] = 'D';
}
}

void interact_door(t_data *data)
Expand Down
73 changes: 57 additions & 16 deletions srcs/frames/lst_new.c → srcs/frames/frame_lst_utils.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* lst_new.c :+: :+: :+: */
/* frame_lst_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tsuchen <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/10 11:28:30 by tsuchen #+# #+# */
/* Updated: 2024/09/03 16:17:52 by tsuchen ### ########.fr */
/* Created: 2024/05/10 11:39:29 by tsuchen #+# #+# */
/* Updated: 2024/09/04 09:58:46 by tsuchen ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -23,17 +23,58 @@ t_frame *lst_new(void)
lst->prev = NULL;
return (lst);
}
/*
#include <stdio.h>
int main(void)

void lst_add_back(t_frame **lst, t_frame *new_node)
{
t_frame *tmp;

if (!new_node)
return ;
if (!(*lst))
{
*lst = new_node;
return ;
}
tmp = *lst;
while (tmp->next)
tmp = tmp->next;
new_node->prev = tmp;
tmp->next = new_node;
}

void lst_clear(t_frame **lst, void (*del)(void *))
{
int a = 7;
t_list *lst;
lst = ft_lstnew(&a);
printf("val_lst: %d, add_lst: %p\n", *((int *)(lst->content)), lst->content);
printf("val_a : %d, add_a : %p\n", a, &a);
printf("add of nex in lst: %p\n", lst->next);
free(lst);
return (0);
}*/
t_frame *tmp;

while (*lst)
{
tmp = *lst;
*lst = (*lst)->next;
del(tmp);
}
}

t_frame *lst_last(t_frame *lst)
{
t_frame *tmp;

tmp = lst;
while (tmp->next)
tmp = tmp->next;
return (tmp);
}

int lst_size(t_frame *lst)
{
int i;
t_frame *tmp;

tmp = lst;
i = 0;
while (tmp)
{
i++;
tmp = tmp->next;
}
return (i);
}
118 changes: 0 additions & 118 deletions srcs/frames/lst_add_back.c

This file was deleted.

84 changes: 0 additions & 84 deletions srcs/frames/lst_clear.c

This file was deleted.

Loading

0 comments on commit 02a1a44

Please sign in to comment.