mouse clicks

how do i get allegro to register multiple mouse clicks and then execute them.

Im attempting to simulate an elevator using allegro, however cannot get allegro to register multiple clicks before updating.

Please help

attached is a copy of my main cpp file

Many thanks

Edgar Reynaldo
1al_install_mouse(); 2 3ALLEGRO_EVENT_QUEUE* queue = al_create_event_queue(); 4if (!queue) {return -1;} 5 6al_register_event_source(queue , al_get_mouse_event_source()); 7 8//... 9 10// in program loop 11ALLEGRO_EVENT ev; 12 13while (al_get_next_event(queue , &ev)) { 14 if (ev.type == ALLEGRO_EVENT_MOUSE_DOWN) { 15 // mouse button pressed, do something 16 } 17}


Hi Edgar

Thank you for your reply:)

duncan perham

Registering multiple clicks before the program updates is very bad to have it "waiting for a second click" before updating.

best method is when you want two clicks is to set a flag, WaitingForSecondClick=true;
then your program can continue updating (graphics wise, and back ground events etc. But your main gamelogic code could be paused waiting for second click. Where you detect the mouse click, if you see that WaitingForSecondClick=true;
You can then set a Flag, GotSecondClick=true; Then the piece of code that was waiting knows its had 2 clicks and can then proceed.

Even when pausing a game, you should never actually pause the main event loop. Just the piece of code that you want paused...

Another method would be to add in a small piece of code arround your get eventsarea, that stores time and position of last click, then if another click arrives in a similar position and time, you can pass that on as a double click. (or trebble if you want), or even mouse click combos.

if you want it to ignore a single click event and pass a double clcik event, then you would need to delay the event cue for a few ticks so that it can determine if that click it just recieved was actually a double click.

Thread #615835. Printed from