diff --git a/src/npc.c b/src/npc.c index 00da67a..c3952dc 100644 --- a/src/npc.c +++ b/src/npc.c @@ -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]