Question about nested "overlapping at offset" checks

Get help using Construct 2

Post » Sun Jun 15, 2014 11:57 am

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?
You do not have the required permissions to view the files attached to this post.
B
6
S
1
Posts: 41
Reputation: 762

Post » Sun Jun 15, 2014 2:19 pm

I'm not sure I understand what's happening visually. Is the collisionDetector the player?
Image
B
75
S
23
G
3
Posts: 673
Reputation: 9,283

Post » Sun Jun 15, 2014 2:37 pm

- 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 :)
You do not have the required permissions to view the files attached to this post.
B
6
S
1
Posts: 41
Reputation: 762

Post » Sun Jun 15, 2014 7:01 pm

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
B
92
S
32
G
109
Posts: 5,294
Reputation: 70,999


Return to How do I....?

Who is online

Users browsing this forum: oosyrag and 29 guests