If ImagesCollide.........

Blitz3D Forums/Blitz3D Beginners Area/If ImagesCollide.........

po(Posted 2004) [#1]
I am having problems with ImagesCollide. Here is an example:
If ImagesOverlap(mouse,MouseX(),MouseY(),fish2,fish_x2,fish_y2) And MouseHit(1) :fish_speed2=fish_speed2+1:PlaySound bubbles2:score=score+15:EndIf 
If ImagesOverlap(mouse,MouseX(),MouseY(),fish1,fish_x1,fish_y1) And MouseHit(1) :fish_speed1=fish_speed1+1:PlaySound bubbles2:score=score+10:EndIf
If ImagesOverlap(mouse,MouseX(),MouseY(),fish3,fish_x3,fish_y3) And MouseHit(1) :fish_speed3=fish_speed3+1:PlaySound bubbles2:score=score+5:EndIf
If ImagesOverlap(mouse,MouseX(),MouseY(),time2,time_x,time_y) And MouseHit(1) :time=time+300:PlaySound bubbles2:score=score+10:EndIf

Only the 1st line of code works. The others dont. All the variables and all the spelling is correct. Is this because I am using: mouse,MouseX(),MouseY() wrong?

-Thanks


Bot Builder(Posted 2004) [#2]
maybe. Try storing mousex/y values in variables and then substiturte all the calls to it with the associated vars. otherwise it looks ok to me.


Curtastic(Posted 2004) [#3]
you should only call mousehit() once each loop


GitTech(Posted 2004) [#4]
mouseHitBool=MouseHit(1)
If ImagesOverlap(mouse,MouseX(),MouseY(),fish2,fish_x2,fish_y2) And mouseHitBool :fish_speed2=fish_speed2+1:PlaySound bubbles2:score=score+15:EndIf 
If ImagesOverlap(mouse,MouseX(),MouseY(),fish1,fish_x1,fish_y1) And mouseHitBool :fish_speed1=fish_speed1+1:PlaySound bubbles2:score=score+10:EndIf
If ImagesOverlap(mouse,MouseX(),MouseY(),fish3,fish_x3,fish_y3) And mouseHitBool :fish_speed3=fish_speed3+1:PlaySound bubbles2:score=score+5:EndIf
If ImagesOverlap(mouse,MouseX(),MouseY(),time2,time_x,time_y) And mouseHitBool :time=time+300:PlaySound bubbles2:score=score+10:EndIf



dynaman(Posted 2004) [#5]
And also store the mouse coords before checking, otherwise it is possible that the mouse moved between one line and the next. (in this code example that is highly unlikely but still possible, when you have a longer loop it becomes more of an issue).