DS_Grid index out of bounds error

Blaize

Member
So I've recently decided to learn how to use DS_grids to create collision maps - figured I'd give it a go. It works exactly how I want it to work.

Awesome!

The issue is when I try to transition to another room.
This is how I'm checking the transition (In the player's outside room event for now):
Code:
if (x<0)
{
    room_goto(global.Left);
    x = room_width-(sprite_width/2);
}
if (x>room_width)
{
    room_goto(global.Right);
    x = 0 + (sprite_width/2);
}
That's the gist of it.

When the if statements fire off, I get the error 'Grid [no], index out of bounds writing [x,y] - size is [size x, size y]' e.g. Grid 1, index out of bounds writing [20, 15] - size is [20, 20].
From what I know, the player has left the grid and so, it throws this error - please correct me if I'm wrong.

I've thought about how to get around this, and so far, I've come up with:
  • Treat the transition space as a collision to transition into the next room.
  • Use the intersect boundary event - Haven't tried it yet.
How would you get around this?
 

FrostyCat

Member
After transforming the coordinates to in-grid coordinates, I'd check the bounds before peeking into the grid if I were you. If the coordinates are negative or in excess of the grid's dimensions, I'd take that as a clue that I'm past a boundary.
 
Top