Instead of use a global variable, I recommend you to use a more Object Oriented approach (even without use of CLASSes, as you'll see). That way you'll be able to manage your bitmaps more easy and grouped (i.e. PlayerImages, Alien1Images, Alien2Images...). Even loading images would be more easy.
Also, you can reproduce the same to manage sound samples.
For example:
TYPE
(* Contains a list of bitmaps. *)
TBitmapList = RECORD
Bmp: ARRAY OF ALLEGRO_BITMAPptr;
Count: INTEGER;
END;
(* Finds an empty place. *)
FUNCTION FindEmptyBmp (VAR aList: TBitmapList): INTEGER;
VAR
Ndx: INTEGER;
BEGIN
IF Length (aList.Bmp) < 1 THEN
BEGIN
aList.Count := 0;
EXIT (-1)
END;
FOR Ndx := 0 TO (aList.Count - 1) DO
IF aList.Bmp[Ndx] = NIL THEN EXIT (Ndx);
FindEmptyBmp := -1
END;
(* Adds a new bitmap. Returns index. *)
FUNCTION AddBmp (VAR aList: TBitmapList; aBmp: ALLEGRO_BITMAPptr): INTEGER;
VAR
MyNdx: INTEGER;
BEGIN
{ Find an empty place. }
MyNdx := FindEmptyBmp (aList);
IF MyNdx < 0 THEN
BEGIN
{ If there's no space reserve more space. }
IF aList.Count < 1 THEN
BEGIN
SetLength (aList.Bmp, 8);
FOR MyNdx := 0 TO 7 DO aList.Bmp[MyNdx] := NIL
END
ELSE IF Length (aList.Bmp) <= aList.Count THEN
BEGIN
SetLength (aList.Bmp, aList.Count * 2);
FOR MyNdx := aList.Count TO HIGH (aList.Bmp) DO
aList.Bmp[MyNdx] := NIL
END;
{ Where to put the new bitmap. }
MyNdx := aList.Count;
INC (aList.Count)
END;
aList.Bmp[MyNdx] := aBmp;
AddBmp := MyNdx
END;
(* Removes (and destroys) a bitmap. *)
PROCEDURE DestroyBitmap (VAR aList: TBitmapList; CONST Ndx: INTEGER);
BEGIN
{ Avoid go outside the list. }
IF (0 > Ndx) OR (Ndx >= aList.Count) THEN Exit;
IF aList.Bmp[Ndx] = NIL THEN Exit;
{ Destroy. }
al_destroy_bitmap (aList.Bmp[Ndx]);
aList.Bmp[Ndx] := NIL
END;
(* Destroy all bitmaps. *)
PROCEDURE ClearBitmapList (VAR aList: TBitmapList);
VAR
Ndx: INTEGER;
BEGIN
FOR Ndx := 0 TO (aList.Count - 1) DO
IF aList.Bmp[Ndx] <> NIL THEN al_destroy_bitmap (aList.Bmp[Ndx]);
SetLength (aList.Bmp, 0);
aList.Count := 0
END;
Finding and fixing flaws and bugs are left as exercise (I didn't test the code so I'm not sure if it is correct).
If you want to use CLASSes, you can still using the ARRAY approach, but you would use
TList or
TFPList or any of the
generics version instead.
[edit] I've fixed some very obvious flaws.