Jump to content

avoid pixel to collide with other


bass711
 Share

Recommended Posts

How you write a code if i dont want a pixel to collide with other for example the walls are green color the ball is red

i dont want the red ball to collide with walls x.y if the ball is near to left send {rigth}, using key arrows any help pleaseeee

any dimension 500,500,500 thank you

Link to comment
Share on other sites

Well I hope you dont laugh about my code im still newbie im trying to learn by making projects and the best way to do it is with games

so now i want my car to drive solo accelerate button is up {up} key move car left and right the color of the road is gray and on left and right sides is green walls I come up with the idea of my car avoiding the green color and stay on the road, in other way is by timing the send keys when to turn left rigth up, and down, but for everytrack it will take a long time for me to do it. so here is my code please help

$color =0x89881F;green color obj walls
$color1 = 0xF30606;red color obj car
   
    $coord = PixelSearch( 0, 0, 1023, 651, $color, 10, 20)
         If IsArray($coord) = 1 Then
        send('{up}')          ;<===this is for accelerate obj = car
        Sleep(300)
         EndIf 
    $coord1 = PixelSearch( 0, 0, 1023, 651, $color1, 10, 20)
         If IsArray($coord1) = 1 Then
        Send('{right}'); or left or up or down this where im lost how tell the code go to the opositive side
        Sleep(300)
         EndIf
Link to comment
Share on other sites

First off your viewing is to great, your should find a focus point. 1st person then a single beam, 3rd person then you are in a car focusing it on a single beam. It you moving in a straight line you can accomplish this more easily if you choose a closer range

0,0,5,5

compared with

0,0,1000,600

If you are in 1st person then can you see what side is open, to take? If you do then make a quite search on those two spots. 3rd person is easier for you because you can easily check to see what side is open and then send right or left

$asColors = StringSplit("0x89881F|0xF30606", "|")

While 1
    Send("{up down}")
    While 1
        For $sColor In $asColors
            $aiCoords = PixelSearch(0, 0, 1023, 651, $sColor, 10, 20)
            If IsArray($aiCoords) Then 
                Send("{right}")
                ExitLoop
            EndIf
        Next
    WEnd
WEnd

Just wanted you to ask you are the objects both obstacles or are you the car? Why, do you want it to skiip once every 20 on your pictures, I know 2 4 maybe 8 at the max unless this is some preschool kids game.

0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E

Link to comment
Share on other sites

well im doing this just to learn autoit i can just drop this test in move on with next but i really want to figure how to do it

i know a way to do it wich is by sending the arrow keys by time delay but i need to track each curve exactly this a hard way the other

way is to make the pixels not to collide since the accelerate key is up all i have to figure is when to turn right or left there is only 3 keys to control the car up , left and right for example if the car is getting really close to the right wall send a commando to be away for 20 pixels from the car by sending left key or the other way here is a pic of example srry for my art and thanks for your help.

Posted Image

Link to comment
Share on other sites

Does the car turn on a dime or like some delay in there or even have to turn it like a real car and turning to much can cause you to overturn and then reversing all of a sudden.

If it is like a dime is is pretty easy. Is your vehicle always in the center of the screen, if not then that is the first thing and you need to find the exact size of the car so your not searching the entire screen. Then put a [3 wide] [25 long] line going out the front. If it encounters a wall then fall into another pixelsearch searching the left and right. Now it is up to you as your could search left/right or right/left and whatever you find first send the key to turn that way. Else you could calculate both and it both a open have it decide on what way to go. Then have it pass out and fall back to the 3 wide 25 long line again coming out the front

0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E

Link to comment
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
 Share

  • Recently Browsing   0 members

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