• Hey! Guest! The 39th GMC Jam will take place between November 26th, 12:00 UTC and November 30th, 12:00 UTC. Why not join in! Click here to find out more!

DS-Grid translation to screen

TonyR

Member
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.
 

TonyR

Member
@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