feat: better floor and walls
This commit is contained in:
parent
45622cf647
commit
a00a02e527
9 changed files with 59 additions and 20 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/11 16:02:29 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/03/29 15:02:13 by mcolonna ### ########.fr */
|
||||
/* Updated: 2024/04/02 12:39:30 by mcolonna ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -15,6 +15,7 @@
|
|||
const t_spriteinfo g_spritesmap[NB_SPRITES] = {
|
||||
{WALL_BORDER, 1, 50, 50, ANIMATION},
|
||||
{FLOOR_1, 1, 50, 50, ANIMATION},
|
||||
{FLOOR_2, 1, 50, 50, ANIMATION},
|
||||
{OBJECT_SNAS, 0, 50, 50, CHARACTER_STILL},
|
||||
{OBJECT_SNAS_DOWN, 1, 50, 50, ANIMATION},
|
||||
{OBJECT_SNAS_UP, 1, 50, 50, ANIMATION},
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/07 23:31:22 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/03/29 17:32:26 by mcolonna ### ########.fr */
|
||||
/* Updated: 2024/04/02 12:42:18 by mcolonna ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -32,7 +32,6 @@ static bool room_fromfile2(
|
|||
while (*line && *line != '\n')
|
||||
{
|
||||
roomcase = getroomcase(path, *line);
|
||||
room->surfaces[*i] = sprite_init(roomcase->surface_spr);
|
||||
if (roomcase->object)
|
||||
{
|
||||
room->objects[*i] = mem_alloc(err, room->mc, sizeof(t_object));
|
||||
|
|
@ -65,6 +64,7 @@ t_room room_fromfile(t_const_string path)
|
|||
while (room_fromfile2(fd, path, &i, &r))
|
||||
;
|
||||
mem_freeall(mc);
|
||||
room_patch(&r);
|
||||
return (r);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* room_utils.c :+: :+: :+: */
|
||||
/* room_utils1.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/13 16:26:28 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/03/29 17:21:17 by mcolonna ### ########.fr */
|
||||
/* Updated: 2024/04/02 12:44:30 by mcolonna ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -16,9 +16,9 @@
|
|||
#include "object.h"
|
||||
|
||||
static t_roomcase g_roomcases[] = {
|
||||
{c: '0', surface_spr: CASE_FLOOR, object: NULL},
|
||||
{c: '1', surface_spr: CASE_FLOOR, object: wall_init},
|
||||
{c: 'P', surface_spr: CASE_FLOOR, object: snas_init},
|
||||
{c: '0', object: NULL},
|
||||
{c: '1', object: wall_init},
|
||||
{c: 'P', object: snas_init},
|
||||
{c: '\0'}
|
||||
};
|
||||
|
||||
37
src/room_utils2.c
Normal file
37
src/room_utils2.c
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* room_utils2.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/02 12:33:48 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/04/02 12:51:20 by mcolonna ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "room_utils.h"
|
||||
#include "data_sprites.h"
|
||||
|
||||
void room_patch(t_room *room)
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
|
||||
x = -1;
|
||||
while (++x < room->width)
|
||||
{
|
||||
y = -1;
|
||||
while (++y < room->height)
|
||||
{
|
||||
if (y == 0 || y == room->height - 1)
|
||||
{
|
||||
room->surfaces[y * room->width + x] = sprite_init(CASE_WALL);
|
||||
room->objects[y * room->width + x] = NULL;
|
||||
}
|
||||
else
|
||||
room->surfaces[y * room->width + x] = sprite_init(
|
||||
CASE_FLOOR_1 + (x + y) % 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue