Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doors #27

Closed
wants to merge 45 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
99e0d22
have not finished adding doors
Feb 7, 2024
18f2d40
applying doors
Feb 7, 2024
cf9d21c
adding doors
Feb 7, 2024
b9f60d6
compiles now
Feb 8, 2024
2a948cf
parser for doors kinda working
Feb 8, 2024
22ae619
Merge branch 'parser_with_sprites' into doors
ys-zm Feb 9, 2024
b5c7ad8
added door tex
ys-zm Feb 9, 2024
925bf62
Add MAP_DOOR_OPEN MAP_DOOR_CLOSED
JopjeKnopje Feb 9, 2024
06604ae
changed door t_cell
ys-zm Feb 9, 2024
bdb7395
Wonky kinda works
JopjeKnopje Feb 9, 2024
f3a94b1
Can kinda toggle doors
JopjeKnopje Feb 9, 2024
31c90dc
Fix keys issue
JopjeKnopje Feb 9, 2024
6c434a3
Change y to x which fixed the doors randomly spawning
JopjeKnopje Feb 9, 2024
fc49e47
Can open doors without rotating first.
JopjeKnopje Feb 9, 2024
11a4f3d
fix workflow
JopjeKnopje Feb 9, 2024
572af27
Can kinda move a wall, only issue is the side texture of the nearby
JopjeKnopje Feb 9, 2024
6389030
cleaned up parser and added next level path
ys-zm Feb 10, 2024
8e0bcd8
can draw line where the texture should "fold"
JopjeKnopje Feb 10, 2024
ca521e0
Bla bla
JopjeKnopje Feb 10, 2024
7c43f95
Kinda buggy
JopjeKnopje Feb 11, 2024
ffb89ad
Fix raycaster directions not being correct
JopjeKnopje Feb 11, 2024
88c4cfa
Endless tunnel
JopjeKnopje Feb 11, 2024
a30c651
More trippy shit
JopjeKnopje Feb 11, 2024
febadb5
Still not working...
JopjeKnopje Feb 12, 2024
549b593
Back to square one
JopjeKnopje Feb 12, 2024
1fb3e50
HOLY SHIT
JopjeKnopje Feb 12, 2024
e0b6f78
Not there yet but getting close
JopjeKnopje Feb 12, 2024
0cab0ff
fixed rendering of the side of the doors
ys-zm Feb 12, 2024
9cb12c3
Fix minimap weirdness
JopjeKnopje Feb 12, 2024
df7b58b
Kinda works except the door is not filling the enitre tile
Feb 13, 2024
90ac40b
Where we left off
Feb 15, 2024
fb162b8
Trying to draw the rays
Feb 15, 2024
38ccc66
Render all rays in minimap
JopjeKnopje Feb 16, 2024
33cf873
Change color
JopjeKnopje Feb 16, 2024
ae0fcea
Idea kinda clear?
JopjeKnopje Feb 16, 2024
17a70fb
DOORS WORKK (for the y-axis only)
JopjeKnopje Feb 16, 2024
7781d37
Can hit doors in all directions
JopjeKnopje Feb 16, 2024
e6fe5a6
moved to func
JopjeKnopje Feb 16, 2024
a0936c8
Removed the `raycaster_cast_id` function
JopjeKnopje Feb 16, 2024
1590cc6
Rename `rays` to `hrays`
JopjeKnopje Feb 16, 2024
a380d5a
Fixed interactions not working caused by `-ofast` flag
JopjeKnopje Feb 16, 2024
55fb7e0
Kinda fixed door collision
JopjeKnopje Feb 16, 2024
ccb950d
working on adding hud
JopjeKnopje Feb 16, 2024
4a42bf9
Revert "working on adding hud"
JopjeKnopje Feb 23, 2024
219d010
Small stuff norm
JopjeKnopje Feb 23, 2024
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
Prev Previous commit
Next Next commit
added door tex
  • Loading branch information
ys-zm committed Feb 9, 2024
commit b5c7ad8c0907b4a2e543ad4462f1b452e179eb6d
2 changes: 1 addition & 1 deletion include/meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ void print_double_array(char *msg, double *arr, uint32_t size, t_sprite *sp, int
void print_ints_array(char *msg, int32_t *arr, uint32_t size);
void print_sprites_array(t_sprite *arr, uint32_t size);
void print_attributes(t_attr *attributes);

void print_door_data(t_door doors);
// sprite_utils.c

void sprite_sort(double *sprite_dist, int32_t *sprite_order, uint32_t sprite_count);
Expand Down
2 changes: 0 additions & 2 deletions src/game/player.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,4 @@ void player_raycast(t_player *p)
}

sprite_calculate(p);


}
4 changes: 3 additions & 1 deletion src/game/render_viewport.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ void render_viewport(mlx_image_t *image, t_player *p)
draw_column(p->meta, &p->rays[col], col, image->height);
col++;
}
// render sprites

// render doors


}
2 changes: 1 addition & 1 deletion src/parser/parse_elements.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ int input_sprite_texture_path(t_sprite **sprites_array, uint32_t *i ,char *conte

int input_door_path(t_door *doors, char *content)
{
doors->tex.tex_path = content;
doors->tex.tex_path = ft_strdup(content);
return (EXIT_SUCCESS);
}

Expand Down
13 changes: 13 additions & 0 deletions src/set_textures.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ int set_sprite_textures(uint32_t sprite_count, t_sprite *sprites)
return (EXIT_SUCCESS);
}

int set_door_texture(t_door *doors)
{
if (doors->door_count)
{
doors->tex.tex = mlx_load_png(doors->tex.tex_path);
if (doors->tex.tex == NULL)
return (EXIT_FAILURE);
}
return (EXIT_SUCCESS);
}

int set_textures(t_attr *attributes)
{
attributes->n.tex = mlx_load_png(attributes->n.tex_path);
Expand All @@ -72,6 +83,8 @@ int set_textures(t_attr *attributes)
return (pr_err(MLX_ERROR));
if (set_sprite_textures(attributes->sprite_count, attributes->sprites))
return (pr_err(MLX_ERROR));
if (set_door_texture(&attributes->doors))
return (pr_err(MLX_ERROR));
return (EXIT_SUCCESS);
}

17 changes: 17 additions & 0 deletions src/test_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,21 @@ void print_attributes(t_attr *attributes)
printf("C: %s\n", attributes->c.tex_path);
else
printf("C: %d,%d,%d\n", attributes->ceiling_c.r, attributes->ceiling_c.g, attributes->ceiling_c.b);
}

void print_door_data(t_door doors)
{
int i = 0;
printf("DOOR COUNT: %u\n", doors.door_count);
printf("DOOR TEX: %s\n", doors.tex.tex_path);
while (i < doors.door_count)
{
if (i == 0)
printf("DOOR IDX: ");
printf("%u", doors.idx[i]);
if (i < doors.door_count - 1)
printf(" | ");
i++;
}
printf("\n");
}
5 changes: 2 additions & 3 deletions test_maps/valid_tex.cub
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ C texture_examples/ceiling_square.png

SP texture_examples/pillar.png 4.5 2.5
SP texture_examples/barrel.png 5.5 3.5
SP texture_examples/hoofd.png 2.5 3.5
SP texture_examples/sexy.png 2.5 2.5
DR texture_examples/door.png

11111111111111
1000000001
1000000001
1000000001
1000000001
10000000D1
100000000111
111000N00111
100000000001
Expand Down
Binary file added texture_examples/door.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.