I am working on creating a simple sketch pad, which will be a console program. I got the idea from "C++ How to Program" from Deitel & Deitel. If any of you know of Turtle Graphics, then you'll know what I'm talking about. If not, then here's what I'm having problems with.
The "pad" is going to be a 15x60 array that will start off with all elements initialized to a blank (i.e. space character). The user can press 'w' to move their "pen" up, 's' for down, 'a' for left, and 'd' for right. If they press the spacebar, this sets the point of the pen "down", and wherever they move the pen on the pad (array), their chosen sketch character (say, for example, an asterix) will be plotted. This will happen until they press the spacebar again to "raise" the pen. When the pen is raised, they can move about freely without drawing anything.
Here's my problem: I'm trying to develop an alg. and write pseudocode to accomplish the above. However, I'm having trouble figuring out how to keep track of where the pen is. The pen will be a visible character on the pad array (I have it set to '+' right now), so if they pen passes over a character and the pen is not DOWN (i.e. not drawing, just moving the pen around), the pen must replace the character in the position its on TEMPORARILY so that when the user moves the pen again, that character will still be in its original location (because the pen point is not down, there's no drawing.) Does anyone have any suggestions, preferably a snippet of code? I'd really appreciate it.
There are other things to check for of course (i.e. if the user moves right, will the array bounds be exceeded; I can do this on my own). The only thing I really need help w/is what I mentioned above. Any comments or suggestions are welcome as well. This is my most ambitious project, and I am really excited about it. Thanks for all of your help!