use C++ program to code.i provided a skeleton code to show how its supposed to be formatted.
Question:
use C++ program to code.i provided a skeleton code to show how its supposed to be formatted. I will leave thumbs if it works correctly. Thank you
command is issued. 4. Map the famous \"WASD\" keyboard control to control the rotation direction of the array. 5. Implement a key to stop the rotation. 6. Implement a key to terminate the program. 7. This time, you may have to adjust the sleeping time more carefully (possibly using the usleep() instead) to prevent staggering program reaction to keyboard inputs. Some Helpful Functions 1. _kbhit() A function from conio.h library that checks whether a keyboard key was pressed use this to check whether a new key press was recorded. 2. _getch() A function from conio.h library that returns the most recent character recorded upon the key press event. - use this to retrieve the character recorded. 3. usleep() Put th
Program Execution to Sleep, with microsecond granularity - use this call from unistd.h library to put your program to sleep for an arbitrary time. usleep (500000); //sleeps for 500000us = 500ms = = 0.55 Example Execution Refer to the executable program in the assignment. o o Deliverables (Total 70 points) The program must initialize the 6x24 array with the correct pattern and display a static image on the console screen upon startup (10 pt) The six user control commands must be properly implemented. 'w' for upward rotation (5 pt) 's' for downward rotation (5 pt) 'a' for leftward
SKELOTON CODE:
#include // getchar(), getc(), fgets(), scanf() #include // _kbhit(), _getch() #include
int main() { char cmd = 0;
//program loop while(cmd != 'x') { // this will NOT require ENTER key after the input to make it effective if(_kbhit()) //if a keyboard hit is detected... { cmd = _getch(); printf(\"%c is pressed... \", cmd); } else { printf(\".\"); usleep(5000); } }
}