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]); }
/*Takes input in curx/cury*/
/*Incredibely jank*/
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)
dy = dy / T_HEIGHT - 1;
else
dy = dy / T_HEIGHT;
int on_walkable = map_get_walkable(game, dx, dy);
int on_walkable = map_get_walkable(game, (dx>>PRECISION) / T_WIDTH,
(dy>>PRECISION) / T_HEIGHT);
int speed = (on_walkable >= 0 && on_walkable < WALKABLE_TILE_MAX)
? walkable_speed[on_walkable]