Jump to content

Recommended Posts

Posted

Is it possible to have two diferent while loops editing the same GUI at the same time? Somthing like

#include<guiconstants.au3>
guicreate("test",400,400)
$test1=guictrlcreatelabel("A",190,200)
$test2=guictrlcreatelabel("B",210,200)
guisetstate()
while 1
   guictrlsetpos($test1,100,200)
   sleep(2000)
   guictrlsetpos($test1,190,200)
andwhile 1
   guictrlsetpos($test2,300,200)
   sleep(2000)
   guictrlsetpos($test2,210,200)
wend

[center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw

Posted (edited)

You can say:

guictrlsetpos($test1,100,200)
guictrlsetpos($test2,300,200)
sleep(2000)
guictrlsetpos($test1,190,200)
guictrlsetpos($test2,210,200)
Or
AdlibEnable("hello",2000)
Func Hello()
     guictrlsetpos($test2,300,200)
     guictrlsetpos($test2,210,200); this is EXACTLY what your currently asking...
EndFunc
While 1
     guictrlsetpos($test1,100,200)
     sleep(2000)
     guictrlsetpos($test1,190,200)
WEnd

If you give the actual code you need in 2 different while loops someone can do it for you.

Edited by Wolvereness

Offering any help to anyone (to my capabilities of course)Want to say thanks? Click here! [quote name='Albert Einstein']Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.[/quote][quote name='Wolvereness' date='7:35PM Central, Jan 11, 2005']I'm NEVER wrong, I call it something else[/quote]

Posted

ok, i am making a game using autoit and I'm using the _IfPressed function for controls but I need monsters and NPCs to also move WHILE the charecter is moving.

[center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw

Posted (edited)

#include<guiconstants.au3>
guicreate("test",400,400)
$test1=guictrlcreatelabel("A",190,200)
$test2=guictrlcreatelabel("B",210,200)
$Go=GUICtrlCreateButton("Go", 350, 350)
guisetstate()
while 1
   $msg = GUIGetMsg()
   
   Select
       
   Case $msg = $Go
   guictrlsetpos($test1,100,200)
   guictrlsetpos($test2,300,200)
   sleep(2000)
   guictrlsetpos($test1,190,200)
   guictrlsetpos($test2,210,200)
   
   EndSelect
              
   If $msg = $GUI_EVENT_CLOSE Then ExitLoop
wend

I'm not sure if this helps, I haven't tested it, but couldn't you just eliminate the 2nd While...Wend loop. See Above. The 2 chars (labels: A & B) should move at the same time.

Hope that helps,

Ian

Edited by ioliver

"Blessed be the name of the Lord" - Job 1:21Check out Search IMF

Posted

that should help with how i've set it up but it might appear a bit laggy...

[center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw

Posted

sounds really hard, if only autoit could do multi-threading (is that what its called im not sure)

[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Posted

@Jon, or anyone else:

Is that possible? I can't think of a way to have one object constantly moving in a GUI, and at the same time have another object move using user input... I hope I phrased that correctly.

Thanks,

Ian

"Blessed be the name of the Lord" - Job 1:21Check out Search IMF

  • Developers
Posted

@Jon, or anyone else:

Is that possible?  I can't think of a way to have one object constantly moving in a GUI, and at the same time have another object move using user input...  I hope I phrased that correctly.

Thanks,

Ian

<{POST_SNAPBACK}>

Did you have a look at AdlibEnable() ?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

  • Administrators
Posted

@Jon, or anyone else:

Is that possible?  I can't think of a way to have one object constantly moving in a GUI, and at the same time have another object move using user input...  I hope I phrased that correctly.

Thanks,

Ian

It doesn't happen at the same time. Its just a loop that is done so quickly it seems to be at the same time. Do you have a Multi CPU machine? Probably not, so how come your email is downloading in the background as your read this? All the tasks get split into small slices that each take turns to receive processing time.
Posted

#include<guiconstants.au3>
guicreate("test",400,400)
$test1=guictrlcreatelabel("A",190,200)
$test2=guictrlcreatelabel("B",210,200)
$Go=GUICtrlCreateButton("Go", 350, 350)
guisetstate()

AdlibEnable("_CharMove", 500)
While 1
   $msg = GUIGetMsg()
   
   Select
       
   Case $msg = $Go
   guictrlsetpos($test1,100,200)
   Sleep(2000)
   guictrlsetpos($test1,190,200)
      
   EndSelect
              
   If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
   
Func _CharMove()
GUICtrlSetPos($test2, 300, 200)
Sleep(2000)
GUICtrlSetPos($test2, 210, 200)
Sleep(2000)
EndFunc

I just tried AdlibEnable(). Code Above. But when I press the 'Go' button Char: A does not move. What am I missing?

Thanks for your time,

Ian

"Blessed be the name of the Lord" - Job 1:21Check out Search IMF

Posted (edited)

as for the controls i'm gonna have something like this.

if _ispressed('22')=1 then
  while _ispressed('22')=1
    $chary=$chary-1
    guictrlsetpos($char,$charx,$chary)
    $rand=int(random(1,5))
    if $rand=1 then
      $monx = $mox + 1
      guictrlsetpos($mon1,$monx,$mony)
    elseif $rand=2 then
      $monx = $monx - 1
      guictrlsetpos($mon1,$monx,$mony)
    elseif $rand=3 then
      $mony = $mony + 1
      guictrlsetpos($mon1,$monx,$mony)
    elseif $rand=4 then
      $mony = $mony - 1
      guictrlsetpos($mon1,$monx,$mony)
    endif
    sleep(5)
  wend
endif

Of course thats only for down and in the final it will have walking avi's but you get the idea.

Edited by fear1313

[center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw

Posted

Is it possible to have two diferent while loops editing the same GUI at the same time?

<{POST_SNAPBACK}>

Here's a modified version of your original script. The "A" follows the cursor around, the GO button randomly relocates "B", and "C" and "D" bounce around continuously.

#include<guiconstants.au3>
guicreate("test",400,400)
$test1=guictrlcreatelabel("A", 190, 200)
$test2=guictrlcreatelabel("B", 210, 200)
$test3=guictrlcreatelabel("C", 100, 200)
$test4=guictrlcreatelabel("D", 290, 200)
$Go=GUICtrlCreateButton("Go", 350, 350)
guisetstate()
   
opt("MouseCoordMode", 0)
$iAuto1 = 1
$iDelay = 500
$iStart = TimerInit()
while 1
   $msg = GUIGetMsg()
   Select
      Case $msg = $Go
         $iX1 = Random(20, 380, 1)
         $iY1 = Random(20, 320, 1)
         $iX2 = Random(20, 380, 1)
         $iY2 = Random(20, 320, 1)
         guictrlsetpos($test2,$iX2,$iY2)
      case $msg = $GUI_EVENT_CLOSE
         ExitLoop
      Case $iAuto1 = 1
         $aPos = MouseGetPos()
         guictrlsetpos($test1, $aPos[0] - 10, $aPos[1] - 45)
         If TimerDiff($iSTART) >= $iDelay Then
            $iX1 = Random(20, 380, 1)
            $iY1 = Random(20, 320, 1)
            $iX2 = Random(20, 380, 1)
            $iY2 = Random(20, 320, 1)
            guictrlsetpos($test3,$iX1,$iY1)
            guictrlsetpos($test4,$iX2,$iY2)
            $iStart = TimerInit()
         EndIf
   EndSelect
wend

Phillip

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...