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.

This forum is locked: you cannot post, reply to, or edit topics. TI-Basic => TI-BASIC
United-TI Archives -> TI-Basic
 
    » Goto page 1, 2  Next
» View previous topic :: View next topic  
Author Message
Bluefire


Member


Joined: 18 Jan 2004
Posts: 186

Posted: 21 Apr 2004 06:00:36 pm    Post subject:

Laughing i am making a game, and part of it needs an 0 moving back and forth, but it only goes one way then stops and the score continually increases, can anyone help me find the bug?

Code:
0->E
70->A
0->I
ClrHome
ZStandard
Menu("SPACE NEEDLE!","PLAY",P,"CREDITS",C,"QUIT",Q
Lbl P
RecallPic Pic5
While 1
Repeat K
getKey->K
Text(10,80,E
Text(47,A,"0
For(M,1,30
End
If A=71
I->0
If A>34 and Iø1
A-1->A
If A=34
A+1->A
If A=34
I->1
If I=1
A+1->A
If K=21 and A=65 or 64
E+1->E
End
End

Notes:
ø is not equal
to run the program on ur calc u may need to remove the recallpic
Back to top
X1011
10100111001


Active Member


Joined: 14 Nov 2003
Posts: 657

Posted: 21 Apr 2004 06:11:41 pm    Post subject:

Try something like this:

Code:
70->A
1->I
Repeat K
Text(47,A,"0
A+I->A
If A=71
-1->I
If A=34
1->I
Getkey->K
End
Back to top
Fr0sty


Member


Joined: 27 Nov 2003
Posts: 202

Posted: 21 Apr 2004 06:23:17 pm    Post subject:

If K=21 and A=65 or 64

Should be: If K=21 and A=65 or A=64

Of course, I have no idea how the calc would interpret that so I'd probably split that statement into two separate If statements such as:

If K=21 and A=65
do sumthin
If K=21 and A=64
do sumthin

-OR-

If K=21 and A=65
do sumthin
If A=64
do sumthin
Back to top
Bluefire


Member


Joined: 18 Jan 2004
Posts: 186

Posted: 21 Apr 2004 06:53:57 pm    Post subject:

ok XX1011's thing worked, but now i got a new prob

Code:
0üE
ClrHome
ZStandard
Menu("SPACE NEEDLE!","PLAY",P,"CREDITS",C,"QUIT",Q
Lbl P
RecallPic Pic5
70üA
1üI
Repeat K
Text(48,A,"0
Text(7,80,E
For(N,1,70
End
A+IüA
If A=71
ú1üI
If A=34
1üI
A-1üB
Text(48,B,"
getKeyüK
If K=21 and A=65
E+1üE
End

whenever i hit 2nd it just quits the prog
Back to top
X1011
10100111001


Active Member


Joined: 14 Nov 2003
Posts: 657

Posted: 21 Apr 2004 07:05:53 pm    Post subject:

Try changing

Repeat K

to

Repeat K and K<>21
Back to top
Bluefire


Member


Joined: 18 Jan 2004
Posts: 186

Posted: 21 Apr 2004 07:47:06 pm    Post subject:

thx, Laughing that worked, now i ahve one last prob, i added some things so the for loop changes to add speed and increase difficulty and now it doesnt work

Code:
80üG
0üE
ClrHome
ZStandard
Lbl PQ
Menu("SPACE NEEDLE!","PLAY",P,"CREDITS",C,"QUIT",Q
Lbl P
RecallPic Pic5
70üA
1üI
Repeat K and Kø21
Text(48,A,"0
Text(7,80,E
For(N,1,G
End
End
A+IüA
If A=71
ú1üI
If A=34
1üI
A-1üB
Text(48,B,"
getKeyüK
If K=21 and A=65
E+1üE
If K=21 and A=64
E+1üE
If K=21 and A=63
E+1üE
If E=5
60üG
If E=10
40üG
If E=15
20üG
If E=20
Then
Output(5,5,"YOU WIN!
Goto W
End
Lbl Q
ClrHome
Stop
Lbl W
Output(5,5,"YOU WIN!
Pause
Goto PQ
Back to top
Fr0sty


Member


Joined: 27 Nov 2003
Posts: 202

Posted: 21 Apr 2004 10:23:32 pm    Post subject:

Easy-
Your loop says:

EDIT: I see two mistakes, you got misplacements.


Code:
80üG
0üE
ClrHome
ZStandard
Lbl PQ
Menu("SPACE NEEDLE!","PLAY",P,"CREDITS",C,"QUIT",Q
Lbl P
RecallPic Pic5
70üA
1üI
Repeat K and Kø21 //It ends before the Getkey see note below
Text(48,A,"0
Text(7,80,E
For(N,1,G
End
End //The loop you set "Repeat K and K /= 21" well K will never NOT equal zero because you didn't set a Getkey to change the K; Also read below note
A+IüA
If A=71
ú1üI
If A=34
1üI
A-1üB
Text(48,B,"
getKeyüK
If K=21 and A=65 //Even if you did set the end to all the way below, you can't have the getkey and the If statement in the same loop if the loop is supposed to exit when you press a key. Make the If statement a different loop so that the key press EXITS the current loop and goes to the If statement.
E+1üE
If K=21 and A=64
E+1üE
If K=21 and A=63
E+1üE
If E=5
60üG
If E=10
40üG
If E=15
20üG
If E=20
Then
Output(5,5,"YOU WIN!
Goto W
End
Lbl Q
ClrHome
Stop
Lbl W
Output(5,5,"YOU WIN!
Pause
Goto PQ
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 22 Apr 2004 07:10:08 am    Post subject:

burr wrote:

Code:
If K=21 xor A=65 and A=64 and A=63
E+1->E

XOR!? Confused This is basic you know, no XOR.

How about:

E+(K=21 AND A>62 AND A<66->E


Last edited by Guest on 22 Apr 2004 07:11:27 am; edited 1 time in total
Back to top
Adm.Wiggin
aka Tianon


Know-It-All


Joined: 02 Jun 2003
Posts: 1874

Posted: 22 Apr 2004 07:15:31 am    Post subject:

ah, but there is xor... it is a logical operator you know...

Press [2nd][TEST][>] and ye will see it Smile
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 22 Apr 2004 07:38:59 am    Post subject:

What the? (remembers there is XOR in basic)

Gah, let's just say it's been a while since I've bothered writing anything in basic.

XOR still shouldn't be used like that.


Last edited by Guest on 22 Apr 2004 07:41:55 am; edited 1 time in total
Back to top
Bluefire


Member


Joined: 18 Jan 2004
Posts: 186

Posted: 22 Apr 2004 09:37:44 am    Post subject:

i found out i had 1 too many ends in the middle and needed 1 more before lbl Q, it works now
Back to top
62 52 53 53
Formerly known as 62 52 53 53


Active Member


Joined: 30 May 2003
Posts: 607

Posted: 22 Apr 2004 04:20:57 pm    Post subject:

Quote:
If the only thing that you are doing for each conditional is adding one to E, then you can optimize this. What you should use instead is your XOR Boolean operator. This is what the code should look like:



Code:
If K=21 xor A=65 and A=64 and A=63
E+1->E


that wouldn't do the same thing. That means that if K=21 but A doesen't equal three separate numbers simultaneously. If you meant that, you would just use K=21

Now the simple way to make sure it's processed in the right order is parenthases.


Code:
If K=21 and (A=65 or A=64 or A=63)


...Will run in the correct order.
Each comparison returns either a 1 or a 0. If any of the last three returns a 1, the parentheses will return a 1. If both the parenthases and the first condition return a 1, the statement will return a 1, and the 'then' will execute.
Back to top
Bluefire


Member


Joined: 18 Jan 2004
Posts: 186

Posted: 22 Apr 2004 05:59:49 pm    Post subject:

when i finish this, does anyone want me to post the entire game?

and i also need a way to make an if then statement execute 4 commands


Last edited by Guest on 22 Apr 2004 06:05:29 pm; edited 1 time in total
Back to top
Babyboy


Advanced Member


Joined: 11 Jun 2003
Posts: 499

Posted: 22 Apr 2004 08:45:02 pm    Post subject:

Neutral u guys r on a whole nother level Neutral
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 23 Apr 2004 08:01:00 am    Post subject:

62_52_53_53 wrote:
If K=21 and (A=65 or A=64 or A=63)


I'm starting to doubt if people actually read my posts. (my line takes less memory!!111!11OMG!11!11)
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 23 Apr 2004 03:34:52 pm    Post subject:

Your code returns 1 (true) when K=21 but A isn't any of those.
Back to top
Bluefire


Member


Joined: 18 Jan 2004
Posts: 186

Posted: 23 Apr 2004 05:58:56 pm    Post subject:

i need a way to make an if then statement execute 4 commands if true, so could u please answer this b4 arguing? ty Laughing
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 23 Apr 2004 06:16:39 pm    Post subject:

If 1 //check for condition
Then
Disp 1 //first statement to execute if condition is true
Disp 2 //second
Disp 3 //third
Disp 4 //fourth
End
Back to top
Adm.Wiggin
aka Tianon


Know-It-All


Joined: 02 Jun 2003
Posts: 1874

Posted: 26 Apr 2004 04:53:58 pm    Post subject:

Would this be a good time for RTFM? (Read The Freaking Manual)

That's what it's for! Laughing
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 27 Apr 2004 07:24:55 am    Post subject:

Adm.Wiggin wrote:
Would this be a good time for RTFM? (Read The Freaking Manual)

It's better to just contribute and help instead of being rude...
Back to top
Display posts from previous:   
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
    » Goto page 1, 2  Next
» View previous topic :: View next topic  
Page 1 of 2 » All times are UTC - 5 Hours

 

Advertisement