Sorry folks but I still have a problem with counter control
everything works in the code below except instead of reading all 5 counters it reads only the first one. I shortened the code and added remarks to make it easy to look at and figure out the problem. I have been working every angle for the last few days and now I am stumped!!!!Also anywhere I can get a sample of "WW2 strategy" type gaming code (In blitz of course) for moving and controlling game counters on the board, that would be great.
Graphics 1280,1024,16,2
SetBuffer BackBuffer()
;Load Image (5) counter 43x32 pixels each
Global imgcounter = LoadAnimImage("AAshipcounter_all5.bmp",43,32,0,5)
;load background data into files
backgroundimage = LoadImage("star1280.jpg")
ECshipprofile = LoadImage ("ECShip_profile.bmp")
Planets = LoadImage ("planets.bmp")
GameLogo= LoadImage ("ShipGameLogo.bmp")
;Set up counter holder for placing existing counters
Global CurrentCounter.FleetCounter = New FleetCounter
CurrentCounter\X = -1
Type Fleetcounter
Field X%
Field Y%
End Type
;Dimension board to place counters
Dim Board(39,31)
;Starting placement for (5) Ship Counters using the "1" flag in the following functions
Board (34, 4)=1
Board (34, 5)=1
Board (35, 5)=1
Board (35, 4)=1
Board (35, 6)=1
;Start game loop
While Not MouseHit(3)
;Draw background data to screen
TileBlock backgroundimage
MaskImage ECshipprofile,001,001,001
DrawImage ECshipprofile,300,-145
MaskImage Planets,001,001,001
DrawImage Planets,0,0
MaskImage Gamelogo,001,001,001
DrawImage Gamelogo,22,925
;Start counter hold process but first it will draw the (5) counters in the first location discribed above in "board" array
CheckInput1()
DrawCounters1()
Flip
Cls
Wend
End
;;;;;;;;;;;;;;;;;;;
Function CheckInput1()
;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 DrawCounters1()
For x = 0 To 39
For y = 0 To 31
;!!!!!The statement below is where I have the problem. I cannot control the "c" variable in this loop so it winds up creating 5 images of the first image from the .bmp file!!!!!
If Board(x,y) = 1 Then DrawImage imgcounter, ((x*32)-6),(y*32),c
MaskImage imgcounter,001,001,001
Next
Next
End Function
everything works in the code below except instead of reading all 5 counters it reads only the first one. I shortened the code and added remarks to make it easy to look at and figure out the problem. I have been working every angle for the last few days and now I am stumped!!!!Also anywhere I can get a sample of "WW2 strategy" type gaming code (In blitz of course) for moving and controlling game counters on the board, that would be great.
Graphics 1280,1024,16,2
SetBuffer BackBuffer()
;Load Image (5) counter 43x32 pixels each
Global imgcounter = LoadAnimImage("AAshipcounter_all5.bmp",43,32,0,5)
;load background data into files
backgroundimage = LoadImage("star1280.jpg")
ECshipprofile = LoadImage ("ECShip_profile.bmp")
Planets = LoadImage ("planets.bmp")
GameLogo= LoadImage ("ShipGameLogo.bmp")
;Set up counter holder for placing existing counters
Global CurrentCounter.FleetCounter = New FleetCounter
CurrentCounter\X = -1
Type Fleetcounter
Field X%
Field Y%
End Type
;Dimension board to place counters
Dim Board(39,31)
;Starting placement for (5) Ship Counters using the "1" flag in the following functions
Board (34, 4)=1
Board (34, 5)=1
Board (35, 5)=1
Board (35, 4)=1
Board (35, 6)=1
;Start game loop
While Not MouseHit(3)
;Draw background data to screen
TileBlock backgroundimage
MaskImage ECshipprofile,001,001,001
DrawImage ECshipprofile,300,-145
MaskImage Planets,001,001,001
DrawImage Planets,0,0
MaskImage Gamelogo,001,001,001
DrawImage Gamelogo,22,925
;Start counter hold process but first it will draw the (5) counters in the first location discribed above in "board" array
CheckInput1()
DrawCounters1()
Flip
Cls
Wend
End
;;;;;;;;;;;;;;;;;;;
Function CheckInput1()
;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 DrawCounters1()
For x = 0 To 39
For y = 0 To 31
;!!!!!The statement below is where I have the problem. I cannot control the "c" variable in this loop so it winds up creating 5 images of the first image from the .bmp file!!!!!
If Board(x,y) = 1 Then DrawImage imgcounter, ((x*32)-6),(y*32),c
MaskImage imgcounter,001,001,001
Next
Next
End Function