Question about nested "overlapping at offset" checks

  • Hello. I'm making some line of sight code for a roguelike game. I'm not sure what the best approach for such code is so for now I'm hardcoding it with the intention of optimizing it with loops and such after I figure out the best approach.

    If you look at my screenshot I've got a problem. If I nest the checks only the first one evaluates to true. This is a problem as I need the code branch to stop if a wall is encountered (the player shouldn't be able to see through walls of course). As you can see from the attachment the 4 code blocks only work if they're not nested.

    Can anyone tell me what I'm doing wrong, or how I can do it differently?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm not sure I understand what's happening visually. Is the collisionDetector the player?

    • Green box = player
    • Orange dot = collision detector

    The black tiles are fog. These are supposed to turn invisible when you explore them. The red/green dots on the black tiles indicate whether a boolean has been set or not. Not sure that's relevant here.

    I hope that made sense, otherwise I'll try and explain it more

  • It doesn't work due to picking.

    https://www.scirra.com/manual/75/how-events-work

    A loop can help to make it works like so:

    for "" from 1 to 4

    -- colision detector is overlapping fog at offset (32*loopindex, 0)

    ---- set fog booleans...

    -- [inverted] colision detector is overlapping fog at offset (32*loopindex, 0)

    ---- system: stop loop

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