Basically I tried making a game where you control an 'O' and random '0's pop around the screen and when you hit one you lose so it's like how long can you stay. But I can only get one loop running at a time so I have 2 loops(One for character movement and the other for the '0's) and I tried repeat loops to but no matter what I try it only runs one loop at a time and the other doesn't run until the first loops conditions are met then it goes vice-versa.


Code:
8→A:4→B
ClrHome

While 1
randInt(1,10)→D
randInt(1,26)→E
Output(D,E,"0"
Wait 2
If B=E and A=D
Then
ClrHome
Stop
End
End

Repeat K=105
getKey→K
Output(A,B,"O
If K=24 and B>1
Then
Output(A,B," "
B-1→B
End
If K=26 and B<26
Then
Output(A,B," "
B+1→B
End
If K=34 and A<10
Then
Output(A,B," "
A+1→A
End
If K=25 and A>1
Then
Output(A,B," "
A-1→A
End
If K=105
Then
ClrHome
Stop
End
End
You need to learn how to debug things on your own please.
That's because TI BASIC is a procedural language. It can only do one line (starting from the top and moving to the bottom) at at time and therefor one loop at a time. There's no way to run two loops, like you're trying to do, at once. Your only option is to combine the two loops into one bigger loop. (Note: a While 1 command will never quit so it's not ideal for programming games or anything you're planning on releasing.)

Expanding on what Mateo said. We appreciate all your questions, however we are not your personal programmers. You do need to learn to research and solve issues yourself, there's no better way to learn. Wink

I would highly suggest referencing TIBasicDev as it is an incredible resource for learning BASIC. I still look at every now an then whenever I need to remember what a command does or how a routine works.

Don't be scared away from asking questions at all though. Just please spend more time researching your issue before you make a new topic for it. Smile
Also, could you please make a topic named 'davidclue's BASIC questions' and post all your question under that one topic? It will be easier for you to reference the questions and answers to your questions since everything will be under one topic rather than scattered throughout the forum. Smile

Happy researching!
I just analyzed the code, and if you haven't already, my post will optimize your code to what you want it to do.


Code:
Repeat K=105
randInt(1,10)→D
randInt(1,26)→E
Output(D,E,"0"
Wait 2
If B=E and A=D
Then
ClrHome
Stop
End
Repeat K=105
getKey→K
Output(A,B,"O
If K=24 and B>1
Then
Output(A,B," "
B-1→B
End
If K=26 and B<26
Then
Output(A,B," "
B+1→B
End
If K=34 and A<10
Then
Output(A,B," "
A+1→A
End
If K=25 and A>1
Then
Output(A,B," "
A-1→A
End
End
End
End
ClrHome
"


This is my version, in which I think it will help. Happy programming!
  
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 1 of 1
» 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