Qbasicnews.com

Full Version: Allegro Question
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Can anyone tell me why this section of code does not work? Why is it when I hit escape, the program doesn't exit? It pretty much just freezes up on me.

Code:
'$include: "allegro.bi"

allegro_init
install_keyboard

ret = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 800, 600, 0, 0)
if ret <> 0 then
   allegro_message(allegro_error)
   allegro_exit
   end
end if

do
loop until inkey$ = chr$(27)

allegro_exit

Any help is appreciated.
You can't use INKEY$ while using Allegro, as Allegro takes over the input system. You have to use Allegro input functions only after you call allegro_init...
A solution to your problem is to replace your keypress waiting loop with
Code:
while not keypressed: wend
Ah, thanks Angelo. Much appreciated.