So I'm writing a Tetris game, mostly for practice, and I have come to a wall. Let me start by saying I'm not using any frameworks, I'm doing this all in C# using Visual Studio and I know I'm probably not doing this the best way however i am determined to get this finished before I start doing more research and using a framework.
So my Form has a panel in it that I have put a picture box for every possible Tetris block. They all start with the visibility flag set to false, and I have two arrays I have created, one that is for the gameMap and the other is for the current tile in play, as follows
int[,] gameMap = new int[,] {
{ 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 } }
int[,] currentTile = new int [,] {
{ 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} }
This has been slightly simplified, but you get the idea. I have an array index for every picture box and I have a timer running that is constantly checking the gameMap and currentTile arrays to see if any of the positions are set to 1 and if they are then I set the tile that maps to this index to visible = true;
The problem I am having is dropping the tiles. I have set up another timer to run in the background and drop the till in the current tile array, and this is where I am having an issue. I had written a line of code that is a for loop inside of a for loop looking for an index set to 1 and it sets this to 0 and sets the index below it to 1(ie if its currentTile [0,5], it sets this to 0 and sets currentTile[1,5] to 1). I quickly figured out that this runs through the whole loop and ends up sending the tile to the bottom of the board at the end of the for loop.
I had tried a few more ideas to get it to drop the 1's in the array down 1 level, but nothing I have tried has worked. Does anyone have any ideas, or will it just not work this way? I don't want to try this any other way at the moment until I get a little more comfortable with the ins and outs of classes. Any help would be appreciated!