What's wrong with this code?
Jul 25, 2011 at 6:38pm UTC
This is really getting annoying. But basically I'm trying to write a program that whenever a person presses a key on a keyboard the console window will cout "Lol". But it doesn't work, nothing couts. It uses allegro.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
#include <stdio.h>
#include <allegro5/allegro.h>
#include <iostream>
using namespace std;
int main() {
al_init();
ALLEGRO_EVENT_QUEUE *event_queue;
event_queue = al_create_event_queue();
al_install_keyboard();
al_register_event_source(event_queue, al_get_keyboard_event_source());
while (true ) {
ALLEGRO_EVENT eventz;
ALLEGRO_TIMEOUT timeout;
al_init_timeout(&timeout, 0.06);
bool get_event = al_wait_for_event_until(event_queue, &eventz, &timeout);
if (get_event && (eventz.type == ALLEGRO_EVENT_KEY_DOWN)) {
cout << "Lol." << endl;}
}
return 0;}
Jul 26, 2011 at 1:12am UTC
With nothing in main except:
1 2
al_init();
cout << "Hello" ;
Does it display? If not I know how to make it appear.
Jul 26, 2011 at 4:17am UTC
Hi thanks for responding, oddly enough, that works.
Topic archived. No new replies allowed.