npc : Collision des npcs "acceptable"

This commit is contained in:
attilavs2 2024-08-11 19:45:21 +02:00
parent 35e1d498f9
commit 3c6a2faf99

View file

@ -57,19 +57,11 @@ void npc_remove(NPC *npc) {
void npc_remove_pos(uint32_t pos) { npc_remove(&npc_stack[pos]); } void npc_remove_pos(uint32_t pos) { npc_remove(&npc_stack[pos]); }
/*Takes input in curx/cury*/ /*Takes input in curx/cury*/
/*Incredibely jank*/
bool npc_collision(Game *game, NPC *npc, int32_t dx, int32_t dy) { bool npc_collision(Game *game, NPC *npc, int32_t dx, int32_t dy) {
/* Handle a negative position differently than a positive one. */
if(dx < 0)
dx = dx / T_WIDTH - 1;
else
dx = dx / T_WIDTH;
if(dy < 0) int on_walkable = map_get_walkable(game, (dx>>PRECISION) / T_WIDTH,
dy = dy / T_HEIGHT - 1; (dy>>PRECISION) / T_HEIGHT);
else
dy = dy / T_HEIGHT;
int on_walkable = map_get_walkable(game, dx, dy);
int speed = (on_walkable >= 0 && on_walkable < WALKABLE_TILE_MAX) int speed = (on_walkable >= 0 && on_walkable < WALKABLE_TILE_MAX)
? walkable_speed[on_walkable] ? walkable_speed[on_walkable]