Hey again everybody, I have this simple code here, and a very simple question.
When I run this code I can either choose to type l, r or f, each letter activates a sentence, like type l, the turtle goes left and so on...
But I can only type a letter once and then the code stops..
I would like to repeatedly type, l, r or f many times, as long i feel like without the code stops. I just want the code to start over and over agaib. I know its a silly question, but can someone help me.
// my stuff
// as the player of this game you have three choices, move the turtle forward and
// choose its direction - Either left or right
#include <iostream>
usingnamespace std;
int main(){
char myresponse; // I use here char because i want to write a command and not type an int
std::cout << "your turtle just woke up, what should it do?" << std::endl;
cin >> myresponse;
// Here I will use conditionals
if (myresponse == 'l')
{
// do something
std::cout << "the turtle goes left" << std::endl;
}
elseif (myresponse == 'r')
{
std::cout << "the turtle goes right" << std::endl;
// do something else
}
elseif (myresponse == 'f')
{
std::cout << "the turtle steps forward" << std::endl;
// do this instead
}
}