I need help drawing accurately - Capx attached

Get help using Construct 2

Post » Wed Mar 06, 2013 3:03 am

Total amateur here... I've been working on this problem for weeks, but can't solve it.

I want the user to draw lines on the screen by swiping.
These are the two major problems I'm having:

1) The lines do not stop accurately when colliding - especially after hitting the "speed button". The lines often overlap the other lines (which will not work in my game. They must end exactly on the line they collide with since I need those specific points to calculate the different areas of the rectangles created)

2) The user cannot draw mulitple lines at the same time (the user should be able to draw at least a second line while the first line is still being drawn, but currently the first line stops when the second one is started)

CapX file is here:
https://www.dropbox.com/s/i8p5b41or8v8ytx/Drawing-Line-Issue.capx?m

If anyone can help me with these 2 issues, I'd be very grateful!30FootForest2013-03-06 20:52:12
B
10
S
3
G
3
Posts: 29
Reputation: 2,692

Post » Wed Mar 06, 2013 4:34 pm

BTW, I've never used Dropbox this way. Is the link to the Capx working?
B
10
S
3
G
3
Posts: 29
Reputation: 2,692

Post » Thu Mar 07, 2013 7:51 pm

ok. one more try...
If I can't get the fences to draw more accurately, I need a way to calculate when sprites are boxed in by the lines.

ie. if the user drew 4 lines (4 sides of a box) I'd need to know the area of the box and what sprites were in it. Then, if the user drew another line through that box it would divide it into 2 boxes. I would then need to know the area of both boxes and what sprites were in each of them.

I was going to find the area of each boxed in square by noting the locations of the ends of the lines. (but since the ends of the lines are often over the lines, it makes for a very inaccurate measurement).

Is there a way I can either draw the lines more accurately, OR, calculate when an area has been "boxed in" and what sprites are in the boxed in area?

TIA!
B
10
S
3
G
3
Posts: 29
Reputation: 2,692

Post » Thu Mar 07, 2013 10:13 pm

One way to make it more accurate is to use a loop to check for collisions in between positions. Also if you restrict fence positions and sizes to grid positions it's simpler to keep it precise.

Loops will also enable the lines to be done instantly. For example:
http://dl.dropbox.com/u/5426011/examples17/fence.capx

For a horizontal line the detector moves from the starting position right to just shy of a fence then back left. That gives the start and end positions.

You can similarly find the top/left and bottom/right corners of a box in the same way. With that you can create a box to fill that area and check for collisions or calculate the area.
B
79
S
24
G
54
Posts: 4,747
Reputation: 40,757

Post » Thu Mar 07, 2013 11:08 pm

Thank you. I am currently installing the beta because I can't open your capx in the stable release.

I am looking forward to seeing your suggested solution and playing more with Loops! :o)
B
10
S
3
G
3
Posts: 29
Reputation: 2,692


Return to How do I....?

Who is online

Users browsing this forum: Kagubro, MisterAqua and 23 guests