-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from ys-zm/floor-ceiling-textures
Floor ceiling textures
- Loading branch information
Showing
28 changed files
with
259 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{ | ||
"files.associations": { | ||
"cstdlib": "c", | ||
"stdio.h": "c" | ||
} | ||
"cstdlib": "c", | ||
"stdio.h": "c", | ||
"meta.h": "c" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* cub3d.c :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: yzaim <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/01/08 15:24:47 by yzaim #+# #+# */ | ||
/* Updated: 2024/01/18 10:45:29 by jboeve ######## odam.nl */ | ||
/* :::::::: */ | ||
/* cub3d.c :+: :+: */ | ||
/* +:+ */ | ||
/* By: yzaim <[email protected]> +#+ */ | ||
/* +#+ */ | ||
/* Created: 2024/01/08 15:24:47 by yzaim #+# #+# */ | ||
/* Updated: 2024/01/24 11:14:56 by yzaim ######## odam.nl */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -111,6 +111,8 @@ int cub3d(int argc, char **argv) | |
printf("Tex_S: %s\n", meta.attributes.s.tex_path); | ||
printf("Tex_E: %s\n", meta.attributes.e.tex_path); | ||
printf("Tex_W: %s\n", meta.attributes.w.tex_path); | ||
printf("Tex_C: %s\n", meta.attributes.c.tex_path); | ||
printf("Tex_F: %s\n", meta.attributes.f.tex_path); | ||
|
||
init_mlx_images(&meta); | ||
// TODO Error check. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* :::::::: */ | ||
/* floorcaster.c :+: :+: */ | ||
/* +:+ */ | ||
/* By: yzaim <[email protected]> +#+ */ | ||
/* +#+ */ | ||
/* Created: 2024/01/24 13:13:37 by yzaim #+# #+# */ | ||
/* Updated: 2024/01/24 18:23:45 by jboeve ######## odam.nl */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "meta.h" | ||
|
||
t_vray floorcaster(t_vec2d pp, t_vec2d dir, t_vec2d cam_plane, uint32_t y) | ||
{ | ||
t_vray ray; | ||
t_vec2d raydir_left; | ||
t_vec2d raydir_right; | ||
|
||
raydir_left = ((t_vec2d){dir.x - cam_plane.x, dir.y - cam_plane.y}); | ||
raydir_right = ((t_vec2d){dir.x + cam_plane.x, dir.y + cam_plane.y}); | ||
|
||
int p = y - WINDOW_HEIGHT / 2; | ||
double posZ = 0.5 * WINDOW_HEIGHT; | ||
double row_distance = posZ / p; | ||
ray.step.x = row_distance * (raydir_right.x - raydir_left.x) / WINDOW_WIDTH; | ||
ray.step.y = row_distance * (raydir_right.y - raydir_left.y) / WINDOW_WIDTH; | ||
|
||
ray.floor.x = pp.x + row_distance * raydir_left.x; | ||
ray.floor.y = pp.y + row_distance * raydir_left.y; | ||
|
||
return (ray); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* :::::::: */ | ||
/* player.c :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: yzaim <[email protected]> +#+ +:+ +#+ */ | ||
|
@@ -91,10 +91,22 @@ void player_turn(t_player *p, float radiant) | |
|
||
void player_raycast(t_player *p) | ||
{ | ||
uint32_t w = p->meta->image->width; | ||
uint32_t h = p->meta->image->height; | ||
uint32_t col; | ||
double camera_x; | ||
uint32_t row; | ||
t_vec2d ray_start; | ||
double camera_x; | ||
|
||
|
||
row = 0; | ||
while (row < h) | ||
{ | ||
p->vrays[row] = floorcaster(p->position, p->direction, p->cam_plane, row); | ||
row++; | ||
} | ||
p->should_render = true; | ||
|
||
// TODO Just create the player.plane here instead of saving it. | ||
col = 0; | ||
while (col < p->meta->image->width) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* raycaster.c :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: yzaim <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/01/08 15:27:33 by yzaim #+# #+# */ | ||
/* Updated: 2024/01/18 12:05:53 by jboeve ######## odam.nl */ | ||
/* :::::::: */ | ||
/* raycaster.c :+: :+: */ | ||
/* +:+ */ | ||
/* By: yzaim <[email protected]> +#+ */ | ||
/* +#+ */ | ||
/* Created: 2024/01/08 15:27:33 by yzaim #+# #+# */ | ||
/* Updated: 2024/01/24 13:11:30 by yzaim ######## odam.nl */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* check_colors.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: yzaim <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/01/08 15:30:18 by yzaim #+# #+# */ | ||
/* Updated: 2024/01/08 15:33:48 by yzaim ### ########.fr */ | ||
/* :::::::: */ | ||
/* check_colors.c :+: :+: */ | ||
/* +:+ */ | ||
/* By: yzaim <[email protected]> +#+ */ | ||
/* +#+ */ | ||
/* Created: 2024/01/08 15:30:18 by yzaim #+# #+# */ | ||
/* Updated: 2024/01/24 11:18:50 by yzaim ######## odam.nl */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -64,7 +64,7 @@ bool colors_valid(char *file) | |
skip_spaces(&file); | ||
if (is_valid_element(file)) | ||
{ | ||
if (is_colour(file) && !is_valid_color(file)) | ||
if (!is_path(file) && is_floor_or_ceiling(file) && !is_valid_color(file)) | ||
return (false); | ||
} | ||
skip_line(&file); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* check_elements.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: yzaim <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/01/08 15:33:58 by yzaim #+# #+# */ | ||
/* Updated: 2024/01/08 15:42:20 by yzaim ### ########.fr */ | ||
/* :::::::: */ | ||
/* check_elements.c :+: :+: */ | ||
/* +:+ */ | ||
/* By: yzaim <[email protected]> +#+ */ | ||
/* +#+ */ | ||
/* Created: 2024/01/08 15:33:58 by yzaim #+# #+# */ | ||
/* Updated: 2024/01/24 11:02:13 by yzaim ######## odam.nl */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -96,7 +96,7 @@ bool is_missing(char *file) | |
{ | ||
i = 0; | ||
skip_spaces(&file); | ||
if ((is_valid_element(file) || is_colour(file))) | ||
if ((is_valid_element(file) || is_floor_or_ceiling(file))) | ||
{ | ||
while (*file && *file != element[i] && i < 6) | ||
i++; | ||
|
@@ -118,7 +118,7 @@ bool is_duplicate(char *file) | |
{ | ||
i = 0; | ||
skip_spaces(&file); | ||
if ((is_valid_element(file) || is_colour(file))) | ||
if ((is_valid_element(file) || is_floor_or_ceiling(file))) | ||
{ | ||
while (*file && *file != element[i] && i < 6) | ||
i++; | ||
|
Oops, something went wrong.