GMS 2 Advice? Collisions with ds_grid vs. objects/tiles

G

Guest

Guest
I'm working on a top-down, turn-based, grid-based game with procedurally generated levels. My next step will be coding a collision system.

I seem to have two choices for collisions:

(1) Ds_grid: When the actor wants to move in a direction, I can pull the data from the grid to figure out where the actor's going and either let the actor go there (it's a floor) or else call some other action like combat (it's a monster).

(2) Objects/tiles: I can let the actor just rip out his movement action and then check the sprite's bounding box every frame; if the box overlaps with a walle tile or monster object, I can stop movement and, if appropriate, call an action like combat. I studied Heartbeast's tile-collisions tutorial, and I could do it. This would be a very different system.

I think the ds_grid is more intuitive because my game is just a data grid with sprites sprayed on top.

Soon, though, I will add shooting and projectiles, and it would be neat if an actor could zip across the map in a single turn. I'll need to research the best way to do this with the ds_grid method; presumably, I'll just check each cell in the direction of the projectile's/actor's desired movement until I find something that's not a wall, then use my same movement code with a faster speed to push the sprite all the way to the tile immediately prior to the tile with the collision, then trigger run appropriate collision events. But it nags me that, well, this is what GameMaker's built-in collision detection system was made for.

Do wiser heads have any advice for me?
 
Well, my uninformed advice would be go with the grid. I've found that if you have a grid system already setup, it's easier to use that for collisions rather than use GM's collision system simply because of the way that GM's collision system works. Especially if you're using something like a turn-based game. Depending on how your code works, you could use some pathfinding code to check if a player can get to any square and then move them there in one turn (though, in rogue-like games, which yours sounds like it is, moving across the map makes many turns happen very quickly rather than just being a single turn).
 
Top