PLease someone, end my torment.
I''m doing Tetris and what I along with some help have come up with is two have two arrays, one for the actual gamegrid which is set to 0 showing that it is empty or there is a space. The other array contains 1''s in the shape of a game peice.
The arrays: -
//Actual playfield array - might need changing work out size
UCHAR blockgrid[NUM_BLOCK_ROWS][NUM_BLOCK_COLUMNS] = {
{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},
{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},
{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},
{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},
{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},
{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},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
};
//This will store the game peice
int GameBlock[NUM_BLOCK_ROWS][NUM_BLOCK_COLUMNS] = {
{1},
{1},
{1},
{1}
};
What I have next is a nightmare, I am trying to put the GameBlock array onto the block_grid array. So the 1''s represent single blocks on the block_grid.
This is what I got: -
It works in that the single blocks are drawn together to represent the game peice but it is out of position on the screen and also when I take out the last if (blockgrid[row etc. statement completely it still works? WHY??
Also if I get rid of the block.x and block.y statements in the top if statement then the block is then drawn in the correct location on the screen but only one block is drawn. I think the rest are being drawn behind it but not sure.
What I would appreciate is if someone could talk me through whats going on because I just don''t get it, what is it doing?
Also am I doing it the right way, by copying over the bits from one array to another. I am trying to do it in C rather than c++ because it''s easier in C
Any help really really appreciated it''s already taken me a month LOL
Paul