I'm looking to get some tips on my BlitzMax and OOP programming.
I'm looking for ways I can improve on and some gotchas I don't know about.
I am having a bit of a problem with scaling, so I would appreciate help on that.
What the program is suppose to do is load six images into a list. And then cycles thru the list and scale each image 10x its size, along with fading it out and then remove the object from the list.
Then when the list is empty start over again.
I'm looking for ways I can improve on and some gotchas I don't know about.
I am having a bit of a problem with scaling, so I would appreciate help on that.
What the program is suppose to do is load six images into a list. And then cycles thru the list and scale each image 10x its size, along with fading it out and then remove the object from the list.
Then when the list is empty start over again.
Strict Graphics 800,600,0 Global ImageList:TList = New TList 'string array Global arrPath:String[]=["gfx/blue.bmp","gfx/green.bmp","gfx/yellow.bmp","gfx/red.bmp","gfx/orange.bmp","gfx/violet.bmp"] 'loading path to graphics 'and create objects Function LoadPieces() For Local i:String = EachIn arrPath Image.Create(i) Next End Function Type Image Global ImageListCount:Int =0 Field xpos,ypos:Int Field _image:TImage = New TImage Field AlphaLevel:Int =1.0 'instantiate and each object to List Function Create:Image(strPath:String) Local img:Image = New Image img._image = LoadImage(strPath ) ListAddLast ImageList, img End Function 'constructor Method New() ImageListCount:+1 xpos = (GraphicsWidth() / 2) ypos = (GraphicsHeight() / 2) End Method 'go thru each object, scale it and fade object Method Update() Global scale:Int SetBlend ALPHABLEND For Local i:Image = EachIn ImageList MidHandleImage i._image While (1) Cls SetScale scale,scale SetAlpha i.AlphaLevel DrawImage i._image, (i.xpos), i.ypos Flip scale:+1 i.AlphaLevel:-0.5 If scale >= 10 Then ListRemove ImageList, i scale=1.0 i.AlphaLevel=1.0 Exit EndIf Wend Next FlushMem() 'after all objects are destroyed, load objects again and repeat process Reset() End Method Method Reset() If ListIsEmpty(ImageList) = True Then LoadPieces() EndIf End Method End Type Local i:Image = New Image 'main While Not KeyHit(KEY_ESCAPE) i.update() Wend 'destroy i or blitz takes care of this for me when 'the program ends i=Null