TheouAegis
Member
Code:
var i=0;
var row = y-2 + LINEINDEX;
if median(row,0,size.FIELDHEIGHT-1)==row {
var cell = row * size.FIELDWIDTH;
while i<size.FIELDWIDTH {
if !FIELD[i + cell] {
LINES[LINEINDEX] = 0;
break;
}
i++;
}
}
if i == size.FIELDWIDTH {
audio_play_sound(5,2,0);
LINECOUNT++;
LINES[LINEINDEX] = row;
}
LINEINDEX++;
if LINEINDEX < 4
return 0;
Now, I have a hunch the reason row 18 is getting cleared is because of the next state, which handles the dropping of all the rows down to fill the deleted rows. Maybe -- just possibly maybe -- the row in LINES[2] gets cleared, the row above it drops down, then the row in LINES[3] gets cleared and since it's the same row, it looks like two rows got cleared when in fact it was only one row getting cleared twice. BUT... How the hell is row 19 getting added to LINES[] twice in the first place?!
Here is how the bottom 4 rows appear in the array. The array looks fine to me -- values never shift and a piece placed in the last cell sets the last index in the array as expected.
1,0,0,0,0,1,1,0,1,1,
1,0,0,0,0,1,1,0,1,1,
1,0,0,0,0,1,1,0,1,1,
1,1,1,1,1,1,1,0,1,1
{ {
1,0,0,0,0,1,1,1,1,1,
1,0,0,0,0,1,1,1,1,1,
1,0,0,0,0,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1
{ {
0,0,0,0,0,0,0,0,0,0,
1,0,0,0,0,1,1,1,1,1,
1,0,0,0,0,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1
{ {
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,1,1
This is a snapshot of the array after a piece is placed. The green numbers represent the piece just placed. In the second set, you can see that I placed a vertical I piece to clear the bottom row. In the third frame, you see that one row was cleared as expected and then I placed a horizontal piece. (Note: It seems to always be the horizontal pieces on the bottom row that cause the issue.) In the fourth frame, you can see that two rows were cleared instead of just one. When that happens, LINES[] has two indexes both showing the same row.
Does anyone have any idea why this code is wigging out seemingly so randomly?