crocparty/game/map/game_map_entities.c

86 lines
2.7 KiB
C
Raw Normal View History

2024-02-29 03:42:03 +00:00
#include <assert.h>
2024-02-28 21:14:48 +00:00
#include "sys/sys.h"
2024-02-29 00:10:09 +00:00
#include "game/game.h"
2024-02-28 21:14:48 +00:00
#include "game_map.h"
sys_i32 game_map_player_start_x;
sys_i32 game_map_player_start_y;
// called by map_game_map_create_entities
void map_game_map_player_spawn_create(sys_i32 x, sys_i32 y) {
// center, because the entity has top-left positioning
game_map_player_start_x = x * TILE_SZ_MICROPIXEL + PIXEL_SZ_MICROPIXEL * 8;
game_map_player_start_y = y * TILE_SZ_MICROPIXEL + PIXEL_SZ_MICROPIXEL * 16;
}
2024-02-29 00:10:09 +00:00
void map_game_map_collectible_cake_create(sys_i32 x, sys_i32 y) {
game_collectible_create(
(x + 2) * TILE_SZ_MICROPIXEL,
(y + 2) * TILE_SZ_MICROPIXEL,
GAME_COLLECTIBLE_TYPE_CAKE
);
}
void map_game_map_collectible_money_big_create(sys_i32 x, sys_i32 y) {
game_collectible_create(
(x + 1) * TILE_SZ_MICROPIXEL,
(y + 1) * TILE_SZ_MICROPIXEL,
GAME_COLLECTIBLE_TYPE_MONEY_BIG
);
}
void map_game_map_collectible_money_small_create(sys_i32 x, sys_i32 y) {
game_collectible_create(
(x + 1) * TILE_SZ_MICROPIXEL,
(y + 1) * TILE_SZ_MICROPIXEL,
GAME_COLLECTIBLE_TYPE_MONEY_SMALL
);
2024-02-29 03:05:52 +00:00
}
2024-02-29 03:42:03 +00:00
game_npc* game_map_npc_in_progress = NULL;
2024-02-29 03:05:52 +00:00
void map_game_map_npc_create(sys_i32 x, sys_i32 y) {
2024-02-29 03:42:03 +00:00
// center NPC
game_map_npc_in_progress = game_npc_create(
(x + 1) * TILE_SZ_MICROPIXEL,
(y + 1) * TILE_SZ_MICROPIXEL
);
2024-02-29 03:05:52 +00:00
}
void map_game_map_npc_set_sprite_id(sys_i32 id) {
2024-02-29 03:42:03 +00:00
assert(game_map_npc_in_progress && "NPC has to be in progress");
game_map_npc_in_progress->sprite_id = id;
}
void map_game_map_npc_set_palette_id(sys_i32 id) {
assert(game_map_npc_in_progress && "NPC has to be in progress");
game_map_npc_in_progress->palette_id = id;
2024-02-29 03:05:52 +00:00
}
void map_game_map_npc_set_inflict_id(sys_i32 id) {
2024-02-29 03:42:03 +00:00
assert(game_map_npc_in_progress && "NPC has to be in progress");
game_map_npc_in_progress->inflict_id = id;
2024-02-29 03:05:52 +00:00
}
2024-02-29 03:42:03 +00:00
void map_game_map_npc_set_face_left(bool face_left) {
2024-02-29 03:49:49 +00:00
assert(game_map_npc_in_progress && "NPC has to be in progress");
2024-02-29 03:42:03 +00:00
game_map_npc_in_progress->face_left = face_left;
2024-02-29 03:05:52 +00:00
}
2024-02-29 21:20:18 +00:00
void map_game_map_npc_set_flip(bool flip) {
assert(game_map_npc_in_progress && "NPC has to be in progress");
game_map_npc_in_progress->flip = flip;
}
2024-02-29 03:42:03 +00:00
void map_game_map_npc_set_no_cake_dialogue(const char* dialogue) {
assert(game_map_npc_in_progress && "NPC has to be in progress");
game_map_npc_in_progress->no_cake_dialogue = dialogue;
2024-02-29 03:05:52 +00:00
}
void map_game_map_npc_add_dialogue(const char* dialogue) {
2024-02-29 03:42:03 +00:00
assert(game_map_npc_in_progress && "NPC has to be in progress");
assert(game_map_npc_in_progress->n_dialogues < GAME_NPC_MAX_N_DIALOGUES &&
"NPC can't have too many dialogues");
sys_i32 ix = game_map_npc_in_progress->n_dialogues++;
game_map_npc_in_progress->dialogues[ix] = dialogue;
2024-02-29 00:10:09 +00:00
}