I recently thought about a way of optimizing collisions with static elements (walls, for exemple) but I'm not sure if the benefit would be that great, if other, better ways already exist or if GameMaker is already optimized for collision checks.
My idea is to implement a collision grid.
DESCRIPTION
* Let's say I create a 1000x1000 room and use 32x32 static walls to create the level.
* Upon execution, a 1000x1000 array is created and every walls register their collision bounding box in the array.
** Example: A 2x2 wall placed at (0,0) would flag as true the following adresses: [0,0], [0,1], [1,0] and [1,1].
* After registering itself, the wall is destroyed.
* Instead of using built-in collision checking for walls, I directly check the concerned adresses in the array.
** Example: I need to know if a wall-collision exist a position (2,4). I'll check if address [2,4] in the array.
QUESTIONS
1. Is array checking fast in GM?
2. Is this method better than iterating through every instances of Wall objects?
3. Is this method better than creating a single, large wall object?
4. Is collision_checking in GM already so optimized that I don't need to implement such a system?
5. Do you know other, better ways of optimizing collision checking?
6. Navigation grids already exit in GM, although it exists for path-finding, can I use this framework for collision checking?
6. Ultimately, do you think it is a good idea?
PS: Sorry if my discourse is convoluted, English isn't my primary language