having difficulty with my code , the user is suppose to input a character and then move it , up , down , ;left and right using the keys : i,j,k,l on the keyboard. however so far with my code it just moves to left no matter what key i press.
int main()
{
CursorController crs;
ColourController cl;
int Number;// the number of stairs
int Amount = 1; // this is the amount of x it will add to the line
string A;// this is the variable for the character
char movementi = 'i' ;// this is the variable to move the character
char movementk = 'k';
char movementj = 'j';
char movementl = 'l';
double xval ,yval;
xval= 2;// the set x postion coordinates
yval= 3;//the set x postion coordinates
cout << "Enter in how many 'stairs' you want" << endl;
cin >> Number;
cout << " now enter a special character to move up and down the starirs \n";
cin >> A;
for(int c = 0; c < Number; c++)
{
for(int d = 0; d < Amount; d++)
{
cout << "*";//the charater for the stair
}
cout << endl;
Amount +=1; //Adds 1 'X' after every new line
}
while( movementi =='i')
{
yval=yval-0.5;
crs.setPosition(xval,yval);
cout << A <<"\n";
qin>>movementi;
crs.clearAll();
cout<< " to move the special character press the following keys \n";
cout<< " press i for up \n k for down \n j for left and l for right \n";// intructions for the keys
}
while( movementk == 'k')
{
yval=yval+0.5;
crs.setPosition(xval,yval);
cout << A <<"\n";
qin>>movementk;
crs.clearAll();
cout<< " to move the special character press the following keys \n";
cout<< " press i for up \n k for down \n j for left and l for right \n";// intructions for the keys
}
while( movementj == 'j')
{
xval=xval-0.5;
crs.setPosition(xval,yval);
cout << A <<"\n";
qin>>movementj;
crs.clearAll();
cout<< " to move the special character press the following keys \n";
cout<< " press i for up \n k for down \n j for left and l for right \n";// intructions for the keys
}
while( movementl != 'l')
{
xval=xval+0.5;
crs.setPosition(xval,yval);
cout << A <<"\n";
qin>>movementl;
crs.clearAll();
cout<< " to move the special character press the following keys \n";
cout<< " press i for up \n k for down \n j for left and l for right \n";// intructions for the keys
}
You're not putting a decision making process in there, so it's just looping through the first while loop and never getting to the second one, because movementi will never not equal i.