mirror of
https://git.planet-casio.com/Slyvtt/Collab_RPG.git
synced 2024-12-28 04:23:42 +01:00
npc : Collision des npcs "acceptable"
This commit is contained in:
parent
35e1d498f9
commit
3c6a2faf99
1 changed files with 3 additions and 11 deletions
14
src/npc.c
14
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]
|
||||
|
|
Loading…
Reference in a new issue