• 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!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Problems with Isometric tile drawing

dazza_bo

Member
I took the isometric game tutorial in GM 1.4 and changed the tile sprite to a sprite that has height (rather than the flat "2D" sprite used in the tutorial) so it's obviously not going to display correctly. I know I need to take into account a y axis offset for the height of the tile but I can't figure out where or how. The tile sprite is 64 x 32.



Here are the 3 scripts that the tutorial uses to handle the iso grid

scrIsoGridDimensions:
Code:
gridWidth = 15;
gridHeight = 15;
scrIsoGridInit:
Code:
// Setup the isometric grid according to how big it currently is
var gridDimensions;
gridDimensions = instance_create(0, 0, objGridDimensions);

var i, j;
for (i = 0; i < gridDimensions.gridWidth; i += 1) 
{
    for (j = 0; j < gridDimensions.gridHeight; j += 1)
    {
        // Place the sprite at this locale
        gridCell[i,j] = spr_desert1;
    }
}

// Get the template tile used for defining the size of an isometric tile
templateTile = spr_desert1;

// Work out the origin for the grid within the room
var gridHeight;
gridHeight = (sprite_get_height(templateTile) / 2) * gridDimensions.gridHeight;

xorigin = (room_width - sprite_get_width(templateTile)) / 2;
yorigin = (room_height - gridHeight - sprite_get_height(templateTile)) / 2;
scrIsoGridDraw
Code:
var gridDimensions;
gridDimensions = instance_find(objGridDimensions, 0);

var i, j;
for (i = 0; i < gridDimensions.gridWidth; i += 1) 
{
    for (j = 0; j < gridDimensions.gridHeight; j += 1)
    {
        // Determine the x/y position for the sprite
        var xx, yy;
        xx = xorigin + (((i * 0.5) - (j * 0.5)) * sprite_get_width(templateTile));
        yy = yorigin + (((j * 0.5) + (i * 0.5)) * sprite_get_height(templateTile));
       
        draw_sprite(gridCell[i, j], 0, xx, yy);
    }
}
Thanks for any help
 
Top