You can help CodeWalrus stay online by donating here. | New CodeWalrus | Old (dark mode) | Old (light) | Discord server

My BASIC Questions

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

0
b/Calculator Talk publicado por u/xMarminq_ November 13, 2016, 11:24:38 PM
I am making a part of a game where I need two things running at once, like doing an action in a said time period.
Let me know what you would do, and will certainly help in the development. 
Inicia sesión o crea una cuenta para dejar un comentario
u/E37 November 13, 2016, 11:38:23 PM
I would have them take turns running. Knowing what two things would be helpful.
To answer your question, there is no way of doing two things at the exact same time at all on the calc.
u/p2 November 13, 2016, 11:56:08 PM
in general you can either switch between two tasks super fast or do two things after another and repeat that over and over again...
which would be Interrupts (not available in pure BASIC) or putting everything in your main loop ^^
While 1
: task 1
: task 2
: task 3
:End

btw WHILE 1 is the same as WHILE TRUE which means the condition (true) is always met ---> infinite loop :)

But before trying something fancy now, listen to E37 as there are better ways of doing many things ^^
u/kotu November 13, 2016, 11:59:27 PM
We really need a bit more information as.... you may have a simpler situation than described above

For example if you need to work out distance travelled for two cars, you can just multiply 'Time Passed' by Speed and there you have both distances
u/xMarminq_ November 14, 2016, 01:36:13 AM
Like I want someone to tap a button to get to a certain value while a timer is going off
u/kotu November 14, 2016, 01:42:16 AM
What you want to do is fairly simple - someone else will explain though as I don't know really any TI-BASIC
u/xMarminq_ November 14, 2016, 02:08:59 AM
Start mentioning people you may know who could help
u/kotu November 14, 2016, 02:12:54 AM
I don't know who uses TI-BASIC on here, I'm more into other languages, namely C and C++

What you want though is an infinite loop, in which you keep checking for key presses, and keep checking the timer  :P
u/xMarminq_ November 14, 2016, 03:17:21 AM
Any way someone can create something like that here?
u/kotu November 14, 2016, 03:25:11 AM
Someone else can help you, not me.
u/kotu November 14, 2016, 03:29:24 AM
Can someone help _xmarminq with some getkey() function equivalent and some timer function for TI-BASIC. Thanks  (-_(//));

*Edit*
@xMarminq_ check out these 2 webpages...

http://tibasicdev.wikidot.com/getkey

http://tibasicdev.wikidot.com/timers

ps. sorry for top-posting  :'(
Last Edit: November 14, 2016, 03:38:22 AM by kotu
u/JWinslow23 November 14, 2016, 03:46:30 AM
@xMarminq_ , I could help. I'm not sure you're being specific enough, but it sounds like a Cookie Clicker-type thing.

You will have to be more specific, though. What project are you working on? Can you describe what it's supposed to look like? Do you have a TI-83+, TI-84+, or the TI-84+ color models? (as far as timers, there are differences between different models)
u/xMarminq_ November 14, 2016, 09:21:42 PM
It is a CE, (5.2 OS) and I want something around a game where you press a button as much as you can to get to certain value in an amount of time (maybe when a key pressed add symbol +, when time expires delete last +, constant decrease of +1 every second) and the If A=7 (Goal) , do this, If A≥7, Menu for restart, if A≤7, action as if goal. (IS this possible? let me know.
u/JWinslow23 November 14, 2016, 11:15:13 PM
Quote from: xMarminq_ on November 14, 2016, 09:21:42 PM
It is a CE, (5.2 OS) and I want something around a game where you press a button as much as you can to get to certain value in an amount of time (maybe when a key pressed add symbol +, when time expires delete last +, constant decrease of +1 every second) and the If A=7 (Goal) , do this, If A≥7, Menu for restart, if A≤7, action as if goal. (IS this possible? let me know.

Quote from: xMarminq_ on November 14, 2016, 09:21:42 PM
(IS this possible? let me know.
TI-BASIC is Turing-complete; basically, anything's possible ;) .

So, what you might be looking for here is a Repeat loop and getKey. Repeat has this syntax:
Repeat <conditional>
<code>
End

Where <conditional> is the conditional that will end the loop when it is true, and <code> is the code to repeat.
Repeat always runs unconditionally once, then at the end of the loop, it checks the conditional, and exits if it's true, and otherwise it restarts.

getKey is a number that depends on the row and column of the current key pressed (for example, Y= is 11 because it's in row 1 column 1, PRGM is 43 because it's in row 4 column 3, etc). There are only two "exceptions"; row 2 is considered to have 2ND, MODE, DEL, LEFT, UP, and RIGHT, and row 3 is considered to have ALPHA, XTON, STAT, and DOWN.

I obviously cannot write the code for you (you know your game idea better than me), but here's a rough guideline:
Repeat A>=7         // I assume that's what you want to end on. You never told me what it meant, though.
  getKey->K
  If K=<keycode>    // put keycode here
  Then
    <action for a keypress>
  End
  <other actions>
End


Still not sure exactly what you mean by your idea, but hopefully I helped!

Oh, and timer commands will be useful too, but I don't wanna teach you about them unless I know it's precisely what you need.
u/xMarminq_ November 17, 2016, 12:21:12 AM
I want dat :D (Timer)
ill try it when I get to that part of my project I'm making
Start a Discussion

b/Calculator Talk

Saw a cool TI, HP or Casio program out there? Need help programming or installing a software? This place is for you.

283
Topics
Explore Board
Website statistics


MyCalcs | Ticalc.org | Cemetech | Omnimaga | TI-Basic Developer | MaxCoderz | TI-Story | Casiocalc.org | Casiopeia | The Museum of HP Calculators | HPCalc.org | CnCalc.org | Music 2000 Community | TI Education | Casio Education | HP Calcs | NumWorks | SwissMicros | Sharp Calculators
Powered by EzPortal