npc : Functional npc_stack

This commit is contained in:
attilavs2 2024-08-01 17:37:42 +02:00
parent 0f887ea419
commit a86462fdb2
3 changed files with 11 additions and 12 deletions

View file

@ -175,16 +175,14 @@ void game_get_inputs(Game *game) {
if(keydown(KEY_F1)) {
NPC *mynpc = npc_create();
if(mynpc) {
mynpc->curx = player->x;
mynpc->cury = player->y;
mynpc->x = 0;
mynpc->y = 0;
mynpc->curx = (player->x << PRECISION)/PXSIZE;
mynpc->cury = (player->y << PRECISION)/PXSIZE;
mynpc->x = player->x;
mynpc->y = player->x;
mynpc->hasPath = 0;
mynpc->face = 0;
mynpc->paused = 0;
mynpc->has_dialog = 0;
dprint(0, 50, 0, "succes");
dupdate();
}
}

View file

@ -70,7 +70,8 @@ typedef struct {
} Sign;
typedef struct {
/* current coordinates of the NPC */
/* current coordinates of the NPC
* In 24:8 fixed point */
uint32_t curx;
uint32_t cury;

View file

@ -60,9 +60,9 @@ int npc_append_path(uint16_t x, uint16_t y, NPC *npc) {
npc->ypath = realloc(npc->ypath, npc->path_length * 2 + 2);
if(npc->xpath == NULL || npc->ypath == NULL)
return 1;
npc->xpath[npc->path_length] = x - npc->x;
npc->ypath[npc->path_length] = y - npc->y;
npc->path_length++;
npc->xpath[npc->path_length - 1] = x - npc->x;
npc->ypath[npc->path_length - 1] = y - npc->y;
return 0;
}
@ -297,12 +297,12 @@ void npc_draw(Game *game) {
Player *pl = &game->player;
uint32_t u;
for(u = 0; u < game->map_level->nbNPC; u++) {
npc_draw_single(&game->map_level->npcs[u], pl);
}
for(u = 0; u < npc_count; u++) {
npc_draw_single(&npc_stack[u], pl);
}
for(u = 0; u < game->map_level->nbNPC; u++) {
npc_draw_single(&game->map_level->npcs[u], pl);
}
}
void npc_reload(GUNUSED Game *game) { npc_count = 0; }