Search an Array using X varriables

0 favourites
  • 3 posts
From the Asset Store
Searching
$16 USD
Searching is a game where you are challenged to find all the images with the requested letter in 30 seconds.
  • Hello forum Buddies,

    I have populated an X,Y Array with (Random X coordinate), (Random Y coordinate), and other info about a sprite that will eventually be placed on the screen. So each Y axis line is a new object with x,y coordinates.

    I also created a Dropdown box that lists each object location as ?X,Y?. This box is populated in the for next loop creating the random coordinates.

    How would I do a search of the Array to find the Y line (I need CurY of Array) where X0 = tokenat(List.SelectedText,0,",") and X1 = tokenat(List.SelectedText,1,",")? It would start with-> List: on selection changed

    Example: ARRAY

          X0 , X1

    Y0    213 , 435

    Y1    123 , 654

    Example:Dropdown List

    213,435

    123,654

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I think I know what your asking. If I'm wrong. Sorry, but your 3rd paragraph is throwing me.

    search = int(tokenat(List.SelectedText,0,",") )

    xIndex = Array.indexof(search)

    xpos = Array.At(xIndex, 0)

    ypos = Array.At(xIndex, 1)

    you will have to validate both values. but I think this is the direction your looking at.

  • I have decided that a Hash table might do the trick a little better... I am going to try that rout.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)