Hey, I'm was writing a program in the graph screen and am having odd probelms with pixel coordinates. Heres the code.


Code:
:Lbl 1
:ClrDraw
:31→X
:‾1→Y
:randInt(27,51→V
:Pxl-On(57,V
:Lbl 2
:getKey
:If Ans=24
:X-1→X
:If Ans=26
:X+1→X
:Y+1→Y               
:Pxl-Change(Y,X
:pxl-Test(Y,X→T
:If T=0
:Goto 1
:Goto 2


Ok so their it is...My question is how can I set up the starting coordinate of the line. I tried to make it move up across the screen by setting the starting coordinates at the lower part of the screen and changing Y+1→Y to Y-1→Y, all it did was create a dot at my desired starting point. Then the lines started at the top still where I didn't want it and went up as I wanted but going off screen.

I know I'm probably explaining this poorly so if you have any questions please ask.
Yup, what you have described is a known bug with the TI-OS and the Y variable. Simply use a variable other than Y for your vertical coordinate.
KermMartian wrote:
Yup, what you have described is a known bug with the TI-OS and the Y variable. Simply use a variable other than Y for your vertical coordinate.
Yeah Y becomes zero whenever the graph screen is updated, if the calc is in function mode that is, different modes effect different variables.
Thanks for the help. Very Happy
ryansimbalist wrote:
Thanks for the help. Very Happy
Did this fix your problem for you?
KermMartian wrote:
ryansimbalist wrote:
Thanks for the help. Very Happy
Did this fix your problem for you?


Yes. Good Idea
Eww, Lbl and Goto commands... >.<

You should get those replaced with While statements. Lbl and Goto commands are evil Razz
Can someone beat my optimization?


Code:
:Repeat K=21
:ClrDraw
:31->X:1->Z
:Pxl-On(57,randInt(27,51
:Repeat K=21 or pxl-Test(Z,X
:getKey->K
:X-(Ans=24)+(Ans=26->X
:Z+1->Z
:Pxl-Change(Z,X
:End
:End


This assumes [2nd] is the quit key

Edit: Erm, this is Kerm. My mistake.
Ilys wrote:
Can someone beat my optimization?


Code:
:Repeat K=21
:ClrDraw
:31->X:1->Z
:Pxl-On(57,randInt(27,51
:Repeat K=21 or pxl-Test(Z,X
:getKey->K
:X-(Ans=24)+(Ans=26->X
:Z+1->Z
:Pxl-Change(Z,X
:End
:End


This assumes [2<sup>nd</sup>] is the quit key

Edit: Erm, this is Kerm. My mistake.


Did you try out that code because it doesn't work. I don't think I typed it in wrong.
Ah, I left out a not.


Code:
:Repeat K=21
:ClrDraw
:31->X:1->Z
:Pxl-On(57,randInt(27,51
:Repeat K=21 or not(pxl-Test(Z,X
:getKey->K
:X-(Ans=24)+(Ans=26->X
:Z+1->Z
:Pxl-Change(Z,X
:End
:End

Code:
:Repeat K=21
:ClrDraw
:31->X:1->Z
:Pxl-On(57,randInt(27,51
:While K!=21 or pxl-Test(Z,X
:getKey->K
:X-(Ans=24)+(Ans=26->X
:Z+1->Z
:Pxl-Change(Ans,X
:End
:End

That should work too.
Thanks for the optimization. I know that Lbl/Gotos are discouraged, I just never knew how to efficiently remove them. Thank to looking at your guy's code I think I have a better understanding.
Sage Orator wrote:

Code:
:Repeat K=21
:ClrDraw
:31->X:1->Z
:Pxl-On(57,randInt(27,51
:While K!=21 or pxl-Test(Z,X
:getKey->K
:X-(Ans=24)+(Ans=26->X
:Z+1->Z
:Pxl-Change(Ans,X
:End
:End

That should work too.
The While should have an "and", not an "or".
uh...yeah, whoops, danka
Sage Orator wrote:
uh...yeah, whoops, danka
No problem. Smile I've made that mistake enough times myself.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement