How do I draw a parabola between 2 points?

0 favourites
  • 8 posts
From the Asset Store
Draw It!
$19 USD
The objective is to correctly guess and complete the missing part of the picture.
  • There is a lot of good info around on calculating parabolas and the like, but I can't seem to apply it to my specific situation.

    Basically, I have two sprites (start & end). I want them to be connected by a loosely hanging wire type of thing.

    and I'm not using physics. or plugins.

    so basically, I want to draw a droopy line from (start.x,start.y) to (end.x,end.y).

    I'd also like to be able to change the length (and thus, the droopiness) of the line.

    I'm sure this isn't hard. But my brain just isn't doing it.

  • spacedoubt

    You can use that Pin behaviour, " Pin to X -> Rope style "?

  • Add a sprite to use as a line, and make it's origin centered on the left. Also make it's height 4 or something, that will be the line thickness. Name the sprite "line".

    Then you can use the qarp() expression to do the curve and you could do this:

    global number px=0

    global number py=0

    every tick

    --- line: destroy

    --- set px to start.x

    --- set py to start.y

    repeat 100 times

    --- create line at (qarp(start.x, (start.x+end.x)/2, end.x, (loopindex+1)/100), qarp(start.y, (start.y+end.y)/2+200, end.y, (loopindex+1)/100)

    --- line: set angle toward (px,py)

    --- line: set width to distance(self.x,self.y,px,py)

    --- set px to line.x

    --- set py to line.y

  • R0J0hound Ah, man! you're a genius!

    I had a feeling you'd come through on this one

    I was already using a mishmash of different stuff you've posted, but just couldn't quite get it right.

    Perfect as usual.

    Thanks very much!

  • Add a sprite to use as a line, and make it's origin centered on the left. Also make it's height 4 or something, that will be the line thickness. Name the sprite "line".

    Then you can use the qarp() expression to do the curve and you could do this:

    global number px=0

    global number py=0

    every tick

    --- line: destroy

    --- set px to start.x

    --- set py to start.y

    repeat 100 times

    --- create line at (qarp(start.x, (start.x+end.x)/2, end.x, (loopindex+1)/100), qarp(start.y, (start.y+end.y)/2+200, end.y, (loopindex+1)/100)

    --- line: set angle toward (px,py)

    --- line: set width to distance(self.x,self.y,px,py)

    --- set px to line.x

    --- set py to line.y

    it's fantasy! but , it's also executing each tick and such more objects were created ...

  • totoyan

    The goal is always to first create the effect, and this serves are a good example. Sure you can modify it to reuse the same 100 objects or only running the events when you need to, but that wasn't relevant to the example.

  • totoyan

    The goal is always to first create the effect, and this serves are a good example. Sure you can modify it to reuse the same 100 objects or only running the events when you need to, but that wasn't relevant to the example.

    thanks for your answer!

    actually i want to make a parabola for the grenade when one object aims on another one before throwing it, so after throwing it, the grenade will move for the parabola.

    by the way ,i can know the object and another one's position, and the grenade 's bullet speed, bullet gravity.

    can you help me ? thanks a lot!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This topic may help:

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