How do I draw a dash line and move on.PLEASE!?

0 favourites
  • 9 posts
From the Asset Store
solution for games like "fruit ninja" and drawing applications
  • The problem is :

    Draw a dashed line, and when finished drawing, a red circle is created on the first drawn dash and moves along that dashed line up to the end.

    The problem is to find a way to make the red circle move so SMOOTHLY and look like it's skating or floating.

    if I use the "bullet behavior" or "move to behavior" on the red circle then a micro nudge occurs between two dashes.

    I believe it should be coded using MATH, (which I can't do it )

    I've tried to solve this problem on my own without any success, any help will be highly appreciated.

    IAM looking to see and learn from R0J0hound about this issue cause I believe he has advanced knowledge of game coding math which I highly recommend.

  • The problem is :

    Draw a dashed line, and when finished drawing, a red circle is created on the first drawn dash and moves along that dashed line up to the end.

    The problem is to find a way to make the red circle move so SMOOTHLY and look like it's skating or floating.

    if I use the "bullet behavior" or "move to behavior" on the red circle then a micro nudge occurs between two dashes.

    I believe it should be coded using MATH, (which I can't do it )

    I've tried to solve this problem on my own without any success, any help will be highly appreciated.

    IAM looking to see and learn from R0J0hound about this issue cause I believe he has advanced knowledge of game coding math which I highly recommend.

  • You can use this addon to move a sprite along a curved line:

    construct.net/en/make-games/addons/198/spline-movement-c3-runtime/versions

  • There are lots of ways to do curves, but for that particular one you could use a Bézier curve or an arc.

    Generally for most curves you can get a formula to get any position along it by t. But the speed will vary as you move along it, so the solution to that is to convert the curve to a polyline so you can move along it at a constant speed.

    Anyways here’s the simplest formula to move on a curve. A and C are the end points and B is a control point, and t changes from 0 to 1.

    X=qarp(ax,bx,cx,t)

    Y=qarp(ay,by,cy,t)

    Again if you want to move at a constant speed along the curve you’ll need to use the formula above to get a list of points along the curve then move between them in straight lines. Another way is called arc reparameterization which avoids the polyline but requires more math to get an integral we can evaluate numerically.

    A second idea in that specific curve is to just use the arc on a circle. You can derive the center and radius from three points on the circle and using this formula for the tree points. Then solve using algebra.

    (X-centerX)^2+(y-centerY)^2=radius^2

    Then you can get a point on the circle with

    X=radius*cos(a)+centerX

    Y=radius*sin(a)+centerY

    So to move along an arc you lerp between the angles from the center to the endpoints. That will be constant speed.

    I don’t have time to make an example but I’ve done something similar a lot so a forum search of my posts will give a fair amount of results.

    If that plug-in works for you I’d go for it as well. I have not tried it.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There are lots of ways to do curves, but for that particular one you could use a Bézier curve or an arc.

    Generally for most curves you can get a formula to get any position along it by t. But the speed will vary as you move along it, so the solution to that is to convert the curve to a polyline so you can move along it at a constant speed.

    Anyways here’s the simplest formula to move on a curve. A and C are the end points and B is a control point, and t changes from 0 to 1.

    X=qarp(ax,bx,cx,t)

    Y=qarp(ay,by,cy,t)

    Again if you want to move at a constant speed along the curve you’ll need to use the formula above to get a list of points along the curve then move between them in straight lines. Another way is called arc reparameterization which avoids the polyline but requires more math to get an integral we can evaluate numerically.

    A second idea in that specific curve is to just use the arc on a circle. You can derive the center and radius from three points on the circle and using this formula for the tree points. Then solve using algebra.

    (X-centerX)^2+(y-centerY)^2=radius^2

    Then you can get a point on the circle with

    X=radius*cos(a)+centerX

    Y=radius*sin(a)+centerY

    So to move along an arc you lerp between the angles from the center to the endpoints. That will be constant speed.

    I don’t have time to make an example but I’ve done something similar a lot so a forum search of my posts will give a fair amount of results.

    If that plug-in works for you I’d go for it as well. I have not tried it.

    R0J0hound

    thank you for your reply,

    I've tried to implement your beautiful method titled "catmullrom" cause arrow movement is so smooth and flexible, but unfortunately, I couldn't succeed.

    Also, there is an old example made by you a long time ago titled "rocketfollowpath" where you use bullet behavior as a main movement trigger.

    the problem with that is the movement behavior is not smooth compared to "catmullrom" movements, especially between two dashes and when it doing a curve.

    is there any way you can do a C3 example for me where you use your beautiful math skills to give the red ball that smooth movement?

    I am one of your main supporters through ( buy me a coffee ), and I can pay you for this example as well.

    my email is:

    crockware1970kdq@gmail.com

  • Catmull rom & rockety example by ROjO are great. In the end is all about interpolating position and angle. Why don't just use lerp & anglelerp?

  • I would use Spline, it's a popular C2 addon by Rex ported for C3. It works like MoveTo only for curves, allows to adjust speed and curve tension.

  • There are always multiple ways to do something. Here's one way in addition to previous examples and such. My examples are meant to be something to fiddle with and maybe get some ideas how something could be done.

    It just converts a qarp curve to a polyline and lets you move some distance up and down the polyline.

    dropbox.com/s/m0pk8zvqoj08kr7/move_on_dashed_curve.capx

  • There are always multiple ways to do something. Here's one way in addition to previous examples and such. My examples are meant to be something to fiddle with and maybe get some ideas how something could be done.

    It just converts a qarp curve to a polyline and lets you move some distance up and down the polyline.

    https://www.dropbox.com/s/m0pk8zvqoj08kr7/move_on_dashed_curve.capx?dl=1

    Thank You so much.

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