A
Audun Paudun
Guest
Hello!
I'm making a grid based game kind of like tetris only without the gravity. The player places tiles onto the grid and gets points when rows/columns are full of tiles. When a row(s) is full the game populates a list with the ID's , coordinates and colors of the tiles in said row(s). The game then calculates the score based on how many adjacent tiles there are of the same color.
Here is the start of the code:
The entries in the list look like this; 302100004, where the first number is the color of the tile, the next two are the coordinates and the rest is the tile's ID.
The first if-statement checks if list_checked is empty, and if so, adds to it the first entry in list_remaining. It them deletes the entry in list_remaining. This is where it all goes wrong. the varible current_coord is set to the coordinates of entry number g. Here it seems that var current_coord is set to undefined for some reason. What could be the reason for this? It is my understanding that when I delete index 0 from a ds_list, the rest of the entries move up one space so to speak?
Does anyone know why var current_coord is set to undefined?
EDIT: The entries in list_remaining are integers not strings if that info helps.
I'm making a grid based game kind of like tetris only without the gravity. The player places tiles onto the grid and gets points when rows/columns are full of tiles. When a row(s) is full the game populates a list with the ID's , coordinates and colors of the tiles in said row(s). The game then calculates the score based on how many adjacent tiles there are of the same color.
Here is the start of the code:
Code:
if (!ds_list_empty(global.list_remaining)){
remaining_size = ds_list_size(global.list_remaining);
for(g=0; g<remaining_size; g++){
if(ds_list_empty(global.list_checked)){
ds_list_add(global.list_checked, ds_list_find_value(global.list_remaining, 0));
ds_list_add(global.list_colors_checked,string_char_at(string(ds_list_find_value(global.list_remaining,0)), 1));
ds_list_add(global.list_coords_checked,string_char_at(string(ds_list_find_value(global.list_remaining,0)), 2) + string_char_at(string(ds_list_find_value(global.list_remaining,0)), 3));
ds_list_delete(global.list_remaining,0);
}
current_coord = string_char_at(string(ds_list_find_value(global.list_remaining, g)),2) + string_char_at(string(ds_list_find_value(global.list_remaining, g)),3);
check_color = string_char_at(string(ds_list_find_value(global.list_remaining, g)), 1);
check_over = string_char_at(current_coord,1) + string(real(string_char_at(current_coord,2))-1);
The first if-statement checks if list_checked is empty, and if so, adds to it the first entry in list_remaining. It them deletes the entry in list_remaining. This is where it all goes wrong. the varible current_coord is set to the coordinates of entry number g. Here it seems that var current_coord is set to undefined for some reason. What could be the reason for this? It is my understanding that when I delete index 0 from a ds_list, the rest of the entries move up one space so to speak?
Does anyone know why var current_coord is set to undefined?
EDIT: The entries in list_remaining are integers not strings if that info helps.
Last edited by a moderator: