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:
scrIsoGridInit:
scrIsoGridDraw
Thanks for any help
Here are the 3 scripts that the tutorial uses to handle the iso grid
scrIsoGridDimensions:
Code:
gridWidth = 15;
gridHeight = 15;
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;
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);
}
}