Ok, since pxl-test( returns a 0 for an empty space, and a 1 if it isn't, I need to find a way to get that implemented with as little space taken up as possible.
Here is an example of what I mean.

Code:
:while 1
:Repeat Ans
:Getkey
:End:Ans->K
:X=(K=26)(pxl-test(A,B))-(K=24)(pxl-test(A,B))->X //will always return a 0 if the pxl is empty, so that wont work

I also tried making it seperate, but it took up about 9 lines to get the A,B coordinates to change based on the direction.

Code:
:while 1
:Repeat Ans
:Getkey
:End:Ans->K
::if K=24
:5->A
...... and so on, then  replace the pxl-test from above with A.

Code:
:while 1
:Repeat Ans
:Getkey
:End:Ans->K
:X=(K=26)(pxl-test(A,B+1))-(K=24)(pxl-test(A,B-1))->X
If you want to find out where the next pixel is, as opposed to whether the pixel in the next column is the next pixel, check out ScanForPx:

http://dcs.cemetech.net/index.php?title=BasicLibs:ScanForPx
_player1537 wrote:

Code:
:while 1
:Repeat Ans
:Getkey
:End:Ans->K
:X=(K=26)(pxl-test(A,B+1))-(K=24)(pxl-test(A,B-1))->X


As I stated, putting pxl-test in that part of the code will result in a 0, when I need it to move, so even if 26=1 , pxl-test would return 0 on the empty spots that I want to be moved.....
So then negate it by doing a -(pxl-test()-1).

Seems like a bit extra code, but I'm sure teh pplz on here can simplify/optimize that a bit more.
Ok, then I'm afraid I don't understand what you meant to do. Do you want it to only move you to one side if and only if that next pixel is blank?

If so, then I need to edit my code (completely forgot the Not() statements)

Code:
:while 1
:Repeat Ans
:Getkey
:End:Ans->K
:X=(K=26)(Not(pxl-test(A,B+1)))-(K=24)(Not(pxl-test(A,B-1)))->X
Ah yes... Not(). I'm an idiot. Although, in my defense... I just woke up.
_player1537 wrote:
Ok, then I'm afraid I don't understand what you meant to do. Do you want it to only move you to one side if and only if that next pixel is blank?

If so, then I need to edit my code (completely forgot the Not() statements)

Code:
:while 1
:Repeat Ans
:Getkey
:End:Ans->K
:X=(K=26)(Not(pxl-test(A,B+1)))-(K=24)(Not(pxl-test(A,B-1)))->X

I want it to move to that direction if the next pixel is blank. Which sadly returns a 0 if it is blank.

Can someone explain the not() function a bit more, I thought it only worked if it wasn't a certain value.
Sonlen, so then use the code he just wrote. Using Not() should make that work.
Then my code would be correct Smile

Edit: Indeed, Not() will take a value and negate it... in a way. Not(0) will return 1, and if x != 0 then Not(x) will return 0

Edit: Edit: Btw, interesting method to Not() a value swivelgames Very Happy ...Err, just realized it only works for 1 and 0 >.>
_player1537 wrote:
Then my code would be correct Smile

Edit: Indeed, Not() will take a value and negate it... in a way. Not(0) will return 1, and if x != 0 then Not(x) will return 0

Edit: Edit: Btw, interesting method to Not() a value swivelgames Very Happy ...Err, just realized it only works for 1 and 0 >.>

Thank you for explaining that more, and it works, I just need to get rid of extra bits I had before I edited this into it so that it works 100%.
Oh, and btw, you can get rid of a bunch of those parenthesis. pxl-test() doesn't need parenthesis. So it would look like:

Code:
:while 1
:Repeat Ans
:Getkey
:End:Ans->K
:X=(K=26)Not(pxl-test(A,B+1))-(K=24)Not(pxl-test(A,B-1->X
_player1537 wrote:
Then my code would be correct Smile

Edit: Indeed, Not() will take a value and negate it... in a way. Not(0) will return 1, and if x != 0 then Not(x) will return 0

Edit: Edit: Btw, interesting method to Not() a value swivelgames Very Happy ...Err, just realized it only works for 1 and 0 >.>
Err, remember that this is logical negation, not arithmetic negation. Arithmetic negation is -n->n. Logical negation is (n==0)->n in TI-BASIC.
KermMartian wrote:
_player1537 wrote:
Then my code would be correct Smile

Edit: Indeed, Not() will take a value and negate it... in a way. Not(0) will return 1, and if x != 0 then Not(x) will return 0

Edit: Edit: Btw, interesting method to Not() a value swivelgames Very Happy ...Err, just realized it only works for 1 and 0 >.>
Err, remember that this is logical negation, not arithmetic negation. Arithmetic negation is -n->n. Logical negation is (n==0)->n in TI-BASIC.

Yeah, when I read it the first time with the negation symbol, I didn't think it was correct. But then I tried it with 1 and 0, and it worked... and I forgot the rest >.< I've got it now though Razz
_player1537 wrote:
KermMartian wrote:
_player1537 wrote:
Then my code would be correct Smile

Edit: Indeed, Not() will take a value and negate it... in a way. Not(0) will return 1, and if x != 0 then Not(x) will return 0

Edit: Edit: Btw, interesting method to Not() a value swivelgames Very Happy ...Err, just realized it only works for 1 and 0 >.>
Err, remember that this is logical negation, not arithmetic negation. Arithmetic negation is -n->n. Logical negation is (n==0)->n in TI-BASIC.

Yeah, when I read it the first time with the negation symbol, I didn't think it was correct. But then I tried it with 1 and 0, and it worked... and I forgot the rest >.< I've got it now though Razz
not(1) = 0, not(0) = 1, not(100) = 0, not(9001) = 0. However, -(1) = -1, -(0) = 0, -(100) = -100, and -(9001) = -9001.
KermMartian wrote:
_player1537 wrote:
KermMartian wrote:
_player1537 wrote:
Then my code would be correct Smile

Edit: Indeed, Not() will take a value and negate it... in a way. Not(0) will return 1, and if x != 0 then Not(x) will return 0

Edit: Edit: Btw, interesting method to Not() a value swivelgames Very Happy ...Err, just realized it only works for 1 and 0 >.>
Err, remember that this is logical negation, not arithmetic negation. Arithmetic negation is -n->n. Logical negation is (n==0)->n in TI-BASIC.

Yeah, when I read it the first time with the negation symbol, I didn't think it was correct. But then I tried it with 1 and 0, and it worked... and I forgot the rest >.< I've got it now though Razz
not(1) = 0, not(0) = 1, not(100) = 0, not(9001) = 0. However, -(1) = -1, -(0) = 0, -(100) = -100, and -(9001) = -9001.


I know Razz Just got confused at first. Like I said, I get it now lol.
I know you know, I'm just clarifying for Sonlen's sake (and of course for others who read the thread). Other fun facts:

-(-(N)) = N whereas not(not(N)) can only 0 or 1. -(-(9)) = 9, -(-(0)) is 0, and -(-(-42)) = -42, but not(not(9)) = 1, not(not(0)) = 0, and not(not(-42)) = 1.
Well, in the case of not(not(, 0!= is better (where != is the not-equal sign) Very Happy
BASIC Code wrote:
:ClrHome
:ClrDraw
:DispGraph
:35→Y:40→X
:0→A:0→B
:Horizontal(‾1
:Horizontal(‾63
:Vertical 1
:Vertical 95
:Text(X,Y," O
:While 1
:Repeat Ans
:getKey
:End
:Ans→K
:Text(X,Y,"
:Y+(K=34)not(pxl-Test(X,Y-7))-(K=25)not(pxl-Test(X,Y+1→Y
:X+(K=26)not(pxl-Test(X-5,Y))-(K=24)not(pxl-Test(X+1,Y→X
:Text(X,Y," O
:End:End:End
Generated by SourceCoder, © 2005-2010 Cemetech

Anyone care to take a look at why I get a domain error every time I go all the way to the left and up, and why it won't stop me from moving it past the line on the right and bottom... >.<
1) You're getting the domain error because you're trying to read the rows or columns above the top of the screen, to the right of the right edge, below the bottom, or to the left of the left edge.

2) To solve this, draw your Horizontal at the top at -5, not -1. Draw your Vertical on the left at 7, not 1.

3) Don't use Y on the graphscreen; some TI-OS functions set it to zero
  
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 2
» 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