Kerm's code has no labels.
Will_W wrote:
Kerm's code has no labels.
Qazz, I'd be happy to explain how my code works line-by-line if you find it confusing. Smile
that would be nice, thanks....


sorry if i caused trouble, i guess being at school makes me hot-headed
also, I don't see the point of the "then/end" parts of the code, but those can be ommited if it was in a while/repeat loop, or if you put an end parenthesis after the for( loop.
i should learn while and repeat now i guess
*points player off to page 1 and at mine and Kerm's code posts :p

qazz: http://tifreakware.net/tutorials/83p/b/tifw/les6.htm

Read through this first, tell us what you don't understand of that before we go further, alright?
they are pretty easy

while(condition):code:End
while checks at the beggining, ie


Code:
0-->X:while X:pause:End

will never pause because it checks at the beggining

Repeat(Condition):code:End
repeat checks at the end, and loops if the condition is not true


Code:
3-->X:Repeat X:pause:End

will pause once, because it checks at the end


Does that make sense?
qazz42 wrote:
that would be nice, thanks....[...]



Code:
:8->X:4->Y
This initializes the variables we'll be using to store the X and Y position of the 'X' character on the screen. As you know, the homescreen has 16 columns and 8 rows, so X is somewhere in [1,16] and Y is in [1,8].


Code:
:Repeat K=21
Every time we hit the End at the end of the chunk of code, loop back to here UNLESS K=21. If K=21 when we first start, this loop still runs at least once.


Code:
:Output(Y,X,"X
Display the X at a specific row and column, pretty straightforward.


Code:
:Repeat K:getKey->K:End
Keep looping inside this set of three commands until K is something other than 0; in other words, until a key is pressed.


Code:
:Output(Y,X,"[space]
Since a key was pressed, erase the X in preparation for moving it.


Code:
:X+(X<16)(K=26)-(X>1)(K=24->X
This updates the value of the X coordinate. X<16 and K=26 are both conditional tests, and return 0 when false and 1 when true. Since 0*anything = 0, both conditions must be true for (X<16)(K=26) to equal 1. Therefore, we only add 1 to X if te current column is less than the right edge, and the user pressed the right arrow key. Similarly, only subtract 1 from X if we're to the right of the left edge, and the left arrow key was pressed.


Code:
:Y-(Y>1)(K=25)+(Y<8)(K=34->Y
Same thing as X, but with vertical positions and the up and down arrow keys.


Code:
:End
Loop back to the first Repeat unless the user pressed [2nd] to quit.
tifreak8x wrote:
*points player off to page 1 and at mine and Kerm's code posts :p

qazz: http://tifreakware.net/tutorials/83p/b/tifw/les6.htm

Read through this first, tell us what you don't understand of that before we go further, alright?




Sigh.. already reading that.............. let me finish it first.
http://ourl.ca/4231

Here is some more info if you want it
_player1537 wrote:
http://ourl.ca/4231

Here is some more info if you want it
I think that's gonna confuse him more than explain anything at this point. Did that user on Omnimaga really have to explain what the ClrHome statement does? O_o
my head hurts Sad
if he didn't include how the clrhome statement worked, he would have skipped a portion of the code, and it might be somewhat confusing, idk. But it would be useful to someone who has just started ti-basic, which I think is what he was doing. either way.

Edit: Btw, that wasn't meant to be rude at all, if anyone took it that way.
hmmm....

Using the same format I was using, can anyone create a code for me that makes the X shoot ^?

Code:

:0-->C
:0-->D
:8→A
:8→B
:For(T,1,200000   \\you really should change this to "While K=/=45" or "Repeat K=45", those will quit when you press clear
:ClrHome
:Output(A,B,"X
:getKey→K
:If D=/=0
:Output(D,C,"^"
:D-1-->D
:End
:
:If (K=21) And (A=/=1)
:Then
:X-->C
:Y-->D
:End
:If K=26
:Then
:B+1→B
:End
:If K=24
:Then
:B-1→B
:End
:If K=25
:Then
:A-1→A
:End
:If K=34
:Then
:A+1→A
:If A>8
:1→A
:End
:If A<1
:Then
:8→A
:End
:End


I didn't test this, but it should work, I'll explain it if you need it. Keep in mind D is the Y of the bullet, and C is the X of the bullet.
yo anyone know why i get a domain error in this program?



Code:
:DelVar CDelVar D8→A
:8→B
:Repeat K=45
:ClrHome
:Output(A,B,"X
:getKey→K
:If not(D
:Then
:Output(D,C,"^
:D-1→D
:End
:If (K=21) and (A≠1
:Then
:B→C
:A→D
:End
:B+(K=26)1→B
:B-(K=24)1→B
:A-(K=25)1→A
:Then
:A+1→A
:If A>8
:1→8
:End
:If A<1
:8→A
:End
1) Put [code] tags around it
2) What line do you get the DOMAIN error on?

Code:
:Output(D,C,"^
:D-1→D


right around there
qazz42 wrote:
:Output(D,C,"^
-1→D


right around there
Because If not(D detects when D is zero. You then are doing the equivalent of Output(0,C,"^, but 0 is an invalid row. The row must be between 1 and 8, inclusive.

OK, you're using D as both the flag for the shot, and the position. Therefore, you need to change the If not(D to If D.

Code:
:DelVar CDelVar D8→A
:8→B
:Repeat K=45
:ClrHome
:Output(A,B,"X
:getKey→K
:If D
:Then
:Output(D,C,"^
:D-1→D
:End
:If (K=21) and (A≠1
:Then
:B→C
:A→D
:End
:B+(K=26)1→B
:B-(K=24)1→B
:A-(K=25)1→A
:Then
:A+1→A
:If A>8
:1→8
:End
:If A<1
:8→A
:End



now i get syntax error
  
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 2 of 3
» 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