The thing is, it is different from tetris in the sense that all the characters that will be coming down will have to be moved to a specific position. After going to that position or to the end of the line, it will have to go back up again. My problem is maintaining that specific x position after a random generation between 0 to 79 ( my screen width should be the same as the cmd console). In my code below, I have set my x to pick a random number, but I need that number to remain constant until it goes to the y position 24. How do I do this?
Code:
int main()
{
int lives = 3;
int x1 = 0, y = 0;
char letter = 'a';
setBackground(BLUE);
while(lives > 0)
{
if( y < 24)
clrscr();
gotoxy(pickRandom(0,79), y);
printf("%c", letter);
switch(getKeypressed())
{
case KEY_LEFT: gotoxy(x--, y);
printf("%c", letter); break;
case KEY_RIGHT: gotoxy(x++, y);
printf("%c", letter); break;
delay(200);
}
}
}