GameMaker draw sprite on a ds_grid

M

Midastouch

Guest
Hello everyone,

I want to put my spr_ground on each grid with a value = 1
I tried lot of things but i failed everytime, i need some help.

I think i am near to succed with the code bellow placed in my step event :

GML:
var a, b;
a = 0;
b = 0;
repeat (ds_grid_width(grid_))//check in each lines
   {
   repeat (ds_grid_height(grid_))//check in each columns
      {
        var value = ds_grid_get(grid_, a, b);//check the value in the grid
        if value = 1 {draw_sprite(spr_ground,1,a*32,b*32)}//check if my value is 1 to draw sprite

        b += 1;
      }
   b = 0;
   a += 1;
}
 

FrostyCat

Redemption Seeker
Drawing code needs to be in the Draw event (using in-room coordinates) or Draw GUI event (using on-screen coordinates) to show up.
 
M

Midastouch

Guest
I wna tto precise that the code works if i want to place an object :

Code:
var a, b;
a = 0;
b = 0;
repeat (ds_grid_width(grid_))//check in each lines
   {
   repeat (ds_grid_height(grid_))//check in each columns
      {
        var value = ds_grid_get(grid_, a, b);//check the value in the grid
        if value = 1 {instance_create_depth(a*32,b*32,-1,object1)}// IT WORKS WITH THIS CODE

        b += 1;
      }
   b = 0;
   a += 1;
}
 
Top