So tonight I fixed some of the bugs around checking whether the squares were empty or not.
First bug was the array dimensions that hold all the squares – stupid mistake really 🙄 ! Once I’d done this, and after drawing a grid on the screen, and writing to a debug log file to check, it all seems to be going pretty well, until I tried to rotate a block on the left, and it went outside the grid, then failed the isEmpty check and stopped half way up the screen! DOH!
So I now need to fix this in the isEmpty check.
Also realised I have a memory leak. I’m still deciding what to do about it. It exists because I create a block to move around the screen, and a block consists of 4 squares. Once the block stops, I create a new one, and then redraw using the squares only.
I can’t decide if I delete the block before I create a new one, what this will do to the squares that belonged to that block. In theory they should be destructed along with it, so I think I need to just keep a growing list (linked list) of all the blocks used during a game, and then delete/destruct them at game over!
Finally, I’ve added in an offset to move the gamefield over, and I’ve also put a background in place!