A few hard questions

This forum is currently in read-only mode.
From the Asset Store
Dynamic heavy and powerful hard rock tracks. 15 tracks, loops and more.
  • Okay Secret Sally, I think people have squeezed enough information out of you to actually be able to help now.

    Use one detector and a series of two loops to load your array.

    Let's set a couple of ground rules first:

    We're using your grid picture in the first post as reference (nine by five grid)

    Box 1 is located at 0,0

    Every box is 32x32px

    Your collider object is 32x32px

    Your collider object has a cell counter to keep track of which grid space it is over

    The places where your Collider detects an impassable area are all in the family "Hard"

    You will be using two loops in a nest, the "outer" loop runs five times (for grid rows) and your "inner" loop runs nine times (for grid columns)

    This example uses a string to store the info, like you asked, but you could modify it to use an array

    There are two text objects, "collisionText" and "freespaceText" to store the strings

    Obviously, your real setup might be different but this is just an example

    Okay, let's start:

    1. Before the loop, reset all of your strings to empty (not "0", just nothing at all. No space between quotes.)

    2. Set your collider object to 0,0

    3. Set your collider object's counter to 1

    4. Start your loops:

    + On loop "loopRow"
      +Repeat 9 times
        +Detector overlaps "Hard"
        +Detector.Value('counter') = 1
          - collisionText: Set text to Detector.Value('counter')
        +Detector overlaps "Hard"
        +Detector.Value('counter') > 1
          - collisionText: Set text to collisionText.text & ", " & Detector.Value('counter')
        +Detector does not overlap "Hard"
        +Detector.Value('counter') = 1
          - freespaceText: Set text to Detector.Value('counter')
        +Detector oes not overlap "Hard"
        +Detector.Value('counter') > 1
          - freespaceText: Set text to freespaceText.text & ", " & Detector.Value('counter')
        + Always
          - Add 1 to Detector.Value('counter')
          - Detector: Set X to Detector.X + 32
    + On loop "loopRow"
      - Detctor:  Set Y to Detector.Y + 32
      - Detector: Set X to 0
    That's a total of eight events for the loops, and that includes the redundant events to make sure that the counter is at 1 so it doesn't put a comma at the beginning.  Of course I'm just doing this off the top of my head so it might need some tweaking but the basic idea is there.
    Also, in the future I suggest you give as much information as possible when asking for help, and don't hold back if someone asks for more info.  It just makes it more difficult to help.
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yeah... detectors seem superfluous. One could either use one detector object that moved around, or calculations based on distance, maybe. But, I don't know what you're really doing or anything about math. So I'm sorry, this post is pointless.

    That wasn't pointless! The moving detector worked like a dream!


    WOW! Just this minute i finnished it, and it was allmost exactly what you wrote (eccept i made it possible to ajust the grid with and number of cells). The only thing i hadn't figured out yet was how build the text in a string correctly (the &-sign).

    Awsome! Thanks for your efforts guys! The only thing i need now is how to search a string for a specific phrase!

    Edit: Which i allready have, since i've asked for it before:

    Next time i'll try to post more info, but sometimes i'm not looking for a new solution, but just for the answer to my question. I'm still curious about if it's possible to create many objects at the same time in a specific pattern.

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