Don't have an account? Register now to chat, post, use our tools, and much more.
This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's TI-BASIC subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

TI-Basic => TI-BASIC
 » Goto page 1, 2  Next
Author Message
Awesome1

Joined: 28 Jan 2004
Posts: 269

 Posted: 02 Mar 2004 06:42:29 pm    Post subject: I'm having a little trouble with my scrolling program. I want it to have a name bounce around on the screen. Like in pong the way it bounces of the slide but for text. This is the code i've compiled but it don't work...what am i doing wrong? Code: ```ClrHome 2->Y                                  // Sets the A-Axis 2->X                                 // Sets the X-Axis 1->B                                 // Sets the Y-Axis for the "trail clearer" 1->A                                 // Sets the X-Axis for the "trail clearer" 0->K Lbl 1 Output(B,A,"    "                 // 4 spaces Output(Y,X,"TEXT"             // the text that moves around the screen X+1->X:Y+1->Y                // Moves the text B+1->B:A+1->A               // Moves the text If X>13:X-1->X                 // Sets the parameters If X<1:X+1->X                 // Sets the parameters If Y>8:Y-1->Y                   // Sets the parameters If Y<1:Y+1->Y                  // Sets the parameters If A>13:A-1->A                // Sets the parameters If A<1:A+1->A                // Sets the parameters If B>8:B-1->B If B<1:B+1->B               // Sets the parameters While K=0 GetKey->K While K (not equal to) 22 // If Mode has not been pressed, loops again... Goto 1``` What am I doing wrong? Last edited by Guest on 02 Mar 2004 06:47:18 pm; edited 1 time in total
omni

Member

Joined: 14 Jun 2003
Posts: 115

 Posted: 02 Mar 2004 07:24:34 pm    Post subject: did you put the end statements? and why don't you loop the code instead of putting a 'goto 1'
Awesome1

Joined: 28 Jan 2004
Posts: 269

 Posted: 02 Mar 2004 07:40:40 pm    Post subject: [QUOTE]ClrHome 2->Y                                  // Sets the A-Axis 2->X                                 // Sets the X-Axis 1->B                                 // Sets the Y-Axis for the "trail clearer" 1->A                                 // Sets the X-Axis for the "trail clearer" 0->K Lbl 1 Output(B,A,"    "                 // 4 spaces Output(Y,X,"TEXT"             // the text that moves around the screen X+1->X:Y+1->Y                // Moves the text B+1->B:A+1->A               // Moves the text If X>13:X-1->X                 // Sets the parameters If X<1:X+1->X                 // Sets the parameters If Y>8:Y-1->Y                   // Sets the parameters If Y<1:Y+1->Y                  // Sets the parameters If A>13:A-1->A                // Sets the parameters If A<1:A+1->A                // Sets the parameters End Goto 1Last edited by Guest on 02 Mar 2004 07:46:48 pm; edited 1 time in total
Awesome1

