Drawing a loop around bubbles

Get help using Construct 2

Post » Mon Jan 27, 2014 4:07 pm

How would i do this, so when the connection is made (in the loop) the bubbles are counted ?
B
16
S
4
G
4
Posts: 179
Reputation: 4,688

Post » Mon Jan 27, 2014 9:51 pm

The problem can be thought of how to find out if a point is inside a polygon.

Here is capx with one solution:
https://www.dropbox.com/s/q8geaer8sa26f ... .capx?dl=0

Edit:
You can eliminate the need for variables if you add a imagepoint to the right-center of the line object and do this:
Code: Select all
For each Sprite
For each line
    | compare: line.y>sprite.y != line.ImagePointY(1)>sprite.y
    | sprite: x < (line.ImagePointX(1)-line.x) * (sprite.y-line.y) / (line.ImagePointY(1)-line.y) + line.x
    -----
        + Sprite: set animation frame to 1-Sprite.AnimationFrame
B
94
S
33
G
117
Posts: 5,391
Reputation: 75,343

Post » Thu May 04, 2017 7:06 am

@R0j0hound - Why does changing the last part of the line (animation frame to 1-sprite.animationframe) break everything if you simply change it to "set animation frame to 1"

isnt the code simply picking any sprite that's inside the lines, and changing their animation frame?

The code is setting the sprite to frame 0, then after it picks all of the circles inside the drawn loop, to frame 1? (1 minus 0?) why doesn't simply having "set animation frame to frame 1 work instead?
B
90
S
44
G
17
Posts: 1,012
Reputation: 18,527

Post » Thu May 04, 2017 8:24 am

The code looks at each line segment and toggles the selection of the points below them. It toggles it instead of setting it because it matters how many line segments are above a point. Basically if you take any point and draw a line straight up, and then count how many lines crossed you'll know if it's inside or outside. Odd:inside, even:outside.
B
94
S
33
G
117
Posts: 5,391
Reputation: 75,343


Return to How do I....?

Who is online

Users browsing this forum: dop2000 and 9 guests