Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ SRC =main.c \
render/init_graphics.c \
render/render_canvas.c \
\
minimap/mini_map.c \
minimap/mini_player.c \
minimap/utils_minimap.c \
minimap/ray_minimap.c \
\
parsing/check_order.c \
parsing/parse_prep.c \
parsing/validation.c \
Expand Down
1 change: 0 additions & 1 deletion inc/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
# include "player.h"
# include <math.h>
# include "textures.h"
# include "mini_map.h"
# include "raycast.h"
# include <sys/time.h>
#endif
21 changes: 0 additions & 21 deletions inc/mini_map.h

This file was deleted.

2 changes: 0 additions & 2 deletions inc/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ int load_player_dt(t_game *game);
int handle_keypressed(int keycodde, void *param);
int handle_keyrelease(int keycodde, void *param);
void handle_rotation(t_player *p, t_game *game);
void draw_minimap_player(t_game *game, int px, int py, t_minimap *m);
void mini_dir_player(t_game *game, t_line *line, t_minimap *m);
void update_movement(t_game *game);
int move_player(t_player *p, char **map, t_game *game);
void draw_line(t_game *game, t_line *line, int color);
Expand Down
11 changes: 1 addition & 10 deletions inc/struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,6 @@ typedef struct s_line
int step;
} t_line;

typedef struct s_minimap
{
double offset_x;
double offset_y;
int height;
int width;
int tile_size;
int color_tile;
} t_minimap;

typedef struct s_player
{
double pos_x;
Expand Down Expand Up @@ -78,6 +68,7 @@ typedef struct s_game
void *win_ptr;
char **config;
char **map;
int map_height;
char *path_to_map;
int cursorcreate_ca;
int c_color[3];
Expand Down
32 changes: 16 additions & 16 deletions src/engine/player/move_player.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,51 +12,51 @@

#include "main.h"

int move_up(t_player *p, char **map, double speed, double pad)
int move_up(t_player *p, char **map, double speed)
{
if (map[(int)p->pos_y][(int)(p->pos_x + p->dir_x * (speed + pad))] != '1')
if (map[(int)p->pos_y][(int)(p->pos_x + p->dir_x * speed)] != '1')
p->pos_x += p->dir_x * speed;
if (map[(int)(p->pos_y + p->dir_y * (speed + pad))][(int)p->pos_x] != '1')
if (map[(int)(p->pos_y + p->dir_y * speed)][(int)p->pos_x] != '1')
p->pos_y += p->dir_y * speed;
return (0);
}

int move_down(t_player *p, char **map, double speed, double pad)
int move_down(t_player *p, char **map, double speed)
{
if (map[(int)p->pos_y][(int)(p->pos_x - p->dir_x * (speed + pad))] != '1')
if (map[(int)p->pos_y][(int)(p->pos_x - p->dir_x * speed)] != '1')
p->pos_x -= p->dir_x * speed;
if (map[(int)(p->pos_y - p->dir_y * (speed + pad))][(int)p->pos_x] != '1')
if (map[(int)(p->pos_y - p->dir_y * speed)][(int)p->pos_x] != '1')
p->pos_y -= p->dir_y * speed;
return (0);
}

int move_rigth(t_player *p, char **map, double speed, double pad)
int move_rigth(t_player *p, char **map, double speed)
{
if (map[(int)p->pos_y][(int)(p->pos_x + p->plane_x * (speed + pad))] != '1')
if (map[(int)p->pos_y][(int)(p->pos_x + p->plane_x * speed)] != '1')
p->pos_x += p->plane_x * speed;
if (map[(int)(p->pos_y + p->plane_y * (speed + pad))][(int)p->pos_x] != '1')
if (map[(int)(p->pos_y + p->plane_y * speed)][(int)p->pos_x] != '1')
p->pos_y += p->plane_y * speed;
return (0);
}

int move_left(t_player *p, char **map, double speed, double pad)
int move_left(t_player *p, char **map, double speed)
{
if (map[(int)p->pos_y][(int)(p->pos_x - p->plane_x * (speed + pad))] != '1')
if (map[(int)p->pos_y][(int)(p->pos_x - p->plane_x * speed)] != '1')
p->pos_x -= p->plane_x * speed;
if (map[(int)(p->pos_y - p->plane_y * speed - pad)][(int)p->pos_x] != '1')
if (map[(int)(p->pos_y - p->plane_y * speed)][(int)p->pos_x] != '1')
p->pos_y -= p->plane_y * speed;
return (0);
}

int move_player(t_player *p, char **map, t_game *game)
{
if (p->key_w)
move_up(p, map, p->move_speed * game->delta_time, 0.30);
move_up(p, map, p->move_speed * game->delta_time);
if (p->key_s)
move_down(p, map, p->move_speed * game->delta_time, 0.30);
move_down(p, map, p->move_speed * game->delta_time);
if (p->key_d)
move_rigth(p, map, p->move_speed * game->delta_time, 0.30);
move_rigth(p, map, p->move_speed * game->delta_time);
if (p->key_a)
move_left(p, map, p->move_speed * game->delta_time, 0.30);
move_left(p, map, p->move_speed * game->delta_time);
return (0);
}
11 changes: 11 additions & 0 deletions src/engine/raycast/raycast.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ void setup_dda(t_game *game, t_ray *ray)
set_sidestep(game, ray);
}

static int check_limits(t_game *game, t_ray *ray)
{
if (ray->map_y < 0 || ray->map_y >= game->map_height)
return (1);
else if (ray->map_x < 0 || ray->map_x >= ft_strlen(game->map[ray->map_y]))
return (1);
return (0);
}

void dda(t_game *game, t_ray *ray)
{
setup_dda(game, ray);
Expand All @@ -72,6 +81,8 @@ void dda(t_game *game, t_ray *ray)
ray->map_y += ray->step_y;
ray->side = 1;
}
if (check_limits(game, ray) != 0)
break ;
if (game->map[ray->map_y][ray->map_x] == '1')
ray->hit = 1;
}
Expand Down
110 changes: 0 additions & 110 deletions src/minimap/mini_map.c

This file was deleted.

80 changes: 0 additions & 80 deletions src/minimap/mini_player.c

This file was deleted.

Loading