Joined: 28 Jan 2004
Posts: 269

 Posted: 02 Mar 2004 08:09:57 pm    Post subject: I modified it slightly cuz i got an error: changed -B->B to B-1->B and -A->A to A-1->A Than i got this when the "text" hit to the top: ERR:DOMAIN at Output(Y,X,"Text". I'm looking into the problem but if anyone can help me fix it it would be greatly appreciated: Code: ```Current Code: ClrHome 2->Y:2->X 1->B:1->A Repeat K=22 Output(Y,X,"four spaces If Y=1 or Y=8 B-1->B If X=1 or X=13 A-1->A Y+B->Y X+A->X Output(Y,X,"TEXT For(N,0,50 End getKey->K End```
Darth Android
DragonOS Dev Team

Bandwidth Hog

Joined: 31 May 2003
Posts: 2104

 Posted: 02 Mar 2004 11:47:52 pm    Post subject: Code: ```3->C //length of text - 1, must be less than 16 1->A 1->B //set up starting coords 1->D 1->E //set up direction Repeat getKey=22 //wait for a certain key, [mode] Output(A,B,"TEXT D(A>1 and A<8)+(A=1)-(A=8->D E(B>1 and B+C<16)=(B=1)-(B+C=16->E Output(A,B,"(number of spaces in TEXT, 4 in this case) A+D->A B+E->B End``` i just finished my pong game, so anything regarding making something bounce off the walls of the screen should be routed to me works like a charm. have fun!Last edited by Guest on 02 Mar 2004 11:48:43 pm; edited 1 time in total
Jedd
1980 Pong World Champion

Elite

Joined: 18 Nov 2003
Posts: 823

 Posted: 03 Mar 2004 02:20:38 am    Post subject: You might want to stick to If statements so the noobs can understand.
Arcane Wizard
`semi-hippie`

Super Elite (Last Title)

Joined: 02 Jun 2003
Posts: 8993

 Posted: 03 Mar 2004 06:49:09 am    Post subject: They can ask questions about it if they don't understand.
Awesome1

Joined: 28 Jan 2004
Posts: 269

 Posted: 03 Mar 2004 04:34:49 pm    Post subject: Well most newbies put the code in even if they don't understand how it works. But i like to understand what the strings functions and stuff are. Only so i don't have to keep coming back to here. Only makes sence to learn what and why people coded it the way they did. But i like to stick to if then statements if at all possble. Only cuz it simpler. I used the If statements but im holding on to this code for later when i understand it better and change the code... The RED are the strings i don't understand [CODE]3->C //length of text - 1, must be less than 16 1->A 1->B //set up starting coords 1->D 1->E //set up direction Repeat getKey=22 //wait for a certain key, [mode] Output(A,B,"TEXT D(A>1 and A<+(A=1)-(A=8->D E(B>1 and B+C<16)=(B=1)-(B+C=16->E Output(A,B,"(number of spaces in TEXT, 4 in this case) A+D->A B+E->B End GetKey->K forgot to add that Arcane, but please correct me if im wrong EndLast edited by Guest on 03 Mar 2004 04:36:21 pm; edited 1 time in total
Arcane Wizard
`semi-hippie`

Super Elite (Last Title)

Joined: 02 Jun 2003
Posts: 8993

 Posted: 03 Mar 2004 05:14:16 pm    Post subject: Awesome1 wrote:The RED are the strings i don't understand I wouldn't call them strings if I where you, very confusing. :) D(A>1 and A<+(A=1)-(A=8->D This is using boolean logic (use the search function of the forum to find a good thread about it). A>1 returns 1 if A is more than 1 and 0 if not A<8 returns 1 if A is less than 8 and 0 if not and compares the values returned by A>1 and A<8, if they are both 1, it returns 1. So, if A is more than 1 and A is less than 8, (A>1 and A> returns 1. Next, we simply multiply this by D so that if A is more than 7 and less than 2 (the coordinates go of the screen), it becomes 0, where we add the direction to go (bounce) to. If A is 1, we need the vertical direction (represented by D) to become 1, if A is 8 we need it to become -1 so when we add it to the current position it moves in the right direction. So, let's say A=8 (A>1 and A< returns 0, because not both A>1 and A<8 are true (return 1) we mutiply D by 0, so we now have 0 where we add what's after the + sign... (A=1) returns 0, so we add nothing so far.. But wait! A=8 returns 1, so we decrease (yes, that's a -) the 0 by 1 (since 1 is what's returned by A= and all we have left to do is store it to D. Later, when we want to change the vertical coordinate of the object, we add D to it. A+D->A D is -1, so what we do is decrease A by 1, which moves the object up. Same thing happens to E and B only E represents horizontal movement and B the horizontal coordinate of the object. Quote:GetKey->K forgot to add that Arcane, but please correct me if im wrongI don't see why you'd want that there, unless you'd want the user to press a key again right after pressing a key to get out of the loop.Last edited by Guest on 03 Mar 2004 05:16:55 pm; edited 1 time in total
X1011
10100111001

Active Member

Joined: 14 Nov 2003
Posts: 657

 Posted: 03 Mar 2004 05:55:49 pm    Post subject: Arcane Wizard wrote: Quote:GetKey->K forgot to add that Arcane, but please correct me if im wrongI don't see why you'd want that there, unless you'd want the user to press a key again right after pressing a key to get out of the loop. You probably wouldn't want to put that there because it would make it near impossible for the Repeat getKey=22 to end.
Arcane Wizard
`semi-hippie`

Super Elite (Last Title)

Joined: 02 Jun 2003
Posts: 8993

 Posted: 03 Mar 2004 06:13:44 pm    Post subject: Actually, it doesn't influence the Repeat getKey=22 line at all.Last edited by Guest on 03 Mar 2004 06:13:58 pm; edited 1 time in total
X1011
10100111001

Active Member

Joined: 14 Nov 2003
Posts: 657

 Posted: 03 Mar 2004 09:15:28 pm    Post subject: Well, I think it does because it comes right before it and theres not enough time to press the key between the 2 checks of the getkey.
Arcane Wizard
`semi-hippie`

Super Elite (Last Title)

Joined: 02 Jun 2003
Posts: 8993

 Posted: 04 Mar 2004 06:21:32 am    Post subject: Come to think of it, getkey=22 is impossible, funny how we all missed that . And you don't need that second end. 3->C //length of text - 1, must be less than 16 1->A 1->B //set up starting coords 1->D 1->E //set up direction Repeat Ans=22 //wait for a certain key, [mode] Output(A,B,"TEXT D(A>1 and A<+(A=1)-(A=8->D E(B>1 and B+C<16)=(B=1)-(B+C=16->E Output(A,B,"(number of spaces in TEXT, 4 in this case) A+D->A B+E->B getKey End If Ans=22:Disp "YOU PRESSED MODE TO EXIT THE LOOP! HOW COULD YOU!Last edited by Guest on 04 Mar 2004 06:21:49 am; edited 1 time in total
X1011
10100111001

Active Member

Joined: 14 Nov 2003
Posts: 657

 Posted: 04 Mar 2004 03:05:51 pm    Post subject: Arcane Wizard wrote:Come to think of it, getkey=22 is impossible What are you talking about? Yes it is.
Toksyuryel
Crimson Dragon Software

Elite

Joined: 14 Jun 2003
Posts: 880

 Posted: 04 Mar 2004 06:24:10 pm    Post subject: As a loop condition it's impossible for Arcane to figure out how it works. I think that's what he means.
X1011
10100111001

Active Member

Joined: 14 Nov 2003
Posts: 657

 Posted: 04 Mar 2004 07:59:26 pm    Post subject: Figure out how it works? What is there to figure out?
Arcane Wizard
`semi-hippie`

Super Elite (Last Title)

Joined: 02 Jun 2003
Posts: 8993

 Posted: 05 Mar 2004 06:01:21 am    Post subject: X1011 wrote: Arcane Wizard wrote: Come to think of it, getkey=22 is impossible What are you talking about? Yes it is. Nope, Repeat getKey=22 doesn't work, nor will While getKey=# ir if getKey=# it just doesn't work. Quote:As a loop condition it's impossible for Arcane to figure out how it works. I think that's what he means.Nope. Quote:Figure out how it works? What is there to figure out?Exactly. Check the manual, it clearly states that you can only use getkey with ans or another variable and can't check it directly unless you're going for true or false like in Repeat getKey. Works: Repeat getKey While getKey If getKey Doesn't Works: Repeat getKey=# While getKey=# If getKey=# Oh, and burr, your code is optimized for size, Darth's code is for speed.
aka Tianon

Know-It-All

Joined: 02 Jun 2003
Posts: 1874

 Posted: 05 Mar 2004 05:11:25 pm    Post subject: actually, in the TI manual, dont they use this? :Code: ```While getKey<>0 End```im not sure if they actually do this (prolly just my halucinations), but i know it works (ive used it i believe) cant you? maybe im wrong (happens a lot)
Arcane Wizard
`semi-hippie`

Super Elite (Last Title)

Joined: 02 Jun 2003
Posts: 8993

 Posted: 05 Mar 2004 05:51:46 pm    Post subject: I'm starting to freak myself out, I am absolutely 100% positive of being able to recall reading a paragraph in the manual explaining getKey=# would not work. I can even recall where on the page this paragraph was, and how the general layout of the page looked like (paragraph size an such). I went to look for it so I could quote it here, but to no avail. I then looked for some batteries, put them in my calc, and checked if Repeat getKey=21 worked, to my surprise it did. 0_o
X1011
10100111001

Active Member

Joined: 14 Nov 2003
Posts: 657

 Posted: 05 Mar 2004 07:35:59 pm    Post subject: lol, you are going crazy, I told you it works. Quote:While getKey<>0 End That wouldn't work, it would exit as soon as you start it.
 Display posts from previous: All Posts Oldest FirstNewest First
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.

»
 » Goto page 1, 2  Next Page 1 of 2 » All times are GMT - 5 Hours