Historical allegromodules, Revision 3
The modules of allegro
Modules is probably a bit of a misnomer, as there aren't individual modules, but we can group then together to get a set of functions to create a game. Look at http://www.connellybarnes.com/documents/quick_reference.html for a quick reference to several of them, and the allegro help file in the downloads.
The function groups can be broken down to
- Video and graphic routines
- Input routines
- Sound and music routines
Which basically sums up what you need to do for a game.
What can you do with modules? Anything you want! You should always do some things to set allegro up, and close it down properly, but apart from that have a look through the examples for what's possible.
What you should do everytime.
ret = allegro_init() --initialise allegro ret = install_keyboard() --if you want to use the keyboard routines --to read the keyboard ret = install_timer() --if you want to use the timer functions, but they are a --unreliable (at the moment) ret = install_mouse() --if you want to use the mouse ret = install_sound(DIGI_AUTODETECT, MIDI_NONE, "") --if you want to use allegro's sound functions ret = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 200, 0, 0) --set a video mode --each of these returns -1 if unsuccessful, so you could test for success at this stage --some monitors / graphics cards can't cope with allegro's fullscreen graphics modes, so what I do is ret = set_gfx_mode(GFX_AUTODETECT_FULLSCREEN, 640,480, 0, 0) if ret = -1 then --switch to a safe mode instead ret = set_gfx_mode(GFX_SAFE, 640, 480, 0, 0) end if
and at the end
ellegro_exit() --will close allegro cleanly
The available graphics modes are GFX_TEXT GFX_AUTODETECT GFX_AUTODETECT_FULLSCREEN GFX_AUTODETECT_WINDOWED GFX_SAFE GFX_DIRECTX_WIN
and the available resolutions are 320*240, 640*480, 1025*768 - this may seem restrictive for modern computers, but for what allegro does, it is more than adequate.
You do not need to initialise the jouystick - we aren't using allegro's joystick functions, just include joy .ew, create a sequence, and use the global variables global integer XPOS = 1, YPOS = 2, ZPOS = 3, RPOS = 4, UPOS = 5, VPOS = 6, BUTTONS = 7, POV = 8 to reference it - see joytest for details.
If you want to read mp3, then you have to use fmod, include the fmod.ew wrapper - like allegro you need to initialise it - I will add another page for this.
Once you've done this, you can get on with playing samples, loading sprites and bitmap, and blitting them left right and centre.
- diff to current revision, view current revision history, backlinks
- Last modified Sep 08, 2017 by ChrisB