norm
This commit is contained in:
parent
97097c2529
commit
a7e8cdc0c1
3 changed files with 42 additions and 23 deletions
2
Makefile
2
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
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* room.c :+: :+: :+: */
|
||||
/* room1.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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);
|
||||
}
|
39
src/room2.c
Normal file
39
src/room2.c
Normal file
|
@ -0,0 +1,39 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* room2.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/07 23:31:22 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/03/29 17:32:47 by mcolonna ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <fcntl.h>
|
||||
#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);
|
||||
}
|
Loading…
Add table
Reference in a new issue