| TIBasic tut- getkey, sub | |
|---|---|
| Topic Started: Jan 2 2008, 07:10 PM (876 Views) | |
| Mephiles the Dark | Jan 2 2008, 07:10 PM Post #1 |
|
The conscious will
![]() ![]() ![]()
|
yeah. I said I'd post this for some of my friends hoping to buff up the TIBasic skills. if you have nothing constructive to post, go away. anyway, we're gonna make a program that detects key pressage and returns the numbers first. make this in the calculator: notes on my notation: -> is the variable store symbol start programming...
i don't care what you name the program. the while function starts a loop, and, because it's one (true) always happens until you break it by pressing on. or your calc dies.
another while loop. this one resets z to zero and then the while loop detects key pressage while z is still 0. when it's not 0, you get out of the loop.
this displays the value of the key and restarts the program. there. now mess around with that to see the key code patterns while i post the next lesson. you should see a pattern- the first number is the coordinate of the key down and the last number is the coordinate of the key across. Edited by Mephiles the Dark, Jan 4 2008, 06:56 PM.
|
| |
![]() |
|
| Mephiles the Dark | Jan 2 2008, 08:09 PM Post #2 |
|
The conscious will
![]() ![]() ![]()
|
And I'm back! moving onnn.... This session you will make a BASIC movement program with arrow key inputs. code writing notes- -> is the store symbol _ is a blank space. != is the not equal to symbol start writing!
This is just setting up for the start. X will be coordinates across the screen, Y down it. once again, I don't care what you call it.
this outputs a symbol (in this case X) at coordinates X, Y. putting in the label also creates a fallback point for later on.
look familiar?
erases your symbol. it would be embarrasing if he left X's behind whereever he went
this little block of code reads whatever arrow key you pressed and responds by changing the x and y coordinates appropriately. if you don't press an arrow key, the coordinates aren't affected, so nothing really happens except your guy blinking (he is erased and then redrawn). the "(whatever) is not equal to (whatever)" is so your guy doesn't try to go to screen nonexistent coordinates.
this block of code resets the loop, redrawing the character and restarting the getkey loop. the end. hope you enjoyed. the next thing I'll post will be on collision detection using the sub function. Edited by Mephiles the Dark, Jan 4 2008, 06:56 PM.
|
![]() |
|
| Mephiles the Dark | Jan 2 2008, 09:45 PM Post #3 |
|
The conscious will
![]() ![]() ![]()
|
I'm back again! in this section we'll make a collision detector. code writing notes- -> is the store symbol _ is a blank space. != is the not equal to symbol start by modifying the movement program:
replace the ":clrhome" with an
that's a string. yeah. now, before this section:
add this:
this runs what's called a subroutine (here, basically another program) and reads what it responds. if it returns 1, then it resets the loop with no movement. now, to make another program (the subroutine). if you bothered looking, then notice that the command "prgmCOLDET" exectues a program call COLDET. so, make one. like now.
this just sets up the thing. you'll see what it does later. Just so you know, w is y-1 to make the count we’ll discuss later accurate.
this alters the variable based on which key was pressed.
this ends the program if the result will be something nonexistent. s is a label you'll see later.
This is making use of the “sub(“ function. Basically, it mathematically seeks out the character at the location (z, the horizontal, plus 16 times w, the vertical rows minus one) of string one and gets one character from that. Is that’s a plus, it return zero.
If it’s not, then you skip to here from above. The program ends and returns to the mover. If it returns a 1, nothing happens. Try it! OK, that’s it. Edited by Mephiles the Dark, Jan 4 2008, 06:57 PM.
|
![]() |
|
| Mephiles the Dark | Jan 2 2008, 09:53 PM Post #4 |
|
The conscious will
![]() ![]() ![]()
|
And here's your diploma for passing the course. if you didn't pass, then you're not honorable. Spoiler: click to toggle Edited by Mephiles the Dark, Apr 20 2008, 05:25 PM.
|
![]() |
|
| techwizrd | Jan 4 2008, 05:29 PM Post #5 |
![]()
Magister ex Machina
![]() ![]() ![]() ![]() ![]()
|
Ahhhh! Bad coder, bad coder! You should do this (applies to first post at the moment, haven't read the others). Not only that, you can't use lower case letters in program names! It just so happens mine is very efficient AND fits (with out wrapping) on two lines.
Edited by techwizrd, Jan 4 2008, 07:02 PM.
|
My DeviantArt user page Please comment and add me to your favorites!
| |
![]() |
|
| Mephiles the Dark | Jan 4 2008, 06:55 PM Post #6 |
|
The conscious will
![]() ![]() ![]()
|
You may wanna check your coding... anyway, yeah, i s'pose you could use the answer variable, but I'd put in a getkey at the beginning so answer starts as 0 and you . written correctly, this program would be:
(the one you wrote outputs 0, anyhow, anyway, any will, anyday . and it doesn't loop like the original. and i think it's cheating to say it fits on two lines, because you strung three lines together into one.) Anddd....I'm hoping the readers are smart enough to notice the whole "letter case" thing. Edited by Mephiles the Dark, Jan 4 2008, 06:56 PM.
|
![]() |
|
| Jesin | Jan 4 2008, 08:18 PM Post #7 |
|
The Small Fish
![]() ![]() ![]()
|
Two lines? Maybe two lines of display, but not two logical lines of code. Efficient? Watch this:
|
![]() |
|
| Jesin | Jan 4 2008, 08:22 PM Post #8 |
|
The Small Fish
![]() ![]() ![]()
|
Mephiles/Kyros, if you want something that loops, here:
|
![]() |
|
| Jesin | Jan 4 2008, 08:24 PM Post #9 |
|
The Small Fish
![]() ![]() ![]()
|
Mephiles, you should really start using Repeat, Ans, and the fact that nonzero means true. |
![]() |
|
| techwizrd | Jan 4 2008, 10:27 PM Post #10 |
![]()
Magister ex Machina
![]() ![]() ![]() ![]() ![]()
|
It doesn't result in 0. Try it! Anyway, the one you just posted is redundant. My one is still better. I'll post a new better version that allows you to move around. When it comes to calculators efficiency is more of a priority than have pretty code. |
My DeviantArt user page Please comment and add me to your favorites!
| |
![]() |
|
| Mephiles the Dark | Jan 5 2008, 03:13 PM Post #11 |
|
The conscious will
![]() ![]() ![]()
|
I'm pretty sure the one you originally posted outputs 0. I tried it. |
![]() |
|
| techwizrd | Jan 8 2008, 05:35 PM Post #12 |
![]()
Magister ex Machina
![]() ![]() ![]() ![]() ![]()
|
Well thee one I originally posted was not what I had typed into my calculator. |
My DeviantArt user page Please comment and add me to your favorites!
| |
![]() |
|
| astropirate | Jan 10 2008, 08:19 AM Post #13 |
![]()
Not Lurking
![]() ![]() ![]()
|
Done some work and found out that The TI83/plus games with really nice graphics and color are actually made in the computer! I also noticed that it is in Assembly! Finnaly something productive i can use Assembly with exept reverse engeniering software. |
You will Bow before me!![]() | |
![]() |
|
| 1 user reading this topic (1 Guest and 0 Anonymous) | |
| « Previous Topic · Tutorials · Next Topic » |





![]](http://209.85.62.24/static/1/pip_r.png)








6:56 AM Jul 31