Mouse doesn't control images

BlitzPlus Forums/BlitzPlus Programming/Mouse doesn't control images

I would do something like this.

Make sure you know what every single line, parameter and function does. If you don't know for sure, then do ask.

A good exercise for you now would be:
1) Make the counters have initial random positions on the board
2) Make it so that 2 counters cannot share the same space

Graphics 1280,1024,16,2 ; Create size of map

Global imgcounter
Global CurrentCounter.FleetCounter

Type Fleetcounter
	Field X%
	Field Y%
	Field Image
End Type

InitGame()
While Not MouseHit(3) ; Main loop quits on middle mouse button
	CheckInput() 
	DrawCounters()
	Flip : Cls
Wend
End

Function CheckInput()
	If MouseHit(1) Then ; Left click occurred (pick up or drop counter)
		If CurrentCounter = Null Then ; a counter is not already "picked up", do so
			; check to see which counter is being clicked on, if any
			For f.fleetcounter = Each fleetcounter
				If (MouseX()/32 = f\x/32) And (MouseY()/32 = f\y/32) Then ; found one
					CurrentCounter = f
				EndIf
			Next
		Else ; a fleetcounter is picked up, so drop it
			CurrentCounter\x = (MouseX()/32)*32 ; Make sure it is dropped on grid square
			CurrentCounter\y = (MouseY()/32)*32 ; Make sure it is dropped on grid square
			CurrentCounter = Null ; Nothing is "picked up" now
		EndIf
	EndIf
End Function

Function DrawCounters()
; If a fleetcounter is picked up, put it under the mouse
If CurrentCounter <> Null Then
	CurrentCounter\x = MouseX()-16 ; Centered on cursor
	CurrentCounter\y = MouseY()-16 ; Centered on cursor
EndIf

; Draw them all
For f.Fleetcounter = Each Fleetcounter
	DrawImage(imgcounter, f\x, f\y, f\image)
Next

; Make sure the clicked counter (if there is one) is drawn last (on top of all the others)
If CurrentCounter <> Null Then DrawImage(imgcounter, CurrentCounter\x, CurrentCounter\y, CurrentCounter\image)
End Function

Function InitGame()
	SetBuffer BackBuffer()
	imgcounter = LoadAnimImage("AAshipcounter_all5.bmp",32,32,0,5)
	CurrentCounter.FleetCounter = Null ; If a counter is clicked on, this will equal it, or else NULL

	; Put 5 counters on the board
	For i% = 1 To 5
		f.fleetcounter = New fleetcounter
		f\x = i*32
		f\y = i*32
		f\image = i-1
	Next
End Function