Jump to content
Sign in to follow this  
layer

Do Until

Recommended Posts

layer

hey guys... im making a little game and need a little help :"> i have a sound, that plays when you press mouse1 which is part of the game... and that has to be in the Do...Until loop... and so does several GUICtrlSetPos in the Do...Until loop.. heres the loop and then ill explain ;)

Do 
$get= GUIGetMsg ()
If _IsPressed('01') = 1 then
SoundPlay (@DesktopDir & "\Ryans Stuff\Shoot it\sounds\aug-1.wav")
Sleep ("150")
EndIf
If $get= -3 then
exit
endif
Until $get= -3

now is what i need to do is add this in that exact loop:

GUICtrlSetPos ($bad_guy, 60, 200, 20, 40)
sleep ("200")
GUICtrlSetPos ($bad_guy, 70, 200, 20, 40)
sleep ("200")
GUICtrlSetPos ($bad_guy, 80, 200, 20, 40)
sleep ("200")
GUICtrlSetPos ($bad_guy, 90, 200, 20, 40)
sleep ("200")
GUICtrlSetPos ($bad_guy, 100, 200, 20, 40)
sleep ("200")
GUICtrlSetPos ($bad_guy, 110, 200, 20, 40)
sleep ("200")
GUICtrlSetPos ($bad_guy, 120, 200, 20, 40)
sleep ("200")
GUICtrlSetPos ($bad_guy, 130, 200, 20, 40)
sleep ("200")
GUICtrlSetPos ($bad_guy, 140, 200, 20, 40)
sleep ("200")
GUICtrlSetPos ($bad_guy, 150, 200, 20, 40)
sleep ("200")
GUICtrlSetPos ($bad_guy, 160, 200, 20, 40)

... if i try adding that into the loop, is what it does is only moves the picture and doesnt do the rest of the above Do...Until loop.. and then after i put that in, i will be adding things like

$pos = MouseGetPos()
If $pos= 60, 200 then
MsgBox (0, "Congrats!", "Youve passed level 1!")
endif

i will be adding the above mosuepos example in the Do...Until loop too... but im having a little trouble because i need to put all of that in the Do...Until loop and still have all this going on:

Do 
$get= GUIGetMsg ()
If _IsPressed('01') = 1 then
SoundPlay (@DesktopDir & "\Ryans Stuff\Shoot it\sounds\aug-1.wav")
Sleep ("150")
EndIf
If $get= -3 then
exit
endif
Until $get= -3

could someone please help me :idiot:

thanks, very appreciated!!! :lol::D


FootbaG

Share this post


Link to post
Share on other sites
MHz

Untested, but see if this is suitable.

MouseGetPos does return an array in the manual.

$loc = 60
Do
   $get = GUIGetMsg()
   If _IsPressed ('01') = 1 Then
      SoundPlay(@DesktopDir & "\Ryans Stuff\Shoot it\sounds\aug-1.wav")
      Sleep("150")
   EndIf
   
   $pos = MouseGetPos()
   If $pos[0] = 60 And $pos[1] = 200 Then
   MsgBox (0, "Congrats!", "You've passed level 1!")
   endif

   If $get = -3 Then
      Exit
   EndIf
   
   GUICtrlSetPos ($bad_guy, $loc, 200, 20, 40)
   sleep ("200")
   $loc = $loc + 10
   If $loc = 160 Then $loc = 60
      
Until $get = -3

Share this post


Link to post
Share on other sites
layer

hmmm, still doesn't work... i mean the guy moves, but if i press mouse1 then no sound plays and if i try to exit i have to press it until the guy gets to the end... im pretty positive it's because it takes too long for the guy to make all those moves.. so when im trying to listen for the gun noise, the script is still executing the GUICtrlSetPos functions... maybe another way to do this?

P.S. it can't be if $pos= lalal then

msgbox (lala)...

it's gotta be like

if $pos= lala and _IsPressed ("01") = 1 then

msgbox (lala)

but that i can do myself.. i think... but could anyone give me any advice on how i could get this to work? ive tried everything :idiot:


FootbaG

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.