Christopher Alexander
Member
So I'm making this falling block game but I've hit a snafu. Basically, after blocks have matched with neighbours and been destroyed I can't get the blocks above to fall down into their new spots like I want them to.
The "cube_list_pop" script populates a list with all the instances of blocks on the playing field and puts them into "global.cube_list".
The "check_empty_vert" script checks how many empty squares there are below the current square within the playing field and returns that number.
Alarm[5] only contains "y = y+50"
When using this code I get "hanging" blocks in the air. I'm guessing that having an alarm in a for loop doesn't work as I intended. It seems as if the alarm is only called once, the block hangs in the air after falling one square down.
If I instead use this code...
...all of the blocks end up in the right places but they do it instantly. Using alarms I want to get that old school effect of the blocks moving one square at a time using "global.drop_speed" as how fast they drop from one square to another.
Any tips or solutions?
The "cube_list_pop" script populates a list with all the instances of blocks on the playing field and puts them into "global.cube_list".
The "check_empty_vert" script checks how many empty squares there are below the current square within the playing field and returns that number.
Alarm[5] only contains "y = y+50"
Code:
script_execute(cube_list_pop);
for (i = 0; i < ds_list_size(global.cube_list); i += 1)
{
inst = global.cube_list[| i];
with (inst)
{
dropAmount = script_execute(check_empty_vert);
for (ii = 0; ii < dropAmount; ii +=1)
{
alarm[5] = global.drop_speed;
}
}
}
If I instead use this code...
Code:
script_execute(cube_list_pop);
for (i = 0; i < ds_list_size(global.cube_list); i += 1)
{
inst = global.cube_list[| i];
with (inst)
{
dropAmount = script_execute(check_empty_vert);
if (dropAmount > 0)
{
y = y + (50*dropAmount)
}
}
}
Any tips or solutions?