   Problem with tetris style game.
  Hello. I've spent the last few weeks learning the basics of XNA and C#. I've built a couple small games (Pong, Breakout) and I decided that Tetris would be a good next step. I'm however running into some issues with how exactly to design and implement certain parts of the game. My problems are more with the theory, then with the code itself. Specifically the main problem I'm having is with how to handle game pieces. My first thought was to have three main classes: a GameBoard class, a Block Class, and a GamePiece class. The GameBoard class would have an array (10,20) that would store the location of blocks that have been locked in place. Next the GamePiece class would keep track of the current piece the player can move, and inside the class I planned to store all the possible piece combinations and randomly select one after the previous piece was "locked" in place. To do this I was going to use a [4, 4] array of blocks to represent the current active piece. This is where I hit a wall. If I use a separate [4,4] array to store the location of the current pieces blocks ... how exactly would I go about making sure this array knows the information it needs from the GameBoard array? I can get to the point where I move the piece around and all, but my problem is making the piece (and its array) communicate with the GameBoard so it knows when its hit a location it is unable to move from, and then let the GameBoard know what location this piece ended at so it can update its array. I assume the solution is probably pretty simple, but perhaps since I haven't been programming that long its difficult for me to see it. I know I could probably find a "falling block" type tutorial out there that has a solution... but Im not all that interested in the code of how its done, but more so the theory so I can implement it myself. Any help would be most appreciated.   
  In a static context like this one (where the board... or "level" if you will doesn't change), you can simply make a function in the GameBoard that will transpose the block pieces into board coordinates and check if the squares are occupied. You can pass the board to the piece in the constructor and save it to use it later. You can use a 4x4 array plus a point and then just offset each element. It may be more efficient to store position per array element, I'm not sure what exactly is the best solution, but for a simple game like this, it's more important to get it working rather than to make it efficient.   ;  So what your saying is, create a function in the board class that takes in screen coordinates from the blocks in a "Piece Array", and then returns the array coordinates at which they would be located on the gameBoard array?  ;  I assume what you're trying to do is check if the active piece is about to take an occupied position (collide with other blocks). Since the GameBoard stores information about currently existing pieces (ones that locked in place), it would make sense to send the current piece to the board, translate it's coordinates to that of the board, and check if it collided with anything. It doesn't make sense to return the translated coordinates because you still have nothing to check them against. Here's some pseudo code, hope it makes sense.class Piece {public Point mBoardPosition; // Position on the boardpublic ArrayOfPieces[4][4]; // the block}class Board {private BoardArray[10][20];public boolean pieceCollided(Piece activePiece) {for(each piece) { // you will need 2 for loops to check each dimension of the activePiece arrayif(activePiece[j] == <occupied> && BoardArray[activePiece.mBoardPosition.x + i][activePiece.mBoardPosition.y + j] == <occupied>) { // substitute <occupied> with you know what ;]return true;}}return false;}}