diff --git a/Makefile b/Makefile index c13d7d2..bbfaef6 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ INCLUDES = includes/ CODE = main error env input timedloop \ data_assets data_sprites \ display1 display2 display_utils sprite \ - room room_utils point \ + room1 room2 room_utils point \ object_character object_snas object_wall LIBRARIES = mlx libtf LIBRARIES_FILES = libtf/libtf.a diff --git a/src/room.c b/src/room1.c similarity index 81% rename from src/room.c rename to src/room1.c index 9ea40ba..b91c186 100644 --- a/src/room.c +++ b/src/room1.c @@ -1,12 +1,12 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* room.c :+: :+: :+: */ +/* room1.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: mcolonna +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/07 23:31:22 by mcolonna #+# #+# */ -/* Updated: 2024/03/29 17:21:58 by mcolonna ### ########.fr */ +/* Updated: 2024/03/29 17:32:26 by mcolonna ### ########.fr */ /* */ /* ************************************************************************** */ @@ -127,23 +127,3 @@ void room_free(t_room room) { mem_freeall(room.mc); } - -t_object *room_getobjectfaced(t_room room, t_character *character, t_point pos) -{ - point_addto(&pos, point_fromdirection(character->direction)); - return (room.objects[pos.y * room.width + pos.x]); -} - -bool room_canwalk(t_room room, t_character *character, t_point pos) -{ - t_point after; - t_object *obj; - - after = pos; - point_addto(&after, point_fromdirection(character->direction)); - if (after.y <= 0 || after.y >= room.height - 1 - || after.x <= 0 || after.x >= room.width - 1) - return (false); - obj = room_getobjectfaced(room, character, pos); - return (!obj || !obj->solid); -} diff --git a/src/room2.c b/src/room2.c new file mode 100644 index 0000000..e435179 --- /dev/null +++ b/src/room2.c @@ -0,0 +1,39 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* room2.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: mcolonna +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/03/07 23:31:22 by mcolonna #+# #+# */ +/* Updated: 2024/03/29 17:32:47 by mcolonna ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include "room.h" +#include "error.h" +#include "libtf.h" +#include "env.h" +#include "room_utils.h" + +t_object *room_getobjectfaced( + t_room room, t_character *character, t_point pos) +{ + point_addto(&pos, point_fromdirection(character->direction)); + return (room.objects[pos.y * room.width + pos.x]); +} + +bool room_canwalk(t_room room, t_character *character, t_point pos) +{ + t_point after; + t_object *obj; + + after = pos; + point_addto(&after, point_fromdirection(character->direction)); + if (after.y <= 0 || after.y >= room.height - 1 + || after.x <= 0 || after.x >= room.width - 1) + return (false); + obj = room_getobjectfaced(room, character, pos); + return (!obj || !obj->solid); +}