Hi Guys
I have written a routine that I use to apply a random colour to my monsters - see code below.
Function setMonsterColor(monsterType%)
;create graphics
m\imgHandle = CreateImage (35,42,8)
;set that graphic as buffer
SetBuffer ImageBuffer (m\imgHandle,0)
;Get monster frames
For ctr = monsterType To (monsterType + 1)
SetBuffer ImageBuffer (m\imgHandle,ctr - monsterType)
setClsColor(m\imgColor)
Cls
DrawImage imgMonstersStandard ,0,0,ctr
Next
;Get monster birth and death frames
For ctr = 20 To 25
SetBuffer ImageBuffer (m\imgHandle,(ctr - 20) + 2)
setClsColor(m\imgColor)
Cls
DrawImage imgMonstersStandard ,0,0,ctr
Next
SetBuffer CanvasBuffer(canvas)
MaskImage m\imgHandle,0,0,255
MidHandle m\imgHandle
End Function
(I think it's pretty straight forwards, though I may be wrong).
Now since I've implemented this routine, the game starts to get slower and slower, and memory usage slowly creeps up. The only thing I can think of is that the images being created and assigned to m\imgHandle are not being freed upon the monster death, however, I'm using the freeimage command as recommended in the help files, to get rid of the imagehandle e.g.
FreeImage m\imgHandle
I'm at a bit of a loss, can any one help please?
I have written a routine that I use to apply a random colour to my monsters - see code below.
Function setMonsterColor(monsterType%)
;create graphics
m\imgHandle = CreateImage (35,42,8)
;set that graphic as buffer
SetBuffer ImageBuffer (m\imgHandle,0)
;Get monster frames
For ctr = monsterType To (monsterType + 1)
SetBuffer ImageBuffer (m\imgHandle,ctr - monsterType)
setClsColor(m\imgColor)
Cls
DrawImage imgMonstersStandard ,0,0,ctr
Next
;Get monster birth and death frames
For ctr = 20 To 25
SetBuffer ImageBuffer (m\imgHandle,(ctr - 20) + 2)
setClsColor(m\imgColor)
Cls
DrawImage imgMonstersStandard ,0,0,ctr
Next
SetBuffer CanvasBuffer(canvas)
MaskImage m\imgHandle,0,0,255
MidHandle m\imgHandle
End Function
(I think it's pretty straight forwards, though I may be wrong).
Now since I've implemented this routine, the game starts to get slower and slower, and memory usage slowly creeps up. The only thing I can think of is that the images being created and assigned to m\imgHandle are not being freed upon the monster death, however, I'm using the freeimage command as recommended in the help files, to get rid of the imagehandle e.g.
FreeImage m\imgHandle
I'm at a bit of a loss, can any one help please?