KayleMaster
Member
GM Version: GM:S
Target Platform: ALL
Download: Link
Links: click
However here, we're going to be looking at 2:1 (width:height) type isometric, which is not true isometric, but it's easier to work with and the end user won't notice a difference.
This means that you don't have to write new code for pathfinding, collision detecting an all other sorts of things.
We will be using grids (or arrays) to store the information we need.
The chunk size is the width and lenght of the terrain, 64 would equal to 4096 tiles.
Screen position is the absolute position in the room.
These grid positions will be used for the ds_grid.
This is the offset at which the terrain will draw the tile at 0,0 grid position. You can change this to however you want, I just made it so it centers the terrain at the view.
It's also important to set tile_width and tile_height as constants !
My tile width is 128 and the height is 64.
Now we need to make the scripts IsoToScreenX,IsoToScreenY,ScreenToIsoX and ScreenToIsoY.
These are the calculations from absolute coordinates to isometric and back.
IsoToScreenX
IsoToScreenY
ScreenToIsoX
ScreenToIsoY
And this is the result I got (except the obvious paint I did on it):
What thing do you want to learn how to do next?
Target Platform: ALL
Download: Link
Links: click
- What is an isometric view?
However here, we're going to be looking at 2:1 (width:height) type isometric, which is not true isometric, but it's easier to work with and the end user won't notice a difference.
- How it works?
This means that you don't have to write new code for pathfinding, collision detecting an all other sorts of things.
We will be using grids (or arrays) to store the information we need.
- Create event
Code:
//Chunk size
chunk_size = 8;
Code:
//Screen position
globalX = 0;
globalY = 0;
Code:
//Grid positions
LocalX = 0;
LocalY = 0;
Code:
//Chunk start position
global.isoX = tile_width*4-tile_width/2;
global.isoY = tile_height*4;
It's also important to set tile_width and tile_height as constants !
My tile width is 128 and the height is 64.
Code:
//Grid initialize
chunk = ds_grid_create(chunk_size,chunk_size);
//Chunk generation
//tile_width and tile_height are defined as macros
//Creates tiles for each position of the grid
for (var o=0; o<chunk_size; o++){
for (var i=0; i<chunk_size; i++) {
chunk[# i,o] = tile_add(grass_flat,0,0,tile_width,tile_height,IsoToScreenX(i,o),IsoToScreenY(i,o) ,1);
}
}
These are the calculations from absolute coordinates to isometric and back.
IsoToScreenX
Code:
///IsoToScreenX(LocalX,LocalY)
//Transform grid x coordinate to absolute screen x coordinate
return global.isoX + ((argument0 - argument1) * tile_width/2);
Code:
///IsoToScreenY(LocalX,LocalY)
//Transform grid y coordinate to absolute screen y coordinate
return global.isoY + ((argument0 + argument1) * tile_height/2);
Code:
////ScreenToIsoX(x,y)
//Transforms absolute x coordinate to grid x coordinate
return (((argument0 - global.isoX) / (tile_width/2)) + ((argument1 - global.isoY) / (tile_height/2))) / 2;
Code:
///ScreenToIsoY(x,y)
//Transforms absolute y coordinate to grid y coordinate
return (((argument1 - global.isoY) / (tile_height/2)) - ((argument0 - global.isoX) / (tile_width/2))) / 2;
What thing do you want to learn how to do next?
- Isometric RTS (age of empires)
- Isometric RPG (diablo like)
- Isometric Shooter
- Else.
Last edited: