Skip to main content
GameDev.net gamedev.net
🔒 Locked

TI-83 "repeat" & "or" function. HELP plz

Started by Terrafirma Apr 4, 2007 at 11:36 AM 26 replies 7k views
Original Post
Terrafirma
Terrafirma
Can someone tell me how to use the "repeat" function and DeVar function? whenever I use DelVar, the variable still exist. I also need help with the "or" function. I get a stalemate when I do a program such as: :While 1 :Getkey->A :While A=0 :Getkey-> :End :if A=24 or 25 or 26 or 34 :blah blah blah
Sneftel
Sneftel
Moving to the Consoles forum. Please make an effort to post your threads in the right forum to begin with.
CrewNick
CrewNick
This line

:if A=24 or 25 or 26 or 34

Needs to become

:if A=24 or A=25 or A=26 or A=34

This is because each or will evaluate what's between it as a logical statement. So A=24 or 25 would evaluate become a boolean or const int. Sorry if it's confusing. I'm horrible at explaining things online :-p.

envy3d
envy3d
Shouldn't the second Getkey() have a variable that it stores to?

Also "or" does not separate values, it separates expressions. So your line of code should look more like:
if A=24 or A=25 or A=26...
Terrafirma
Terrafirma
What does the "repeat" function do? and how do I use it?
envy3d
envy3d
My guess (haven't owned an 83 in years) is that it executes the current label (lbl) from the beginning.
jouley
jouley
From this:
Quote:

The Repeat loop is kind of the opposite of the While loop. It is as follows:
Repeat conditioncommandsEND

Executes commands until condition is true


(Another possibly helpful link)
Simian Man
Simian Man
There is no point on using DelVar on regular scalar variables. It only really does anything when you use it on big things like strings, lists, matrices or pictures.
Terrafirma
Terrafirma
Thank you everyone for your responses, I now understand things alittle better now. I'm gonna get started on my program now ^_^

How can I make it so that the user can move their character at any given time like in pong for eaxample? I tried Getkey but it halts the rest of the program while it waits for an input. can someone solve this common yet difficult dilema?
jouley
jouley
As has been mentioned in your other thread, getkey shouldn't be blocking. How, exactly, are you using it? If you are using the code listed at the beginning of this thread, then you are using getkey wrong -- it needs to be stored into a variable (as was mentioned in this thread).
envy3d
envy3d
Can you pick up arrowkey presses with Getkey()?
jouley
jouley
Quote:
Original post by envy3d
Can you pick up arrowkey presses with Getkey()?

Are you asking in general (yes, the codes are (*I think*) 24, 25, 26, and 34) or if the OP is able to?
Terrafirma
Terrafirma
I am new to "Getkey", I usually just made text based games and avoided the complexity. I wanted to do something new and better so I start with Getkey. I don't fully understand it, as you might have noticed. I start with Getkey thusly:

:While 1
:Getkey->A
:While A=0
:Getkey->A
:End
:
:

I don't fully understand what each of those lines does either. That is just how I always see it done and that is why I do it that way. I'm assuming it means "While True, Getkey is stored to A, While A is equal to 0, get the value of Getkey and store it to A, End". that's what I gathered from the expression. maybe someone can help me to better understand it, because while this code works, it freezes all other actions until Getkey-> A is defined.
jouley
jouley
Quote:
Original post by Terrafirma
:While 1
:Getkey->A
:While A=0
:Getkey->A
:End

"While True, Getkey is stored to A, While A is equal to 0, get the value of Getkey and store it to A, End"

That's pretty much it, actually, although I think you need a final "End" to make it all match up nice and pretty.

What you need to pay attention to, though, is the part about "While A is equal to 0, get ..." What that says, in effect, is "Don't continue until A is something I can use." What you want to happen, though, is "If I can use A, use it. If not, meh, I didn't want it anyway." So, rather than forcing A to be usable, just don't use it if it's 0. Moving a character on the screen may look like this:
While A != 108 // is that the code for Enter?  I can't remember, and don't have a layout handy to check...Getkey->Aif A = 24// move leftelse if A = 25// move upelse if A = 26// move rightelse if A = 34// move down// your if structure is over, now do the rest of the updating/drawing/outputting you want to do// everything here executes, then loops back up to the While to see if Enter has been pressedEnd


Does that help?
Terrafirma
Terrafirma
Thank you jouley for your advice. I don't know if it works yet because I haven't tried it but just by looking at it, I can see that it does work and it does move the character around. unfortunely that's not the problem. the problem is that when you are prompted to move, everything else freezes while it waits for your input. you might have solved that in your above code but I'm not sure, like I said I have yet to try it. say for instance, there are letters flying past thte screen and you have a "*" in the middle that can move around to dodge the numbers. I need to know how to have the numbers move the entire time and enable the user to move at any given time. and 105 is the code for Enter ^_^
the keys go by coordinates. for example:

Y= is 11 because it's in the first row first column
Enter is 105 because it's in the 10th row 6th column (minus "on" so it's the 5th column). that's how I remember it.
jouley
jouley
Quote:
Original post by Terrafirma
say for instance, there are letters flying past thte screen and you have a "*" in the middle that can move around to dodge the numbers. I need to know how to have the numbers move the entire time and enable the user to move at any given time.

That should do it. Just put the code for all the other characters flying about after the "if"s and before the End.

Quote:
and 105 is the code for Enter ^_^
the keys go by coordinates.

Indeedy -- Had I my TI to look upon/test, I'd have had a much better answer for you. Sadly, it's far away...

That said, I still think the above code should work. Please do let me know if it doesn't, though.
Terrafirma
Terrafirma
I tried it and it didn't work. I think it's missing a "Then" after each "If" due to the use of "Else". I tried what you wrote and it just ended. I also implimented a character to give it something to work with, like this:

:5->X
:5->Y

then within the loop I put:

:Output(X,Y,"X"

so that it show an "X" at the coordinates (5,5)
I put X-1->X ... and so on with the "If" Statements to make it move. Nothing happened tho.
jouley
jouley
You're right, you'll need some "Then"s. Also, I seem to remember now that an If-Then structure requires an "END" at the end. So, you'll have to add another END before the "other" code executes to end the If-Thens. To keep it simple for now, you may try taking out the "Else"s and just having "If"s, so that the extra END isn't necessary.

How did the program end? Did it output the "X" before it ended? And shouldn't you close your parentheses on Output( )?
Terrafirma
Terrafirma
It just showed an "X" a had a blinking cursor indicating it was over. it didn't say "Done" or anything. You don't need an ")" at the end of the "Output(", it just waste memory along with end qoutes " and multiplication signs: A*7->A is better written A7->A. It's more noticable with large programs. I took out the "Else" and "Then" and it moves. I'm about to add some things in it that move the entire time and see if it lets me move simultaneously.



Terrafirma
Terrafirma
This is what I have so far:

:5->X
:5->Y
:ClrHome
:While A != 105
:getKey->A
:Output(X,Y,"X"
:If A=24
:Y-1->Y
:If A=25
:X-1->X
:If A=26
:Y+1->Y
:If A=34
:Y+1->X
:End

That codes displays an "X" at the points (5,5) which can be moved. an X is left in it's place (I'll clean that part up later, too much logic involved to do it now lol ^_^). Now I need to add an object that moves around so I can dodge it. any suggestions?



Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.