Computer Science Canada Using loops to get all possible x,y co-ordinates of a value |
Author: | tristanbryce7 [ Tue Dec 04, 2012 10:46 pm ] | ||
Post subject: | Using loops to get all possible x,y co-ordinates of a value | ||
Hey, I wanted to know if there was any way to use loops, to get all the possible x,y co-ordinates in an output window? so far all I can manage to figure out is, how to get all values for (1,y), where y is all the y values of the co-ordinate up to the max y co-ordinate, but thats only when x = 1, how would I change my code to get it to get all the possible co-ordinates in my program. How would I use the loop statement to acheive this?
|
Author: | Insectoid [ Tue Dec 04, 2012 11:04 pm ] |
Post subject: | RE:Using loops to get all possible x,y co-ordinates of a value |
You might try putting a loop inside a loop. |
Author: | tristanbryce7 [ Tue Dec 04, 2012 11:39 pm ] | ||
Post subject: | Re: Using loops to get all possible x,y co-ordinates of a value | ||
It took the longest time ever to run ![]() ![]() |
Author: | Tony [ Wed Dec 05, 2012 12:02 am ] |
Post subject: | RE:Using loops to get all possible x,y co-ordinates of a value |
Draw.Line For example, instead of saying Quote: draw black dot draw black dot draw black dot draw black dot draw black dot it can be shortened to Quote: draw black line, length 5 Welcome to the exciting ideas of http://en.wikipedia.org/wiki/Image_compression |
Author: | Zren [ Wed Dec 05, 2012 12:24 pm ] | ||||
Post subject: | RE:Using loops to get all possible x,y co-ordinates of a value | ||||
You do realize that when the window's width/height is 600, maxx and maxy are equal to 599 right? Which is the last coordinate on screen (599, 599) in your case. The screen coordinates start from (0, 0) and go to (window.width - 1, window.height - 1). This beings up the matter of your for loops. Which cover the range of:
And on the final iteration, xLoop will be 599 and x will be 600, which is offscreen.
You want to cover the range from 0 .. maxx. Which brings up the question as to why you're not using the for loops counter variable (xloop and yloop), and instead creating another counter (x and y). |
Author: | tristanbryce7 [ Wed Dec 05, 2012 6:11 pm ] |
Post subject: | Re: Using loops to get all possible x,y co-ordinates of a value |
Ahh, I see, That is true, the thougt never ocurred in my mind to use x/y loop, im so used to counters that I guess I forgot :[, and the program ran perfectly fine regardless ![]() |