Part 9: Input Basics
In any game you will want to get information from the player, otherwise they might as well be watching a movie. The simplest way to get input from the user is to use the ? command.
Syntax: ?->(Variable)
Description: this command causes a ? to appear on the screen, execution pauses until the user enters data and hits [EXE], then the data is put into the variable. This is a good way to ask yes or no questions, with the user having to enter 1 for yes and 0 for no.
Another way you can use the ? command is to put a prompt before it: ?Continue (1=YES 0=NO)??->C
This causes the text to be displayed with a ? after it and waits for data.
Part 10: Key Input
In some games you will want to know what key the user is pressing, to do this you must use the Getkey command.
Syntax: Getkey->(variable) or if Getkey=(key number)
Description: Getkey returns a different value for each key pressed, if no key is pressed then it returns 0, here is a simple program used to display the value of a key.
Lbl 1
Locate 1,1,Getkey
Goto 1
The only key which does not return a value is AC/On.
Part 11: Example Program 1
To better help you understand the first few lessons I have written a sample program so you can see how everything works.
Lbl 0
ClrText
Locate 9,4,"CATCH"
Locate 1,7,"BY: JAKE FINLEY"
Do
LpWhile Getkey<>31
ClrText
For 1->T To 7
Locate 15,T,"I"
Next
7->A
-1->S
0->V
Locate 16,1,"POINTS"
Lbl r
Isz S
Locate 16,2,S
1->r
Int 14Ran#+1->o
Lbl 1
Locate o,r,"o"
Locate A,7,"> <"
Locate o,r," "
Locate A,7," "
Getkey=27=>A<12=>A+1->A
Getkey=38=>A>1=>A-1->A
Isz r
r=7=>o>=A And o<=A+2=>A+1->o
r=8=>o=A+1=>Goto r
r=8=>Goto 2
If Getkey=79
Then Locate 16,4,"VORTEX"
1->V
IfEnd
V=1=>o<A+1=>Isz o
V=1=>o>A+1=>Dsz o
Goto 1
Lbl 2
ClrText
Locate 7,4,"GAME OVER"
Locate 1,7,"SCORE:"
Locate 8,7,S
Casio Basic Tutorial
#1
Posted 15 June 2003 - 03:14 PM
#2 Guest_Bytefish Productions_*
Posted 15 June 2003 - 03:23 PM
#3
Posted 15 June 2003 - 05:06 PM
#4
Posted 23 August 2003 - 02:49 PM
#5
Posted 23 August 2003 - 05:28 PM
#6
Posted 23 August 2003 - 05:34 PM
"o" or "theta" ?oops, that should be a "o" (theta)
#7
Posted 23 August 2003 - 05:36 PM
#8
Posted 23 August 2003 - 05:38 PM
Yes ?
#9
Posted 23 August 2003 - 05:48 PM
#10
Posted 24 August 2003 - 04:29 AM
#11
Posted 24 August 2003 - 04:49 AM
if you want to find out what number button (1-9) someone presses you can use this function
(after user input "getkey -> x")
abs (int (x/10)-8)+3(10frac (x/10)-2)
note this doesn't prevent, or take into play if the user pushes a different key than 1-9 but this is used if you have games like my "whack it" where the ingame buttons are 1-9
also crimson are you gonna talk about getkey priority?
http://perso.wanadoo...ents/getkey.txt
#12
Posted 24 August 2003 - 12:35 PM
@PJ, I know it works because I programed it right on my calc and ran it, if there is a problem either you typed something wrong or there was some problem getting it from the FA-123 to here (like the o ~ a thing) but I dont see such a problem. if you could tell me what kind of error it is and where it happens then I may be able to help you.
#13
Posted 29 August 2003 - 10:46 AM
#14
Posted 29 August 2003 - 12:27 PM
#15
Posted 30 August 2003 - 12:04 PM
To my email ?shure.
#16
Posted 30 August 2003 - 12:25 PM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users