I'm trying to make a game where instead of having an actor respond to key presses to move, the actor moves based on what the player types into the game. The player would be able to jump between 5 spots on the map, lets say these spots are 50 units apart.
So basically I want the player to be able to type in something like "move left;" to get the actor to move left 50 units left, and if the player types "move right" the player would move to the right 50 units right. Also there would be a text box on the bottom of the game that shows what the player most recently typed as well as what the code for that action looks like within the game. I'm not sure exactly how to get this to work but I imagine the code would look something like this:
int dx = 0, dy = 0;
if (the player types "move left" \
and the player hits enter) \
{ \
dx--; \
game deletes any text that may be in the textbox \
game ads "move left" the textbox <repeat for all directions
game ads "dx--" to the textbox underneath "move left" /
} /
if(the player's position is -100 /
and the player types "move left") /
{ /
game ads "move left to the textbox"
game ads "cannot move any farther left" to the textbox, underneath "move left"
}
if (dx == 0 && dy == 0) return;
setLocation(getX()+dx*2, getY()+dy*2
if ( the player types anything that is not "move left") \
{ \
text box shows what the player typed <repeat
underneath what was entered the textbox says "could not compute" /
} /
