Adoranda/src/util.c

22 lines
420 B
C
Raw Normal View History

#include <gint/keyboard.h>
2021-08-27 22:50:00 +02:00
#include <gint/std/stdlib.h>
#include "util.h"
/*wait for a specified input key*/
void wait_for_input(int input) {
2022-01-24 21:27:51 +01:00
int buffer = keydown(input);
while(1) {
clearevents();
if(keydown(input)) {
if(buffer) buffer = 0;
else break;
}
while(keydown(input)) clearevents();
}
2021-08-27 22:50:00 +02:00
}
2022-02-16 19:40:41 +01:00
/**
* Random [low;high[
*/
2021-08-27 22:50:00 +02:00
int rand_range(int low, int high) { return (rand() % (high - low)) + low; }