Hi, I'm a student in Computer Science and we have a machine project due on August 20. The problem is, the professor only taught us the basics of C programming, the functions, switch statements and whatnot, and now they're giving us a project about making a game. The game is just like Tetris, only there are no blocks, instead we are matching them to trash bins. Because the overall project was too difficult to do, I thought of learning how to code falling texts first. Here is my code so far.
**mp.h is a user-defined header file that was given to us.
#include <stdio.h>
#include <windows.h>
#include <mp.h>
#include <conio.h>
void setBackground(unsigned short int color);
int pickRandom(int min, int max);
void delay(unsigned long milisec);
void playSoundBeep();
void gotoxy(int x,int y);
void setx(int x);
void sety(int y);
char getKeypressed();
void setScoreTo(int s); // sets the score to s
void changeScoreBy(int x); // increments the score by x. If x is positive the score is increased. If x is negative the score is decreased.
void showScore(); // shows the current score
int getScore(); // returns the current score
void clrscr(void);
int getx(void);
int gety(void);
int getObject(int *x)
{
*x = pickRandom(0, 79);
return(*x);
}
int main()
{
int live = 3;
int x1 = 0, y = 0;
int x = pickRandom(0, 79);
setBackground(BLUE);
do{
clrscr();
gotoxy(getObject(&x), y);
printf("T");
gotoxy(&x, y++);
delay(1000);
}
while(y < 24);
getch();
}
The code I wrote enabled me to print my letter one line and clearing it before going to the next line. The only problem is, I can't get my letter to just stay in one straight line going down. I know I need to make my random X as it is but I don't know how. Any suggestions ? Thanks for all the help provided.