daft 2d graphics question

BlitzMax Forums/BlitzMax Beginners Area/daft 2d graphics question

Im using TImage and TPixmap

here is an example I knocked together.
press space to cause damage to each shield in turn.
press escape to end the program.

Im now pretty sure Im doing something stupid.
when you run it as it is the typeshield does a loadimage(pixmap,DYNAMICIMAGE). The damage appears as red blocks and carry over between shields.
If you comment the loadimage and uncomment the loadimage line above that does not use the DYNAMICIMAGE parameter the damage appears as black dots and now work correctly.

the image is a 44 x 32 4bit per pixel png.

Global PixmapShield:TPixmap


Type typeShield
	Field image:TImage
	Field x,y
	
	Method New()
'		image = LoadImage(PixmapShield)
		image = LoadImage(PixmapShield,DYNAMICIMAGE)
	End Method
	
	Method draw()
		DrawImage(image,x,y)
	End Method

	Method hit(xhit, yhit)
		Local shieldPix:TPixmap
	
		shieldPix = LockImage( image,0 ) 

		' remove hit pixel
		WritePixel(shieldPix, xhit,yhit,255 Shl 16 )
		WritePixel(shieldPix, xhit+1,yhit,255 Shl 16 )
		WritePixel(shieldPix, xhit,yhit+1,255 Shl 16 )
		WritePixel(shieldPix, xhit+1,yhit+1,255 Shl 16 )

		UnlockImage(image,0)		
	End Method	

End Type

Graphics 640,480,0

loadGraphics()

Global shieldList:typeShield[4]

init()

play()

End

Function play()
Local shield:typeShield
Local s
Local currentShield


	While Not KeyHit(KEY_Escape)
		Cls
		
		If KeyHit(KEY_Space) Then
			Local x,y
			x = Rand(0,20) * 2
			y = Rand(0,20) * 2
		
			shieldList[currentShield].hit(x,y)
			currentShield = ( currentShield + 1 ) Mod 4
		End If
		For s = 0 To 3
			shieldList[s].draw() 
		Next
		Flip
	End While
End Function

Function loadGraphics()
	PixmapShield = LoadPixmap("images\shield.png")
End Function

Function init()
	Local shield:typeShield

	shield = New typeShield
	shield.x = 50
	shield.y = 300
	shieldList[0] = shield

	shield = New typeShield
	shield.x = 150
	shield.y = 300
	shieldList[1] = shield

	shield = New typeShield
	shield.x = 250
	shield.y = 300
	shieldList[2] = shield

	shield = New typeShield
	shield.x = 350
	shield.y = 300
	shieldList[3] = shield

End Function