• 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!

DS-Grid translation to screen

T

TonyR

Guest
All,

trying my hand at procedural generation of some terrain for a game I'm working on. I am filling a ds_grid with the code number for solid earth and then running another routine to carve out caverns and tunnels. The routine that does the carving "overlays" a 5 x 5 cavern "array" of terrain codes onto the ds_grid. The trouble is, when I do this pseudocode:

for y loop
for x loop //painting rows first
get ds_grid (x, y)
create instance of dirt at x*tile size , y* tile size
end x loop
end y loop

The shape of the cavern is backwards.

Is 0,0 of the screen in the upper left corner?

Or is there something up with my code?

Thanks for the help.

Tony
 
X

xleonhart

Guest
Yes, its left to right, up to down.
Try to write the current x/y to the screen instead of create the instances.
Probably the problem is in your grid.
 

NazGhuL

NazTaiL
if you write:
create instance of dirt at x*tile size , y* tile size
that will create the instance at x/y of the instance running the code.

You should do:
Code:
var xx, yy;

for(yy=0; yy<grid_height; yy++)
{
     for(xx=0; xx<grid_width; xx++)
     {
     instance_create(xx*tile_size, yy*tile_size, obj_dirt);
     }
}
 
@NazGhuL, pretty sure he knows that. As he stated, that was pseudo code.

@TonyR, can you show us the code where you are carving out the caverns? There's nothing logically wrong with the pseudo code you showed us.
 
T

TonyR

Guest
@NazGhuL, pretty sure he knows that. As he stated, that was pseudo code.

@TonyR, can you show us the code where you are carving out the caverns? There's nothing logically wrong with the pseudo code you showed us.
Sorry It's taken so long to get back. solved my issue. It was a bit of programming error on my part. I've got the ds_grid to screen code working fine.

Thanks for the help.

Tony
 
Top