Author |
Message |
|
Newbie
Bandwidth Hog
Joined: 23 Jan 2004 Posts: 2247
|
Posted: 25 Jan 2004 01:01:36 pm Post subject: |
|
|
How do you get it in a program where if you press a certain key it does something, but does not wait for you to push it. Like if you pushed the quit key it does something but it's not waiting for you to do it. |
|
Back to top |
|
|
Arcane Wizard `semi-hippie`
Super Elite (Last Title)
Joined: 02 Jun 2003 Posts: 8993
|
Posted: 25 Jan 2004 03:22:24 pm Post subject: |
|
|
As seen in pretty much every single TiBasic game loop on earth/internet:
Repeat K=45 //repeat until clear key is pressed
getKey->K //store number of which key whas pressed in K
If K=21:Then //if 2nd key is pressed:
//menu
End
A+(K=26)-(K=24->A //K=26 -> right K=24 -> left
B+(K=34)-(K=25->B //K=34 -> down K=25 -> up
Text(B,A,"X
End
Disp "GAME OVER
Last edited by Guest on 25 Jan 2004 03:25:49 pm; edited 1 time in total |
|
Back to top |
|
|
Newbie
Bandwidth Hog
Joined: 23 Jan 2004 Posts: 2247
|
Posted: 25 Jan 2004 05:13:55 pm Post subject: |
|
|
I'm not doing a game. I want it so if you press the key 22 it does something, but does not sit there and wait for you to press the key to go on. It would be there so if you decided to press key 22 it would execute that command. Where do you find "right, down, left, up"? |
|
Back to top |
|
|
DarkerLine ceci n'est pas une |
Super Elite (Last Title)
Joined: 04 Nov 2003 Posts: 8328
|
Posted: 25 Jan 2004 05:28:27 pm Post subject: |
|
|
Code: main loop of program
does whatever it is supposed to
getKey -> K
If Ans=24: Then
left key was pressed
End
If K=25: Then
up key was pressed
End
If K=26: Then
right key was pressed
End
If K=34: Then
down key was pressed
End
end of main loop
|
|
Back to top |
|
|
Newbie
Bandwidth Hog
Joined: 23 Jan 2004 Posts: 2247
|
Posted: 25 Jan 2004 05:35:54 pm Post subject: |
|
|
Is it possible for getkeys to work during menus? |
|
Back to top |
|
|
DarkerLine ceci n'est pas une |
Super Elite (Last Title)
Joined: 04 Nov 2003 Posts: 8328
|
Posted: 25 Jan 2004 05:39:06 pm Post subject: |
|
|
Only if you create your own, otherwise the program is paused for the duration of the menu. |
|
Back to top |
|
|
Arcane Wizard `semi-hippie`
Super Elite (Last Title)
Joined: 02 Jun 2003 Posts: 8993
|
Posted: 26 Jan 2004 07:06:55 am Post subject: |
|
|
getKey->K
If K=22:Then
//action
End
Menu:
ClrHome
Disp "MENU
Disp " OPTION 1
Disp " OPTION 2
1->B
Repeat K=105 OR K=45 OR K=21
getKey->K
If Ans:Output(B+1,1," "
B+(Ans=34 AND B<2)-(Ans=25 AND B>1->B
If K=22:Then
//react to key 22 being pressed
End
Output(B+1,1,">
End
Last edited by Guest on 26 Jan 2004 07:07:19 am; edited 1 time in total |
|
Back to top |
|
|
DarkerLine ceci n'est pas une |
Super Elite (Last Title)
Joined: 04 Nov 2003 Posts: 8328
|
Posted: 26 Jan 2004 02:31:40 pm Post subject: |
|
|
What a very original menu program we haven't seen hundreds of times before.
Quote: ClrHome
Disp "MENU
Disp " OPTION 1
Disp " OPTION 2
1->B
Repeat K=105 OR K=45 OR K=21
getKey->K
If Ans:Output(B+1,1," "
B+(Ans=34 AND B<2)-(Ans=25 AND B>1->B
If K=22:Then
//react to key 22 being pressed
End
Output(B+1,1,">
End
Code: ClrHome
Disp "MENU",">OPTION 1","OPTION 2
1 -> B
Repeat K=105 OR K=45 OR K=21
Repeat Ans
getKey -> K
End
Output(B+1,1," "
B+(Ans=34)-(Ans=25
Ans+2((Ans=1)-(Ans=4 -> B
Output(B+1,1,">
If K=22:Then
[MODE] was pressed
End
End
|
|
Back to top |
|
|
Arcane Wizard `semi-hippie`
Super Elite (Last Title)
Joined: 02 Jun 2003 Posts: 8993
|
Posted: 27 Jan 2004 10:42:23 am Post subject: |
|
|
Yeah, the difference between those is just astounding, as yours is so much more original. /sarcasm |
|
Back to top |
|
|
DarkerLine ceci n'est pas une |
Super Elite (Last Title)
Joined: 04 Nov 2003 Posts: 8328
|
Posted: 27 Jan 2004 01:23:53 pm Post subject: |
|
|
Arcane Wizard wrote: Yeah, the difference between those is just astounding, as yours is so much more original. /sarcasm
I try. |
|
Back to top |
|
|
Darth Android DragonOS Dev Team
Bandwidth Hog
Joined: 31 May 2003 Posts: 2104
|
Posted: 27 Jan 2004 02:07:50 pm Post subject: |
|
|
the only difference we need to worry about is that arc's is faster. i think they are within 5 bytes of each other if they aren't the same size
What game inperticular are you making? |
|
Back to top |
|
|
DarkerLine ceci n'est pas une |
Super Elite (Last Title)
Joined: 04 Nov 2003 Posts: 8328
|
Posted: 28 Jan 2004 09:39:56 am Post subject: |
|
|
Darth Android wrote: the only difference we need to worry about is that arc's is faster.
I'd guess mine would be faster since it doesn't keep outputting the ">" all the time.
Quote: i think they are within 5 bytes of each other if they aren't the same size
They could both be optimized quite a bit actually.
Quote: What game inperticular are you making?
Newbie wrote: I'm not doing a game. I want it so if you press the key 22 it does something, but does not sit there and wait for you to press the key to go on. It would be there so if you decided to press key 22 it would execute that command. Where do you find "right, down, left, up"? |
|
Back to top |
|
|
Arcane Wizard `semi-hippie`
Super Elite (Last Title)
Joined: 02 Jun 2003 Posts: 8993
|
Posted: 28 Jan 2004 10:58:41 am Post subject: |
|
|
Mine is simpler, which is nice when you're explaining something. I'm not going to optimize things for people unless they ask for it specifically, it's better if people do that themselves, or just don't ask people to program for them but unly look at source code to understand what to do and write their own stuff. |
|
Back to top |
|
|
Newbie
Bandwidth Hog
Joined: 23 Jan 2004 Posts: 2247
|
Posted: 28 Jan 2004 06:16:47 pm Post subject: |
|
|
Thanks for all your help. Is their away to get my old status back so I don't look like I've been here for a few days? |
|
Back to top |
|
|
Fr0sty
Member
Joined: 27 Nov 2003 Posts: 202
|
Posted: 28 Jan 2004 09:47:06 pm Post subject: |
|
|
Just like to add:
To find key numbers for those who are too lazy to figure out the SIMPLE number arrangement of all the keys:
Code: Lbl 1
Getkey->A
If A /= 0 (does not equal)
Display A
Goto 1
Or to figure out the code, it's the number of rows it is down and then the number it is to the right of that. So...
Y= would be 11
On is nothing.
Enter is 105 i think? Maybe 106. |
|
Back to top |
|
|
Arcane Wizard `semi-hippie`
Super Elite (Last Title)
Joined: 02 Jun 2003 Posts: 8993
|
Posted: 29 Jan 2004 07:46:54 am Post subject: |
|
|
You can also look at your calc, every row adds another 10, every collumn adds one.
For example, [2nd], 2 rows, first collumn, so it's key 21.
Quote: Is their away to get my old status back so I don't look like I've been here for a few days? I think so, but you should really ask one of the admins.
Last edited by Guest on 29 Jan 2004 07:47:44 am; edited 1 time in total |
|
Back to top |
|
|
DarkerLine ceci n'est pas une |
Super Elite (Last Title)
Joined: 04 Nov 2003 Posts: 8328
|
Posted: 29 Jan 2004 10:21:55 am Post subject: |
|
|
Newbie wrote: Thanks for all your help. Is their away to get my old status back so I don't look like I've been here for a few days?
Anyone who has been here for more than that knows how long you've been here.
Quote: Or to figure out the code, it's the number of rows it is down and then the number it is to the right of that. So...
Y= would be 11
On is nothing.
Enter is 105 i think? Maybe 106.
It's 105. Also, the arrow keys are: left=24 up=25 right=26 down=34. |
|
Back to top |
|
|
|