In my project, I'm supposed to print three lines of falling objects that are independent of each other and have random positions. My code goes to the second line, but the first line doesn't stay intact. It disappears and the object at the second line replaces it.
Code:#include <stdio.h> #include <mp.h> int main() { //define the variables needed int lives = 3; int x = pickRandom(0,79); int y = 1; int letter = pickRandom(1, 3); int ctr; int x2 = pickRandom(0, 79); int y2 = 1; int letter2 = pickRandom(1, 3); //sets background color setBackground(BLUE); clrscr(); while(lives != 0) //sets the continuous loop while lives is not yet 0 { //redraws trash everytime if( y < 25) { gotoxy(x, y); printf("N"); delay(500); printf("\b "); gotoxy(x, y++); ctr = 1; } else if (y > 24) { letter = pickRandom(1, 3); x = pickRandom(0,79); y = 1; } while(ctr == 1 && y == 3) { gotoxy(x2, y2); printf("B"); delay(500); printf("\b "); gotoxy(x2, y2++); } } }



LinkBack URL
About LinkBacks



"