i would like the user to input a character for example like *, and i want them to be able to move it by pressing i for up , k for down, j for left and l for right.
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
}
if you're talking about moving a character inside a console then so:
short description:
1.global while loop which does not end
2. iner switch statement with iner while loops
3. clearing the console for every key pressed to update the screen.
4. each inner loop inside a swithc will print the character while scree in cleard in same time
so that character in there only once but on different position.