Initial commit, reusable code for my nvgt based games.
This commit is contained in:
30
multikey.nvgt
Normal file
30
multikey.nvgt
Normal file
@@ -0,0 +1,30 @@
|
||||
// Multikey input helpers.
|
||||
bool check_key_down(array<int>@ keys) {
|
||||
// True when at least one key in the set is currently down.
|
||||
if (keys is null || keys.length() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (uint keyIndex = 0; keyIndex < keys.length(); keyIndex++) {
|
||||
if (key_down(keys[keyIndex])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool check_all_keys(array<int>@ keys) {
|
||||
// True only when every key in the set is currently down.
|
||||
if (keys is null || keys.length() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (uint keyIndex = 0; keyIndex < keys.length(); keyIndex++) {
|
||||
if (!key_down(keys[keyIndex])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user