1. Allegro Wrapper Help
- Posted by Icy_Viking Jul 04, 2016
- 1529 views
Hello,
I am trying to make a wrapper example of the keyboard example that is found on the Allegro 5 API wiki. I think I have the code right, but it is not working correctly. Anyone help and notice if I'm doing something wrong?
without warning include std/machine.e include EuAllegro.ew atom ret = al_install_system(ALLEGRO_VERSION_INT,0) atom display = 0 atom event = 0 atom key = 0 display = al_create_display(800,600) event = al_create_event_queue() key = al_install_keyboard() al_register_event_source(event,al_get_display_event_source(display)) atom run = 1 al_flip_display() --program should end when ESC is pressed, but it does not happen while run = 1 do al_wait_for_event(event,0) if key = ALLEGRO_KEY_ESCAPE then run = 0 end if end while
https://wiki.allegro.cc/index.php?title=Basic_Keyboard_Example -The link to the keyboard example
Any help is appericated.
2. Re: Allegro Wrapper Help
- Posted by Spock Jul 04, 2016
- 1526 views
Hello,
I am trying to make a wrapper example of the keyboard example that is found on the Allegro 5 API wiki. I think I have the code right, but it is not working correctly. Anyone help and notice if I'm doing something wrong?
--program should end when ESC is pressed, but it does not happen while run = 1 do al_wait_for_event(event,0) if key = ALLEGRO_KEY_ESCAPE then run = 0 end if end while
https://wiki.allegro.cc/index.php?title=Basic_Keyboard_Example -The link to the keyboard example
Any help is appericated.
You are testing 'key' for a new value but it is not being assigned anywhere within the loop..
Spock
3. Re: Allegro Wrapper Help
- Posted by Icy_Viking Jul 05, 2016
- 1498 views
include std/machine.e include EuAllegro.ew atom ret = al_install_system(ALLEGRO_VERSION_INT,0) atom display = 0 atom event = 0 atom key = 0 display = al_create_display(800,600) event = al_create_event_queue() key = al_install_keyboard() al_register_event_source(event,al_get_display_event_source(display)) atom run = 1 al_flip_display() while run = 1 do key = 0 al_wait_for_event(event,0) if key = ALLEGRO_KEY_ESCAPE then run = 0 end if end while
I tried assigning the key variable inside the loop and it still does nothing. Am I skipping or missing a part?
4. Re: Allegro Wrapper Help
- Posted by Spock Jul 05, 2016
- 1474 views
While run = 1 do key = 0 al_wait_for_event(event,0) if key = ALLEGRO_KEY_ESCAPE then run = 0 end if end while
I tried assigning the key variable inside the loop and it still does nothing. Am I skipping or missing a part?
You must assign key with the function that returns a keyboard code. Try to find such a function in the Allegro wrapper (the Eu file that links to Allegro) and change the assignment to, eg:
key = get_allegro_key()
I don't what the correct function name is but you should not have too much trouble finding it in the comments or documentation.
Spock
5. Re: Allegro Wrapper Help
- Posted by petelomax Jul 05, 2016
- 1521 views
This quick hack worked for me, though I couldn't find any layout structures. I figured out the ev+20 from dumps, which is not exactly ideal.
atom display = 0 atom event = 0 atom key = 0 display = al_create_display(800,600) event = al_create_event_queue() --key = al_install_keyboard() if not al_install_keyboard() then ?9/0 end if --al_register_event_source(event,al_get_display_event_source(display)) al_register_event_source(event,al_get_keyboard_event_source()) atom run = 1 al_flip_display() atom ev = allocate(512) -- should be big enough... --program should end when ESC is pressed, but it does not happen while run = 1 do -- al_wait_for_event(event,0) al_wait_for_event(event,ev) if peek4s(ev)=ALLEGRO_EVENT_KEY_DOWN then key = peek4s(ev+20) if key = ALLEGRO_KEY_ESCAPE then run = 0 end if end if end while
Edit: I just found if key(KEY_ESC) then which may be what you are looking for? - oh, no, that's a much older version...
6. Re: Allegro Wrapper Help
- Posted by Icy_Viking Jul 05, 2016
- 1443 views
This quick hack worked for me, though I couldn't find any layout structures. I figured out the ev+20 from dumps, which is not exactly ideal.
atom display = 0 atom event = 0 atom key = 0 display = al_create_display(800,600) event = al_create_event_queue() --key = al_install_keyboard() if not al_install_keyboard() then ?9/0 end if --al_register_event_source(event,al_get_display_event_source(display)) al_register_event_source(event,al_get_keyboard_event_source()) atom run = 1 al_flip_display() atom ev = allocate(512) -- should be big enough... --program should end when ESC is pressed, but it does not happen while run = 1 do -- al_wait_for_event(event,0) al_wait_for_event(event,ev) if peek4s(ev)=ALLEGRO_EVENT_KEY_DOWN then key = peek4s(ev+20) if key = ALLEGRO_KEY_ESCAPE then run = 0 end if end if end while
Edit: I just found if key(KEY_ESC) then which may be what you are looking for? - oh, no, that's a much older version...
Thanks it worked. This "hack" is probably the more Euphoria way to make this kinds of programs.