Help me understand this

BlitzPlus Forums/BlitzPlus Programming/Help me understand this

fallegon(Posted 2014) [#1]
So I finished writing the code for options to move about the game board and I ran into a really weird image handling problem.

for the splitting lane option I had no problem everything worked written as below. When I put in the joining wave option the program would quit at the "if imagesoverlap(p1size1image.. joinwaveimage...)" so i messed around with the timing and still no succes.. Then for whatever reason I switched it to "if imagesoverlap(joinwaveimage and p1size1image...)" and it worked just fine.. i can take out the opcounter cause that was just for problem solving reasons.

BUT why did this happen? Why was this a problem?

;;;;;;;;;;;;;;;;;;;;; splitting lane ;;;;;;;;;;;;;;;;;;;;;;

If opcounter => 50
opcounter = 50
EndIf

splitlaneoption = False
If p1incombat = 0 And arcademode = False And p1trackxs <> 0
For w.wave = Each wave
If p1tracky = w\y
splitlaneoption = True
opcounter = opcounter + 1
EndIf
Next
EndIf

If splitlaneoption = True And opcounter => 10
DrawImage splitwaveimage,15,470

DrawImage splitwaveimage,785,470

If ImagesOverlap(p1size1image,p1\x,p1\y,splitwaveimage,15,470)
swcounter = swcounter + 1

If swcounter > 100

If p1trackxs > 0
p1tracky = p1tracky - 50
EndIf
If p1trackxs < 0
p1tracky = p1tracky + 50
EndIf

swcounter = 0
opcounter = 0
EndIf
EndIf

If ImagesOverlap(p1size1image,p1\x,p1\y,splitwaveimage,785,470)
swcounter = swcounter + 1

If swcounter > 100
If p1trackxs > 0
p1tracky = p1tracky + 50
EndIf

If p1trackxs < 0
p1tracky = p1tracky - 50
EndIf

swcounter = 0
opcounter = 0
EndIf
EndIf

EndIf

If splitlaneoption = False
swcounter = 0
EndIf

;;;;;;;;;;;;;;;;;; joining wave ;;;;;;;;;;;;;;;;;;;;;;;

joinwaveoption = False
jwleft = 0
jwright = 0

If p1incombat = False And arcademode = False And p1trackxs <> 0
For w.wave = Each wave
If p1tracky >< w\y
joinwaveoption = True

If w\y > p1tracky
If p1trackxs > 0
jwright = 1
EndIf
If p1trackxs < 0
jwleft = 1
EndIf
EndIf
If w\y < p1tracky
If p1trackxs > 0
jwleft = 1
EndIf
If p1trackxs < 0
jwright = 1
EndIf
EndIf

opcounter = opcounter + 1

EndIf
Next
EndIf

If joinwaveoption = True And opcounter => 10

If jwleft = 1

DrawImage joinwaveimage,15,400

If ImagesOverlap(p1size1image,p1\x,p1\y,joinwaveimage,15,400)
jwcounter = jwcounter + 1


If jwcounter => 100
If p1trackxs > 0
p1tracky = p1tracky - 50
EndIf
If p1trackxs < 0
p1tracky = p1tracky + 50
EndIf

jwcounter = 0
opcounter = 0
EndIf

EndIf
EndIf

If jwright = 1

DrawImage joinwaveimage,785,400

If ImagesOverlap(p1size1image,p1\x,p1\y,joinwaveimage,785,400)
jwcounter = jwcounter + 1


If jwcounter => 100
If p1trackxs > 0
p1tracky = p1tracky + 50
EndIf
If p1trackxs < 0
p1tracky = p1tracky - 50
EndIf

jwcounter = 0
opcounter = 0
EndIf

EndIf
EndIf


EndIf

If joinwaveoption = False
jwcounter = 0
EndIf


If joinwaveoption = False And splitlaneoption = False
opcounter = 0
EndIf