March 2019
Intermediate to advanced
312 pages
7h 37m
English
If you have understood the previous two programs, by now, you might have figured out the code for our laptop-controlled rover. In this program, we will move the robot in forward, backward, left, and right directions using the up, down, left, and right arrow keys, as well as the A, S, X, W, and D keys. In order to recognize the inputs from the arrow keys, we will need to include the keypad() function inside our program. The Laptop_Controlled_Rover.cpp program can be download from the Chapter05 folder of the GitHub repository:
int main(){...for(;;){initscr(); keypad(stdscr,TRUE);refresh(); int keypressed = getch(); if(keypressed==KEY_UP || keypressed == 'W' || keypressed == 'w') //KEY_UP command is ...