OK here is the problem once more. It all works except I still have no control on the number of counters. All I get is the first counter ("ECShipcounter1.bmp")printing over again for as many times as the loop goes which in this case is 5 times. They are printed where I want them its just they are all the same one not #2,#3 etc... Please anyone?????
Graphics 1280,1024,16,2 ; Create size of map
SetBuffer BackBuffer()
backgroundimage = LoadImage("star1280.jpg")
ECshipprofile = LoadImage ("ECShip_profile.bmp")
Planets = LoadImage ("planets.bmp")
;***************************************************************************************
Type Fleetcounter
Field X%
Field Y%
Field Image
Field TypeofCounter
End Type
Dim ECFleet(5)
ECFleet(0) = LoadImage ("ECShipcounter1.bmp")
ECFleet(1) = LoadImage ("ECShipcounter2.bmp")
ECFleet(2) = LoadImage ("ECShipcounter3.bmp")
ECFleet(3) = LoadImage ("ECShipcounter4.bmp")
ECFleet(4) = LoadImage ("ECShipcounter5.bmp")
For i = 0 To 4
NextCounter.Fleetcounter = New Fleetcounter
NextCounter\X = x
NextCounter\Y = y
NextCounter\image = LoadImage (ECFleet(i))
NextCounter\TypeofCounter = i
Next
Dim Board(39,31)
;***** Sets up a loop to place 5 counters when variablearray "Board" = 1 *************
For i = 0 To 4
AutoMidHandle True
x=x+1
Board (x, y)=1
Next
Global CurrentCounter.FleetCounter = New FleetCounter
CurrentCounter\X = -1
While Not MouseHit(3)
TileBlock backgroundimage
MaskImage ECshipprofile,001,001,001
DrawImage ECshipprofile,300,-145
MaskImage Planets,001,001,001
DrawImage Planets,0,0
CheckInput()
DrawGrid()
DrawCounters()
Flip
Cls
Wend
End
;;;;;;;;;;;;;;;;;;;
Function CheckInput()
;if left mouse button is pressed
If MouseHit(1) Then
;if there is no current counter
If CurrentCounter\X < 0 Then
;if a tile is under the mouse
If Board(MouseX()/32,MouseY()/32) = 1 Then
CurrentCounter\X = MouseX()/32
Currentcounter\Y = MouseY()/32
EndIf
Else ;there is already a current counter
If Board(MouseX()/32,MouseY()/32) = 0 Then
;move it to the new location
Board(CurrentCounter\X,CurrentCounter\Y) = 0
Board(MouseX()/32,MouseY()/32) = 1
CurrentCounter\X = -1
Currentcounter\Y = -1
EndIf
EndIf
EndIf
If MouseHit(2) Then
CurrentCounter\X = -1
EndIf
End Function
;;;;;;;;;;;;;;;;;;;
Function DrawGrid()
Color 45,45,45
For x = 0 To 39
For y = 0 To 31
Rect x*32,y*32,32,32,False
Next
Next
End Function
;;;;;;;;;;;;;;;;;;;
Function DrawCounters()
For x = 0 To 39
For y = 0 To 31
If Board(x,y) = 1 Then DrawImage (ECFleet(i)), (x*32)+16,(y*32)+16
MaskImage (ECFleet(i)),001,001,001
Next
Next
If CurrentCounter\X >-1 Then
If MouseX() = -1 Then
DrawImage (ECFleet(i)), (MouseX()+16), (MouseY()+16)
MaskImage (ECFleet(i)),001,001,001
Else
EndIf
EndIf
End Function
Graphics 1280,1024,16,2 ; Create size of map
SetBuffer BackBuffer()
backgroundimage = LoadImage("star1280.jpg")
ECshipprofile = LoadImage ("ECShip_profile.bmp")
Planets = LoadImage ("planets.bmp")
;***************************************************************************************
Type Fleetcounter
Field X%
Field Y%
Field Image
Field TypeofCounter
End Type
Dim ECFleet(5)
ECFleet(0) = LoadImage ("ECShipcounter1.bmp")
ECFleet(1) = LoadImage ("ECShipcounter2.bmp")
ECFleet(2) = LoadImage ("ECShipcounter3.bmp")
ECFleet(3) = LoadImage ("ECShipcounter4.bmp")
ECFleet(4) = LoadImage ("ECShipcounter5.bmp")
For i = 0 To 4
NextCounter.Fleetcounter = New Fleetcounter
NextCounter\X = x
NextCounter\Y = y
NextCounter\image = LoadImage (ECFleet(i))
NextCounter\TypeofCounter = i
Next
Dim Board(39,31)
;***** Sets up a loop to place 5 counters when variablearray "Board" = 1 *************
For i = 0 To 4
AutoMidHandle True
x=x+1
Board (x, y)=1
Next
Global CurrentCounter.FleetCounter = New FleetCounter
CurrentCounter\X = -1
While Not MouseHit(3)
TileBlock backgroundimage
MaskImage ECshipprofile,001,001,001
DrawImage ECshipprofile,300,-145
MaskImage Planets,001,001,001
DrawImage Planets,0,0
CheckInput()
DrawGrid()
DrawCounters()
Flip
Cls
Wend
End
;;;;;;;;;;;;;;;;;;;
Function CheckInput()
;if left mouse button is pressed
If MouseHit(1) Then
;if there is no current counter
If CurrentCounter\X < 0 Then
;if a tile is under the mouse
If Board(MouseX()/32,MouseY()/32) = 1 Then
CurrentCounter\X = MouseX()/32
Currentcounter\Y = MouseY()/32
EndIf
Else ;there is already a current counter
If Board(MouseX()/32,MouseY()/32) = 0 Then
;move it to the new location
Board(CurrentCounter\X,CurrentCounter\Y) = 0
Board(MouseX()/32,MouseY()/32) = 1
CurrentCounter\X = -1
Currentcounter\Y = -1
EndIf
EndIf
EndIf
If MouseHit(2) Then
CurrentCounter\X = -1
EndIf
End Function
;;;;;;;;;;;;;;;;;;;
Function DrawGrid()
Color 45,45,45
For x = 0 To 39
For y = 0 To 31
Rect x*32,y*32,32,32,False
Next
Next
End Function
;;;;;;;;;;;;;;;;;;;
Function DrawCounters()
For x = 0 To 39
For y = 0 To 31
If Board(x,y) = 1 Then DrawImage (ECFleet(i)), (x*32)+16,(y*32)+16
MaskImage (ECFleet(i)),001,001,001
Next
Next
If CurrentCounter\X >-1 Then
If MouseX() = -1 Then
DrawImage (ECFleet(i)), (MouseX()+16), (MouseY()+16)
MaskImage (ECFleet(i)),001,001,001
Else
EndIf
EndIf
End Function