forked from kdx/jtmm2-old
22 lines
536 B
C
22 lines
536 B
C
#include <gint/defs/types.h>
|
|
|
|
#include "collide.h"
|
|
#include "conf.h"
|
|
#include "level.h"
|
|
|
|
uint8_t collide_point(Vec point, const Level *level, uint layer_id)
|
|
{
|
|
Vec cursor; /* the final position to test */
|
|
vec_cpy(&cursor, point);
|
|
vec_div(&cursor, VEC_PRECISION * TILE_SIZE); /* get the expected tile ID */
|
|
if (point.x < 0 || point.y < 0 ||
|
|
cursor.x >= level->width || cursor.y >= level->height)
|
|
{
|
|
return -1; /* the point is out of bounds */
|
|
}
|
|
else
|
|
{
|
|
return level->layers[layer_id][cursor.x + cursor.y * level->width];
|
|
}
|
|
}
|