This commit is contained in:
2024-10-06 23:11:45 -05:00
parent ecb3b9c5d1
commit a1d4b0a1d7
12 changed files with 134 additions and 39 deletions

View File

@ -14,4 +14,5 @@ target_sources(${DAWN_TARGET_NAME}
sign.c
interact.c
npc.c
door.c
)

View File

@ -0,0 +1,14 @@
/**
* Copyright (c) 2024 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "door.h"
#include "assert/assert.h"
void doorInit(door_t *door) {
assertNotNull(door, "Door cannot be NULL.");
door->bruv = 0;
}

View File

@ -0,0 +1,20 @@
/**
* Copyright (c) 2024 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "dawn.h"
typedef struct {
uint8_t bruv;
} door_t;
/**
* Initializes a door.
*
* @param door Door to initialize.
*/
void doorInit(door_t *door);

View File

@ -37,6 +37,10 @@ void entityInit(
signInit(&entity->sign);
break;
case ENTITY_TYPE_DOOR:
doorInit(&entity->door);
break;
case ENTITY_TYPE_PLAYER:
playerInit(entity);
break;

View File

@ -10,6 +10,7 @@
#include "sign.h"
#include "entitydirection.h"
#include "npc.h"
#include "door.h"
typedef struct _map_t map_t;
@ -17,7 +18,8 @@ typedef enum {
ENTITY_TYPE_NULL = 0,
ENTITY_TYPE_PLAYER = 1,
ENTITY_TYPE_NPC = 2,
ENTITY_TYPE_SIGN = 3
ENTITY_TYPE_SIGN = 3,
ENTITY_TYPE_DOOR = 4
} entitytype_t;
typedef enum {
@ -49,6 +51,7 @@ typedef struct _entity_t {
player_t player;
npc_t npc;
sign_t sign;
door_t door;
};
} entity_t;

View File

@ -15,10 +15,11 @@ void entityInteractEntity(
assertNotNull(source, "entityInteractEntity: Source is NULL!");
assertNotNull(target, "entityInteractEntity: Target is NULL!");
source->state = ENTITY_STATE_TALKING;
target->state = ENTITY_STATE_TALKING;
switch(target->type) {
case ENTITY_TYPE_NPC:
source->state = ENTITY_STATE_TALKING;
target->state = ENTITY_STATE_TALKING;
target->direction = entityDirectionLookAt(
target->x, target->y,
source->x, source->y
@ -27,11 +28,13 @@ void entityInteractEntity(
return;
case ENTITY_TYPE_SIGN:
source->state = ENTITY_STATE_TALKING;
target->state = ENTITY_STATE_TALKING;
textboxSetText("Sign", target->sign.text);
return;
case ENTITY_TYPE_DOOR:
textboxSetText("Door", "It's a door.");
return;
default:
return;
}
@ -44,10 +47,11 @@ void entityInteractTile(
assertNotNull(source, "entityInteractTile: Source is NULL!");
switch(tile) {
case TILE_ID_WATER:
textboxSetText(NULL, "You cannot swim.");
case TILE_WATER:
textboxSetText(NULL, "A refreshing pool of water.");
source->state = ENTITY_STATE_TALKING;
return;
default:
break;
}

View File

@ -9,8 +9,11 @@
bool_t tileIsSolid(const tile_t tile) {
switch(tile) {
case TILE_ID_WATER:
case TILE_WATER:
case TILE_BUILDING_WALL:
case TILE_ROOF:
return true;
default:
return false;

View File

@ -9,9 +9,12 @@
#include "dawn.h"
typedef enum {
TILE_ID_NULL = 0,
TILE_ID_GRASS = 1,
TILE_ID_WATER = 2
TILE_NULL = 0,
TILE_GRASS = 1,
TILE_WATER = 2,
// TILE_DOOR = 3,
TILE_BUILDING_WALL = 4,
TILE_ROOF = 5
} tile_t;
/**