Sign in to follow this  
Followers 0
Juggernaut

More Pixel help

1 post in this topic

#1 ·  Posted (edited)

I came here before looking for help with pixelsearching, and i've encountered another problem.

Basically, what im looking to make is there is a "maze" or a line of sorts and im looking to make my player walk over the lines, without touching the edges. I can get him to move, but i can't seem to get it. Im looking to make my guy automatically walk over the lines. Any help? I currently have this:

$target = 0x5A86C6
;water - 0x3961A5
$player = 0x292829
$iPixRange = 2
HotKeySet("z", "Quit")
HotKeySet("g", "Get")
Global $target, $player

Func Get()
$pos = MouseGetPos()
$var = PixelGetColor( $pos[0] , $pos[1] )
;MsgBox(0,"The hex color is", Hex($var, 6))
MsgBox(0,"xy", $pos[0] & "," & $pos[1])
EndFunc


HotKeySet("{ESC}", "Quit")
While 1
    Sleep(500)
    $pixelSearch = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, $target);target
    If @error Then ContinueLoop
    $pixelSearchPlayer = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, $player);player
    If @error Then ContinueLoop
   if $pixelsearch[0] > $pixelsearchPlayer[0] then
       Send("{Right}")
   EndIf
   If $pixelsearch[0] < $pixelsearchPlayer[0] Then
       Send("{Left}")
   EndIf
   if $pixelsearch[1] > $pixelsearchPlayer[1] Then
       Send("{Up}")
   EndIf
   if $pixelsearch[1] < $pixelsearchPlayer[1] Then
       Send("{Down}")
   EndIf
WEnd

Func Quit()
    Exit
EndFunc

I also have this other code i was given, im not sure where to go now. I think im missing how to impliment if the player is on the pixel or near it..

$target = 0x42594A
$player = 0x525152
$iPixRange = 48
HotKeySet("z", "Quit")
HotKeySet("g", "Get")
Global $target, $player

Func Get()
$pos = MouseGetPos()
$var = PixelGetColor( $pos[0] , $pos[1] )
;MsgBox(0,"The hex color is", Hex($var, 6))
;MsgBox(0,"xy", $pos[0] & "," & $pos[1])
EndFunc


HotKeySet("{ESC}", "Quit")
While 1
    Sleep(10)
    $pixelSearch = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, $target , 1, 5);target
    If @error Then ContinueLoop
    $pixelSearchPlayer = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, $player , 1, 5);player
    If @error Then ContinueLoop
    Switch $pixelSearchPlayer[0]
        Case $pixelSearch[0] -$iPixRange To $pixelSearch[0] +$iPixRange
            Switch $pixelSearchPlayer[1]
                Case $pixelSearch[1] -$iPixRange To $pixelSearch[1] +$iPixRange
               ;Send("s")
                    Beep(2000, 100)
                    Sleep(500)
            EndSwitch
    EndSwitch
WEnd


Func Quit()
    Exit
EndFunc
Edited by Juggernaut

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  
Followers 0