• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

mp_draw not drawing marked cells as red; what am I doing wrong?

W

whale_cancer

Guest
I am debugging and noticed marked solid tiles were not being displayed as solid when drawing the mp_grid (i.e. all cells are green). I am quite certain global.tile_collision is working as my debugging message indicate the tile_collision coordinates are indeed being marked as either 0 or 1 depending on what mode my brush is in.

Thus, I think it is something here, in my draw code. I know this is inefficient, but this is just for debugging and my actual mp_grids when in-game will be handled elsewhere.

Anybody know why this is happening?

Code:
///Draw Collision
if (global.brush_mode == 'Mark Solid') || (global.brush_mode == 'Mark Free')
{
    t_mpG = mp_grid_create(0, 0, global.mapWidth * 16, global.mapHeight * 15, 16, 16);
   
    for (h = 0; h < global.mapHeight * 15; h += 1)
    {
        for (w = 0; w < global.mapWidth * 16; w += 1)
        {
            if ds_grid_get(global.tile_collision, w, h)
            {
                mp_grid_add_cell(t_mpG, global.mapWidth * 16, global.mapHeight * 15);
            }
        }
    }
    draw_set_alpha(0.25)
    mp_grid_draw(t_mpG);
    draw_set_alpha(1);
    mp_grid_destroy(t_mpG);
}
 
W

whale_cancer

Guest
Should those multiplies be divides?
No. Map size represents chunks of cells. The multiplication is to turn those chunks into an appropriate number of individual cells. This works everywhere else I use it.
 
S

SyntaxError

Guest
Ahh, I think
mp_grid_add_cell(t_mpG, global.mapWidth * 16, global.mapHeight * 15);
should be..
mp_grid_add_cell(t_mpG, w * 16, h * 15);
You're adding the same cell with each iteration of the for loops.
 
W

whale_cancer

Guest
Ahh, I think
mp_grid_add_cell(t_mpG, global.mapWidth * 16, global.mapHeight * 15);
should be..
mp_grid_add_cell(t_mpG, w * 16, h * 15);
You're adding the same cell with each iteration of the for loops.
Brilliant! Thank you! I guess I was just not in the right mental state at the time.
 
Top