I recently created a program that simply bounces a line around the screen, deflecting off the edges (much a screen saver bounces around a monitor). I wanted to give it a little more interest, so instead of having it start at (0,0) each time, it would start at a random point on the screen. Below is the code I currently have:
Code:
Now something entirely inexplicable (to me) is happening when I run this code. After one iteration of the loop, which turns on a pixel at the randomized location, say (45,70) for this example, the value of B is being store to Y, moving the whole operation up to (1,70) in one loop. I know that it is B being stored to Y because I have tried changing the value of B to -1, which obviously returns with a Domain Error when the calculator tries to graph a pixel at (-1,70).
Why on Earth is this happening?! There is absolutely nothing in the code that would allow B to store to Y without adding the initial value of Y first. I'm completely baffled by this, and it's frustrating me beyond belief. Please help me out here.
Thanks,
-- PinSeventy
Code:
:ClrDraw
:AxesOff
:randInt(1,92)→X
:randInt(1,62)→Y
:1→A
:1→B
:While 1
:Pxl-On(Y,X)
:A+X→X
:B+Y→Y
:If X≥93
:-1→A
:If X=1
:1→A
:If Y≥62
:-1→B
:If Y=1
:1→B
:End
Now something entirely inexplicable (to me) is happening when I run this code. After one iteration of the loop, which turns on a pixel at the randomized location, say (45,70) for this example, the value of B is being store to Y, moving the whole operation up to (1,70) in one loop. I know that it is B being stored to Y because I have tried changing the value of B to -1, which obviously returns with a Domain Error when the calculator tries to graph a pixel at (-1,70).
Why on Earth is this happening?! There is absolutely nothing in the code that would allow B to store to Y without adding the initial value of Y first. I'm completely baffled by this, and it's frustrating me beyond belief. Please help me out here.
Thanks,
-- PinSeventy