Closed jamespeilunli closed 3 years ago
Found the bug! I didn't replace all occurrences of piece_data
, the instance variable, with _piece_data
, the local variable, inside put_tetromino
. Diff:
Before:
def put_tetromino(_gameboard=gameboard, _pos=pos, _width=width, _height=height, _piece_data=piece_data, clear=false)
[stuff]
(0..._width).each do |i|
(0..._height).each do |j|
[stuff]
new_gameboard[_pos[0]+j, _pos[1]+i] = piece_data[j, i] # this is where the change is
[stuff]
end
After:
def put_tetromino(_gameboard=gameboard, _pos=pos, _width=width, _height=height, _piece_data=piece_data, clear=false)
[stuff]
(0..._width).each do |i|
(0..._height).each do |j|
[stuff]
new_gameboard[_pos[0]+j, _pos[1]+i] = _piece_data[j, i] # this is where the change is
[stuff]
end
I did a final test run, and another bug has occurred. When I rotate a lot, the tetromino becomes dead (ie. it floats in mid air). I will commit my changes, but keep it as a draft
Never mind, it doesn't just happen when I rotate a lot, it happens when I just press the up arrow once even.
This might be because of the actual position of the tetromino changing when the pos
variable isn't.
will close #34
Currently works-ish, but the tick right after when rotation happens is broken; only part of the tetromino is shown.