So I am writing a game in C++, and its a lot like Zelda . The way I am storing the maps information is through an array which contains which blocks are walkable and which are not. It rounds the players position to the nearest multiple of 32 which is the size of a tile/square.
void walk(int i, int j,char* collide)
{
int tempx,tempy;
animate = true;
//DOWN LEFT RIGHT UP
tempx=x+hspeed*i;
tempy=y+vspeed*j
float xadj,yadj;
xadj = ceil(float(tempx)/32.0);
yadj = ceil(float(tempy)/32.0);
int boundboxes [8];
if(j < 0)
{
yadj -=1;
face = UP;
}
else if(j > 0)
{
face = DOWN;
}
else if (i < 0)
{
xadj-=1;
face = LEFT;
}
else if (i > 0)
{
face = RIGHT;
}
if(collide[int(xadj+(yadj)*20)]==0)
{
x = tempx;
y = tempy;
}
}
So the problem i am having is here I cannot walk through the gap between the tree and the mountains, and there are several other false detections like being able to walk through trees if you are technically not on the tree tile. Can I have some help with this please?