Add direction to the door

This commit is contained in:
2024-10-06 23:21:28 -05:00
parent a1d4b0a1d7
commit 5334f0944e
5 changed files with 66 additions and 6 deletions

View File

@ -10,5 +10,16 @@
void doorInit(door_t *door) {
assertNotNull(door, "Door cannot be NULL.");
door->bruv = 0;
}
void doorDestinationSet(
door_t *door,
const int32_t x,
const int32_t y,
const entitydirection_t direction
) {
assertNotNull(door, "Door cannot be NULL.");
door->x = x;
door->y = y;
door->direction = direction;
}

View File

@ -6,10 +6,12 @@
*/
#pragma once
#include "dawn.h"
#include "entitydirection.h"
typedef struct {
uint8_t bruv;
int32_t x;
int32_t y;
entitydirection_t direction;
} door_t;
/**
@ -17,4 +19,19 @@ typedef struct {
*
* @param door Door to initialize.
*/
void doorInit(door_t *door);
void doorInit(door_t *door);
/**
* Sets the destination of a door.
*
* @param door Door to set the destination of.
* @param x X coordinate of the destination.
* @param y Y coordinate of the destination.
* @param direction Direction the player should face when they arrive.
*/
void doorDestinationSet(
door_t *door,
const int32_t x,
const int32_t y,
const entitydirection_t direction
);

View File

@ -32,7 +32,8 @@ void entityInteractEntity(
return;
case ENTITY_TYPE_DOOR:
textboxSetText("Door", "It's a door.");
entityPositionSet(source, target->door.x, target->door.y);
source->direction = target->door.direction;
return;
default: