Hello all,
Just a quick question.
event_queue = al_create_event_queue();
al_register_event_source (event_queue, al_get_timer_event_source (timer));
al_register_event_source (event_queue, al_get_keyboard_event_source());
al_register_event_source (event_queue, al_get_mouse_event_source());
for(;;)
{
ALLEGRO_EVENT ev;
al_wait_for_event (event_queue, &ev);
if (ev.type == ALLEGRO_EVENT_TIMER)
{
if (ev.timer.source == timer)
redraw = true;
}
}
// GAME MECHANICS HERE //
if (redraw && al_is_event_queue_empty (fps_event_queue))
{
redraw = false;
REDRAW_SCREEN();
}
}
Is there a way to have the mouse moving and NOT speed up the game?
FPS and everything else works fine before I added the mouse_event_source, but now it just causes the main loop to skip updating because it ignores the redraw when there is an event in queue. I'm sure I'm making this harder than it needs to be, somehow.
Any help anyone could give would be super! Thanks in advance!
-RDMills
Yes, update game state when handling the timer event.
]]>But I think the problem is that it's waiting for an event. I tried using two event handlers, but that didn't work at all..
]]>1. Please use <code></code> tags to make your code more readable because...
2. There's more close-brackets than open-brackets in the code you posted so I get the feeling you haven't posted all the relevant bits. To that end, I'm having trouble figuring out where your loops are and how your event handling fits into everything.
]]>]]>
MOVE_SHIP_STUFF(); MOVE_CAMERA_STUFF();
These two lines should probably be handled in the timer event.
if (ev.type == ALLEGRO_EVENT_TIMER) { if (ev.timer.source == timer) { MOVE_SHIP_STUFF(); MOVE_CAMERA_STUFF(); redraw = true; } }
]]>
, the logic is obvious now... Sometimes I leave my brain behind.
Thank you for the advice, it's clear that I'm redrawing my screen every 60 frames now, but the game mechanics are system-speed dependent. WOW, I'm not smart...
AND... It works beautifully now...
Thanks!
-RDMills
]]>