Computer Science Canada Is there a way to repeatedly draw a pic using 1 or 2 lines? |
Author: | KONjbnj [ Thu May 26, 2005 11:01 am ] | ||
Post subject: | Is there a way to repeatedly draw a pic using 1 or 2 lines? | ||
I want to have this
But I would need to do that many other times. I realize that it would take a lot of lines to do, and I was wondering if there waas a way to do that but in fewer lines. |
Author: | Cervantes [ Thu May 26, 2005 12:17 pm ] | ||||
Post subject: | |||||
Yep, for loops. Check the tutorial section if you dont' know them. There's a link to the tutorial in the sticky at the top of the turing tutorials thread. Here's how:
Actually, after looking closer at your code I see that doesn't exactly fit the requirements. This would draw an extra two lines at y = 400. To prevent the ones at (200, 400) & (250, 400) from being drawn, you could use an if statement.
However you do this, look for patterns in your code. Sometimes there is no pattern, sometimes there's a semi-pattern, as is the case here. Whenever there is a pattern, there is an easier way of doing it then just writing every coordinate. |