How do I make curved lines between dots?

Get help using Construct 2

Post » Sat Jul 08, 2017 9:17 pm

I have to trace lines between dots, but they should be curved, what is the best way to do it?
Link to capx - https://www.dropbox.com/s/hotqshxkg6bbd ... .capx?dl=0. I want to draw roads and rivers over the map.
B
20
S
4
Posts: 51
Reputation: 1,104

Post » Sun Jul 09, 2017 7:20 pm

The best way to do it is to use bezier curves, they are rather intuitive. Look up the math on wikipedia. Depending if you just need simple curves or very windy paths you can use more control points.

However drawing good looking curves in C2 is not exactly easy. The best I could come up with is using small sprite sections, calculating the slope at the point in which the section is placed, rotating it to the angle of the slope and so on. Unfortunately you easily end up with hundreds of sprites just for that. That might impact performance. Maybe there is a plugin that does that better.

However if you just want calculate a curve and translate it into a set of tiles constituting a path that you autotile, the whole thing become much simpler. No need for calculating the slope, sprite/object count goes down.
B
15
S
6
Posts: 85
Reputation: 1,195

Post » Sun Jul 09, 2017 8:03 pm

As Pulsar suggested, you can try Bezier curves. I already made this couple of months ago. If you can understand what is there, you could implement this in your game. replace the dots with lines .
https://www.dropbox.com/s/yzuj89fg923ge ... .capx?dl=0

And as for performance goes, if you don;t want many sprites, just use the Paster or Canvas plugin and only "bake" the curve/path line into that object, then delete the curve/path
B
84
S
21
G
23
Posts: 521
Reputation: 18,789

Post » Sun Jul 09, 2017 8:40 pm

Cipriux wrote:As Pulsar suggested, you can try Bezier curves. I already made this couple of months ago. If you can understand what is there, you could implement this in your game. replace the dots with lines .
https://www.dropbox.com/s/yzuj89fg923ge ... .capx?dl=0

And as for performance goes, if you don;t want many sprites, just use the Paster or Canvas plugin and only "bake" the curve/path line into that object, then delete the curve/path

I can't find the plugin SeedRandom, the file is deleted. If it is possible please attack the plugin.
B
20
S
4
Posts: 51
Reputation: 1,104

Post » Sun Jul 09, 2017 9:32 pm

redownload the file again. I deleted the plugin from the projects, since it doesn't use it
B
84
S
21
G
23
Posts: 521
Reputation: 18,789

Post » Tue Jul 11, 2017 3:33 am

It takes a fair bit of math to generate a smooth-closed curve from only points. Here is an example using cubic-bezier curves, as mentioned by @Cipriux.
http://www.blackhornettechnologies.com/Construct2Stuff/bangoo_beziercurves_BHT.capx
ImageImageImage
B
71
S
22
G
257
Posts: 3,790
Reputation: 142,696


Return to How do I....?

Who is online

Users browsing this forum: lemonizer and 2 guests