GMS 2 Isometric view 1 line bug

hey i'm starting my project of making a video game, problem i want to do it in an isometric view, after searching for tutorials i decided to try and code it, i did it well, but once i ve added the coding for movements the map bugged and showed only one line of tiles since i didnt know where the problem came from i deleted the movement codes taht i just did and the problem persists, tried to debug it and the only thing i can find that may cause that is a loop that doesnt loop line 6
Code:
var tiledata, screenX, screenY, tileindex, tileZ;

for (var tX = 0; tX < Map_w; tX++)
{ for (var tY = 0; tY < Map_h; tY++)
    {
        tiledata = global.theMap[# tX, tY]
        screenX = Script2(tX, tY);
        screenY = Script3(tX, tY);
       
        tileindex = tiledata[tiles.sprite];
        tileZ = tiledata[tiles.Z];
       
        if (tileindex != 0) { draw_sprite(tile, tileindex - 1, screenX, screenY + tileZ)}
       
    }
   
}
please help T^T
 
Last edited:

Nocturne

Friendly Tyrant
Forum Staff
Admin
We are missing too much information to be able to properly help here I'm afraid... Where is Map_w/h set? What does Script2 and Script3 do? What is in "tiledata"? Also, have you added a breakpoint to the loop and then run it using the debugger? With that you can step through the code a line at a time and see exactly what values are being used and what is happening...
 
I'll answer all of taht in one message
first, map_w and map-h are set in macros in script 1
second heres the code for script 2
Code:
function Script2(argument0,argument1)
{
return ((argument0 + argument1) * (tile_w * 0.5)) + (Screen_h * 0.25);
}
for script 3
Code:
function Script3(argument0,argument1)
{
return ((argument0 + argument1) * (tile_h * 0.5)) + (Screen_h * 0.25);
}
and last tile data is defined on the code i sent, i dont quite understand all of the function of tiledata but in the idea i think its just a var to help implementing other vars like tiles.sprite and tiles.Z
with that said i think it ll be more clear

Also while running the debugger i noticed that the line 3 of the first code i sent didnt loop at all so tX never increase might as well be the only problem
 

Nidoking

Member
Code:
function Script2(argument0,argument1)
{
return ((argument0 + argument1) * (tile_w * 0.5)) + (Screen_h * 0.25);
}
This function uses Screen_h but appears to be returning a width. Is that right? Should it be Screen_w?

Code:
function Script3(argument0,argument1)
{
return ((argument0 + argument1) * (tile_h * 0.5)) + (Screen_h * 0.25);
}
This one uses height for both the tile and the screen.

EDIT: On second thought, that probably just is how the isometric perspective works.

Also while running the debugger i noticed that the line 3 of the first code i sent didnt loop at all so tX never increase might as well be the only problem
first, map_w and map-h are set in macros in script 1
What is the actual VALUE of Map_w? You say it's a macro, but it's got to have a value.
 
What is the actual VALUE of Map_w? You say it's a macro, but it's got to have a value.
Code:
#macro Map_w 12
#macro Map_h 12
#macro tile_w 109
#macro tile_h 40
#macro Screen_w 2050
#macro Screen_h 1050

enum tiles
{ 
    sprite = 0,
    Z = 1
}
heres all the macros
 

Nidoking

Member
Then that first loop should indeed run twelve times. How did you determine that it only runs once? And what is the value of tX at that time?
 

woods

Member
like @Nidoking said in post #4

Code:
       function Script2(argument0,argument1)
{
return ((argument0 + argument1) * (tile_w * 0.5)) + (Screen_h * 0.25);
}
Screen_w ??
 
PROBLEM SOLVED
I actually made some mistakes
in fact there was the screen w problem but it wasnt the main problem actually i wrote
Code:
function Script2(argument0,argument1)
{
return ((argument0 + argument1) * (tile_w * 0.5)) + (Screen_w * 0.5);
}
instead of :
Code:
function Script2(argument0,argument1)
{
return ((argument0 - argument1) * (tile_w * 0.5)) + (Screen_w * 0.5);
}
Had to check the tutorial at least 20 times to see the mistake
 
Top