Hello, i'm making a map with a grid system. In each of the grids, different things happen. I track the grid the player is in with the int "grid_current". The thing is, I can't figure out how to make the grid_current change according to the player's coordinates. I mean, I do, but manually. And I don't want to have to write 250 of those, I'm sure there's an easier way.
grid_width is another int which tracks the, well... grid's width

I have another one for grid_height, but right now I'm making the 1st row of grids. I'm sure I can extrapolate from the width.
My code so far is this:
if ((player.x>=grid_width*1-1)&&(player.x<=grid_width*1)){ //the player is in grid 1. his X coordinate is bigger than the left side of the grid, and smaller than the right side of the grid.
grid_current=1;
}
else if ((player.x>=grid_width*(2-1))&&(player.x<=grid_width*2)){
grid_current=2;
}
else if ((player.x>=grid_width*(3-1))&&(player.x<=grid_width*3)){
grid_current=3;
}
I call the function in room_repexec. It works, but as I said, I'm sure there's a way to make it automatic.
Thanks in advance.