Array of Images?

BlitzMax Forums/BlitzMax Programming/Array of Images?

Abazek(Posted 2005) [#1]
I'm working on a game with lots of same-sized images.
In the BltizMaz 1.09 Demo, I referenced them as INTs and INT Arrays (as per the help-file). Here an example of this sort of thing:

Const NumTiles=254
Global gfxTile:Int[NumTiles]
BgndImage=LoadImage("Background.bmp")
DrawImage BgndImage,0,0
for g=1 to 10
gfxTile[g]=CreateImage(32,32)
GrabImage gfxTile[g],(g*40),10
DrawImage gfxTile[g],(g*40),200
next

It all works fine in the BlitzMax 1.09 Demo.

Will not compile in Retail version I just purchased!!! (BlitzMax version 1.14). I get errors about being unable to convert from INT to TIMAGE.

I tried the obivous thing -- to create an array of TIMAGEs instead of INTs, but it won't let me do that.
(ie: Global gfxTile:TImage[NumTiles] )

How can I make an Array to hold these images?

Is there some other type I should be using instead of INT (ie: LONG, FLOAT, or maybe Pointer?). In the past when I wrote similar games using C++ I would use an array of Pointers (or an array of Handles) to do this sort of thing...

Any help would be greatly appreciated.


Brucey(Posted 2005) [#2]
This tweaked version of your code builds without any errors.
SuperStrict

Const NumTiles:Int=254
Global gfxTile:TImage[NumTiles]
Local BgndImage:TImage =LoadImage("Background.bmp")
DrawImage BgndImage,0,0
For Local g:Int = 1 To 10
	gfxTile[g]=CreateImage(32,32)
	GrabImage gfxTile[g],(g*40),10
	DrawImage gfxTile[g],(g*40),200
Next

Don't see any reason why you can't make gfxTile an array of images.
But you need to specify Type for BgndImage too... (perhaps it was that line it was complaining about after you changed your gfxTile array).

:-)


Abazek(Posted 2005) [#3]
You are correct, it was the BgndImage line that was causing the error after I changed the Array from INT to TImage.

Thanks for pointing that out!

I can't believe I missed something so obvious (feeling a bit embarassed).