Computer Science Canada How to erase when you type E, and plot when you type P |
Author: | rcmp1234 [ Tue Mar 04, 2008 7:22 pm ] |
Post subject: | How to erase when you type E, and plot when you type P |
Hi, I wrote a program to output a cat's face. I would like to know how to modify it so that when you type E, it erases the face and plots it again when you type the letter P thanks! |
Author: | michaelp [ Tue Mar 04, 2008 9:21 pm ] |
Post subject: | RE:How to erase when you type E, and plot when you type P |
So, you erase the whole face, and then draw the face again when you press 'p'? Just make a function for drawing the face. Then, for when the user presses 'p', you call "cls". You can find out how to use input from the keyboard yourself. ![]() |
Author: | rcmp1234 [ Tue Mar 04, 2008 9:37 pm ] |
Post subject: | Re: How to erase when you type E, and plot when you type P |
not sure what you mean and not sure how... |
Author: | syntax_error [ Tue Mar 04, 2008 10:10 pm ] |
Post subject: | RE:How to erase when you type E, and plot when you type P |
a) the turing walk through or b)just F10.... try it sometime. |
Author: | Tony [ Tue Mar 04, 2008 10:54 pm ] | ||
Post subject: | RE:How to erase when you type E, and plot when you type P | ||
there are a number of smaller problems involved 1. drawing a blank screen -- cls for clear 2. drawing a cat's face -- you've done that part 3. reading the keyboard one character at a time
functions (you might first encounter them as procedures, which is a special type of a function), as suggested, are a way to organize code into blocks. It makes things neater, easier to understand, and you very easily use the same code in multiple places. Probably not essential at this program though, since you shouldn't be repeating any code. |
Author: | BigBear [ Wed Mar 05, 2008 9:04 am ] | ||
Post subject: | Re: How to erase when you type E, and plot when you type P | ||
This will help you with the order of things.
|
Author: | Tony [ Wed Mar 05, 2008 10:39 am ] |
Post subject: | RE:How to erase when you type E, and plot when you type P |
I think that was an unnecessary specific solution to the question. |
Author: | riveryu [ Wed Mar 05, 2008 8:58 pm ] |
Post subject: | RE:How to erase when you type E, and plot when you type P |
I thought he meant typing E or P as input not pressing E or P keys. |
Author: | syntax_error [ Thu Mar 06, 2008 9:57 pm ] |
Post subject: | RE:How to erase when you type E, and plot when you type P |
pressing makes more sense and does not disturb the image itself. |