M
Midastouch
Guest
Hello everyone i have a little question.
I did a little project to store the coordinates of a pixel when i click on it.
I store these coordinates in an array : array[value]= [1 is an filled array / 0 is an empty array, x stored here, y stored here]
The thing is i randomly delete some array in the time.
As you can see below, both codes are similar, i just changed the do until :
- In the first case my array_size stay at 0, it doesn't works
-In the second case my array_size works perfectly
And i don't understand why. It seems that if i change the value of a variable in a do until the value of this variable stay the same?
I did a little project to store the coordinates of a pixel when i click on it.
I store these coordinates in an array : array[value]= [1 is an filled array / 0 is an empty array, x stored here, y stored here]
The thing is i randomly delete some array in the time.
As you can see below, both codes are similar, i just changed the do until :
- In the first case my array_size stay at 0, it doesn't works
-In the second case my array_size works perfectly
And i don't understand why. It seems that if i change the value of a variable in a do until the value of this variable stay the same?
GML:
if mouse_check_button_pressed(mb_left) {
//Find the first empty slot
var value = 0;
if array[value][0] = 1 {
do {
value +=1}
until array[value][0] = 0;
}
//Fill an array with the first empty slot
array[value] = [1, xxx, yyy];
//cell[xxx][yyy].type_ = types_.fire;
//cell[xxx][yyy].updated = update;
//Look for the size of the array
if array[array_size][0] = 0 {
do {
array_size -=1;
}
until array[array_size][0] = 1;
}
}
Code:
//Value in grid
xxx = mouse_x div cellsize;
yyy = mouse_y div cellsize;
if mouse_check_button_pressed(mb_left) {
//Find the first empty slot
var value = 0;
if array[value][0] = 1 {
do {
value +=1}
until array[value][0] = 0;
}
//Fill an array with the first empty slot
array[value] = [1, xxx, yyy];
//cell[xxx][yyy].type_ = types_.fire;
//cell[xxx][yyy].updated = update;
//Look for the size of the array
var variable_to_find_size = array_size;
if array[variable_to_find_size][0] = 0 {
do {
variable_to_find_size -=1;
}
until array[variable_to_find_size][0] = 1;
}
array_size = variable_to_find_size + 1;
}