-
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.
- Loading branch information
Yesim Zaim
committed
Feb 8, 2024
1 parent
b9f60d6
commit 2a948cf
Showing
3 changed files
with
21 additions
and
31 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,17 +1,15 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* :::::::: */ | ||
/* meta.h :+: :+: */ | ||
/* +:+ */ | ||
/* By: joppe <[email protected]> +#+ */ | ||
/* +#+ */ | ||
/* :::::::: */ | ||
/* meta.h :+: :+: */ | ||
/* +:+ */ | ||
/* By: joppe <[email protected]> +#+ */ | ||
/* +#+ */ | ||
/* Created: 2024/02/05 14:01:44 by joppe #+# #+# */ | ||
/* Updated: 2024/02/05 14:01:52 by joppe ######## odam.nl */ | ||
/* Updated: 2024/02/08 12:52:25 by yzaim ######## odam.nl */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
||
|
||
#ifndef META_H | ||
#define META_H | ||
|
||
|
@@ -52,7 +50,6 @@ | |
|
||
#define PI 3.1415926535 | ||
|
||
|
||
// Window | ||
// #define WINDOW_WIDTH 1920 | ||
// #define WINDOW_HEIGHT 1080 | ||
|
@@ -61,7 +58,6 @@ | |
|
||
#define BPP 4 | ||
|
||
|
||
// Game | ||
#define TICK_RATE (1.0 / 60.0) | ||
|
||
|
@@ -100,11 +96,12 @@ MAP_DOOR | |
} t_cell_type; | ||
|
||
typedef enum e_element_type { | ||
INVALID, | ||
CEIL_FLOOR, | ||
WALL, | ||
SPRITE, | ||
DOOR, | ||
NON_VALID | ||
DOOR_CL, | ||
DOOR_OP | ||
} t_element_type; | ||
|
||
typedef enum e_font_family { | ||
|
@@ -124,7 +121,6 @@ typedef struct s_font_atlas | |
char *pixels; | ||
} t_font_atlas; | ||
|
||
|
||
typedef union s_rgba | ||
{ | ||
uint32_t value; | ||
|
@@ -137,7 +133,6 @@ typedef union s_rgba | |
}; | ||
} t_rgba; | ||
|
||
|
||
typedef enum e_side { | ||
SIDE_N = 0, | ||
SIDE_S = 1, | ||
|
@@ -179,7 +174,6 @@ typedef struct s_player { | |
double z_buffer[WINDOW_WIDTH]; | ||
} t_player; | ||
|
||
|
||
typedef struct s_map { | ||
char *map_element; | ||
t_cell_type *level; | ||
|
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 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* :::::::: */ | ||
/* sprite.c :+: :+: */ | ||
/* +:+ */ | ||
/* By: jboeve <[email protected]> +#+ */ | ||
/* +#+ */ | ||
/* :::::::: */ | ||
/* sprite.c :+: :+: */ | ||
/* +:+ */ | ||
/* By: jboeve <[email protected]> +#+ */ | ||
/* +#+ */ | ||
/* Created: 2024/01/25 16:01:20 by jboeve #+# #+# */ | ||
/* Updated: 2024/02/07 12:48:55 by yzaim ######## odam.nl */ | ||
/* Updated: 2024/02/08 13:06:59 by yzaim ######## odam.nl */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -59,18 +59,14 @@ void sprite_calculate(t_player *p) | |
|
||
sprite_sort(p->sprite_dist, p->sprite_order, p->meta->attributes.sprite_count); | ||
|
||
// print_double_array("SPRITE DIST", p->sprite_dist, p->meta->attributes.sprite_count); | ||
|
||
i = 0; | ||
while (i < p->meta->attributes.sprite_count) | ||
{ | ||
const t_sprite *sp = p->meta->attributes.sprites; | ||
const t_vec2d s_pos = (t_vec2d){sp[p->sprite_order[i]].pos.x - p->position.x, sp[p->sprite_order[i]].pos.y - p->position.y}; | ||
|
||
|
||
const double inv_det = 1.0 / (p->cam_plane.x * p->direction.y) - (p->cam_plane.y * p->direction.x); | ||
|
||
|
||
double inv_det = 1.0 / (p->cam_plane.x * p->direction.y) - (p->cam_plane.y * p->direction.x); | ||
const t_vec2d transform = {inv_det * (p->direction.y * s_pos.x - p->direction.x * s_pos.y), | ||
inv_det * (-(p->cam_plane.y) * s_pos.x + p->cam_plane.x * s_pos.y)}; | ||
|
||
|
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 |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: yzaim <[email protected]> +#+ */ | ||
/* +#+ */ | ||
/* Created: 2024/01/08 15:43:19 by yzaim #+# #+# */ | ||
/* Updated: 2024/02/08 12:35:25 by yzaim ######## odam.nl */ | ||
/* Updated: 2024/02/08 12:54:47 by yzaim ######## odam.nl */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -58,8 +58,8 @@ t_element_type check_element_type(char *flag) | |
if (!ft_strncmp(flag, "SP", 2)) | ||
return (SPRITE); | ||
if (!ft_strncmp(flag, "DR", 2)) | ||
return (DOOR); | ||
return (NON_VALID); | ||
return (DOOR_CL); | ||
return (INVALID); | ||
} | ||
|
||
int handle_ceil_floor(t_attr *attributes, char *flag, char *content) | ||
|
@@ -150,7 +150,7 @@ int handle_element(t_meta *meta, t_element_type type, char *flag, char *content) | |
{ | ||
exit_code = input_sprite_texture_path(&meta->attributes.sprites, &meta->attributes.sprite_arr_index, content); | ||
} | ||
else if (type == DOOR) | ||
else if (type == DOOR_CL) | ||
{ | ||
exit_code = input_door_path(&meta->attributes.doors, content); | ||
} | ||
|
@@ -232,7 +232,7 @@ int parse_elements(t_meta *meta) | |
while (elements != NULL) | ||
{ | ||
t_element_type type = check_element_type(elements->flag); | ||
if (type != NON_VALID) | ||
if (type != INVALID) | ||
handle_element(meta, type, elements->flag, elements->content); | ||
elements = elements->next; | ||
} | ||
|