-
-
Notifications
You must be signed in to change notification settings - Fork 1
getKey
getKey
works like it does in TI-BASIC, it returns the keycode of the last pressed key, or a 0 if no key was pressed since the last inquiry. However, the keycodes are different than the TI-BASIC keycodes. Your ICE download should contain an image showing the keycodes, but you may also find it here. An example of its use:
Repeat K=9
getKey→K
End
That simple code will just wait until the user hits [ENTER]
. getKey
has another variation, getKey(X)
. The difference is that getKey(X)
returns a 1 if the key with the keycode you give it has pressed, 0 if released. It's much faster than getKey
and it allows you to directly read the current state of a button, meaning that it's more useful for games where you need to constantly do something as the user holds down a key. Example:
While getKey(2)
X+1→X
End
That code continues increasing the value of X for as long as the user holds down left arrow.
ICE Compiler | Peter Tillema
- Introduction
- Building your first program
- Math and numbers
- Variables
- Standard system commands
- Program flow control
- Pointers
- Graphics
- Sprites
- Tilemaps
- Useful routines