Author | Comment |
jet1891 Probe Posted: 21 Nov 2005 18:14 GMT Total Posts: 6 | I have a TI-84+ and I am a fairly good BASIC programmer but i didn't learn from anyone or any guides, i just learned from looking at other programs and the very horrible 84 guide book that doesn't really say anything. So i need to know once a person lets say enters their name, how can i display that name in say a high scores table without programing the specifis name in the program?
How can i do this? if u need to, e-mail me at jet1891@yahoo.com
thanks |
ericgagne Probe Posted: 21 Nov 2005 19:23 GMT Total Posts: 11 | Use the Input/Prompt key and store as a string ... then to display that string use the disp str X key (or output).
Note: strings are found under vars. |
jet1891 Probe Posted: 21 Nov 2005 19:59 GMT Total Posts: 6 | Nice, thanks, can you tell me how getKey works too |
ericgagne Probe Posted: 21 Nov 2005 20:11 GMT Total Posts: 11 | Look in your manual for more info ... but I'll give you what I can quickly.
If you program in getkey->K, it will store the key you hit into the variable K. You must also have the calculator repeating, so you set a variable, say W to 1. Then program:
While W=1 (This will keep the game engine running) Getkey->K (This will store any key you enter to K) If K=...:then (Now set what you want it to do when a ... certain key is pressed)
Note: the # that corresponds with each key is the collumn it's in and then the row. So, the Del key would be 23. The only confusing ones are the arrows (left=24, up=25, right=26, and down=34). Also, the "On" key does not have a getkey.
What are these good for? ...everything, especially if you want to have an X move across the screen. See TIFreakware's website's tutorial for more info on how to program stuff like that, or ask me. |
Jonny23451 Ultralisk Posted: 21 Nov 2005 20:14 GMT Total Posts: 214 | instead of while W=1, just use While 1. Getkey's usefull for a lott of things. alot. :) |
ericgagne Probe Posted: 21 Nov 2005 20:15 GMT Total Posts: 11 | Also, I forgot, in some cases you can save memory by getting rid of the ->K and just using getkey ... then it is If Ans=... |
Andy Administrator Posted: 21 Nov 2005 20:16 GMT Total Posts: 939 | If you're going to use While 1 just use a (ick) Lbl:Goto block. |
ericgagne Probe Posted: 21 Nov 2005 20:18 GMT Total Posts: 11 | Andy, are there any advantages to "While 1" or should I stick to "While W=1"? |
Andy Administrator Posted: 21 Nov 2005 20:34 GMT Total Posts: 939 | OK guys you obviously haven't messed even with TI-Basic much.
You can ONLY use Ans with getKey if you only want to check for *ONE* key. Or at the very least, as soon as you do ANY math it destroys Ans. You probably can get by with:
getKey If Ans=10 Then docrap End If Ans=11 Then doothercrap End
Etc. But if you do some fancy math OUTSIDE of an If then you destroy Ans. For this reason (and readability!) I recommend using a variable. It's only a couple more bytes only a few ticks slower.
As for 1->W:While W vs. While 1vs. Lbl lp:...:Goto lp, the OBVIOUS winner is the Lbl lp:...:Goto lp, even though it's a goto. If you're doing an infinite loop in Basic, it's best to not use control structures! If you'd Goto out of that infinite While, for example, you'd leave some stuff on the stack which causes the program to run slower and run out of memory eventually.
edit: And if you REALLY want to know the differences between 1->W:While W and While 1, here you go: * Use 1->W:While W if you plan on changing W to 0 somewhere to break out of the loop. * If you are NOT planning on ever breaking out of the loop (other than using say Stop), use While 1.
[Edited by Andy on 22-Nov-05 05:36] |
ericgagne Probe Posted: 21 Nov 2005 20:44 GMT Total Posts: 11 | So, if I'm making an RPG w/ movement (I actually already ran into that ans problem and had to change it to K), then instead of using While W=1 ... programming for movement in my map, I should use a lbl ... programming in my map ... goto the lbl?
Thanks Andy.
Edit: And by the way, if you use hit detection for everything in the moving the X/sprite without any optimization/use of the sub( command, then you can get away with using the Ans ... of course, as I learned when I discovered you could optimize, saving hundreds of bytes is worth the couple it takes to change ans to a variable.
[Edited by ericgagne on 22-Nov-05 05:47] |
TI Freak Probe Posted: 22 Nov 2005 07:18 GMT Total Posts: Edit | If you use While W=1, you can change what the variable equals to run a different while loop, and then basically return back to the other while loop by restoring to it.
Basically, you can use the While command like a Lbl command, if you know how to do it correctly... :) |
Andy Administrator Posted: 22 Nov 2005 09:48 GMT Total Posts: 939 | Really? I'd like to see an example, please. |
TI Freak Probe Posted: 22 Nov 2005 10:28 GMT Total Posts: Edit | I did it in AOD, it doesn't have one single lbl in it, just a bunch of While loops as lbls...
One way to do it is to have one large while loop, with the others inside of it. You can also use it in a seperate program, in the 'mother' program, store to the variable, then the other program, you would just need the While commands, I believe. It has been a long time since I did it. I will see if I can post some of the code tonight... |
CoffmanRunner Ultralisk
Posted: 6 Dec 2005 14:33 GMT Total Posts: 235 | To make a program easier to read (this will not save room on the calc) make muti. prgms and makethem link to each other also this make it easier to read. I will clog up your programs menu though sorry also if you want a program to go to the VERY TOP of a program you can just do a prgmx with x being the prgm you are in.
x :program code :prgmx
[Edit] Hey ericgagne I was going to email u but you keept it private I am making a RPG w/ movement if you want i can send you it all (it is 21 files with very few goto/lbl cause i hate them) so i just linked prgms lot's of them I can't promise it will all work and some prgms arn't even linked yet but i made a move "engine" pretty much i made a matrix the 8x16 (size of screen) and on the main run pgrm it prgramed in where every thing was on the matrix (ex: if there is a wall then i wrote code to store a 2 at that spot in the matrix that corresopnded with the home screen. also i did this (using matirx [H]
2->[H](6,16 3->[H](2,1 4->[H](2,16 5->[H](7,1 6->[H](7,16
I just pasted a few lines in there but then in the move program...
If X=26 Then D+1->D If D=17 D-1->D If 2=[H](C,D) D-1->D End
X is get key and D is the <-> movement yes it may not be the best "code" but you geet the point 2 on the matrix is a wall and you can't run into it also for going into stores...
If 3=[H](C,D) <- If there is a 3 on the matrix where you are moving to Then prgmASTORE1 <- run the store menu prgmAMOVE <- then run this prgm again End
Also there is a program i worte that re-draws the screen and put's you char. out side the store when you leave
lasly my DRAWMAP prgm this prgm is like a huge loop that "ask's" the matrix about what it has stored in it's self it scrolls the whole screen (128 times it loops 8x16=128)
If 2=[H](A,B) <-if there is a 2 on the matrix Output(A,B,"w <-output an x on the screen
hope this helps email me at coffmanrunner@gmail.com for the whole thing or more questions hope this helps
This game will come out soon!
[Edited by CoffmanRunner on 09-Dec-05 01:59]
--- Never gonna let you down... |