S
Storm1208
Guest
Hey! This is my first post on the forum so I'll try to be as clear as possible!
I'm creating a digital version of the board game "battleship" for a coding class at my high school; however, I've run into some issues trying to get my grid to detect when an object is within a specific square. I tried to create a ds_grid array system for a 10x10 grid and initialize all of its values to 0 as seen below:
I then created the 10x10 grid visually in a "draw" event (each square is 64x64 pixels). Now that I have both a visual representation of the grid and an array, I can't figure out how to program my code to detect when an instance placed within a specific square of the visual grid will change the correlating ds_grid value to "1". I tried looking at other posts but couldn't find anything. I appreciate any help anyone can give me!
I'm creating a digital version of the board game "battleship" for a coding class at my high school; however, I've run into some issues trying to get my grid to detect when an object is within a specific square. I tried to create a ds_grid array system for a 10x10 grid and initialize all of its values to 0 as seen below:
Code:
var i = 9;
var j = 9;
grid = ds_grid_create(i,j);
repeat(81)
{
grid[i, j] = 0;
j--;
if(j == 0 && i != 0)
{
j = 9;
i--;
}
}