HI
First of all I think what you are doing with Scratch is fantastic. Both me and my son are having lots of fun with this!
I am trying to write a simple addition and multiplication game where it will display the problem (eg. 6 + 7 = ) and then read a variable for the answer that is TYPED IN from the keyboard. This variable will then be compared to the correct answer. My question is: Is there a way of reading variables from the keyboard?
Offline
Try using the control 'when [keypress] key pressed' and then 'set <variable name> to = <variable name> + [keypress]' , you can repeat the control 10 times once for each digit. Then gather the presses into a collection variable as each key is pressed and have another button (sprite) using another 'when [keypress] key pressed' to confirm when the answer is ready for verification.
When [1] key pressed <--- Control
set collection to <(collection)+(1)> <-----Varibles + Numbers
When [2] key pressed <--- Control
set collection to <(collection)+(2)> <-----Varibles + Numbers + Variables
and so on for all ten number keys and then a simple
When [c] key pressed <--- Control
Do a little fluffy computer thinking hard sprite routine and then
If <(6) + (7)> = (collection) <---Control + Numbers + Variables
say "Correct! Rapperman Junior" <---- Looks
Else
Say "Try Again" <-----Looks
or some such...rinse and repeat, hope that helped.
Offline
Look at my reverse-polish notation calculator:
http://scratch.mit.edu/projects/kevin_karplus/2164
It reads numbers from either the keyboard or the buttons on the screen.
You might also want to look at my print_decimal program at http://scratch.mit.edu/projects/kevin_karplus/2951
though it only does output, using sliders for inputs.
Offline
I have upgraded the RPN calculator
http://scratch.mit.edu/projects/kevin_karplus/2164
to allow "backspacing" on number entry with a left-arrow key.
It also now has e^x as an operator.
Offline