Author Topic: [Lua] Rope Physics  (Read 15154 times)

0 Members and 1 Guest are viewing this topic.

Offline Nick

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1166
  • Rating: +161/-3
  • You just got omnom'd
    • View Profile
    • Nick Steen
[Lua] Rope Physics
« on: January 07, 2013, 03:01:53 pm »
Hi

Here is another video of a script I made today (I didn't really work long on it, so it's not really complete and useable) that i wanted to show you.
It is a rope physics script that can be downloaded below.

The video description tells more about it, everyone can use it if they want, feel free, but as I told you, it is not really working as it should be. For example the gravity seems to work perfectly as you look, but in the code it's a total mess :)


Offline ElementCoder

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 611
  • Rating: +42/-2
    • View Profile
Re: [Lua] Rope Physics
« Reply #1 on: January 07, 2013, 03:03:18 pm »
It looks pretty :3 I'm going to waste so much time playing with dat rope :D

Some people need a high five in the face... with a chair.
~EC

Offline Levak

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +208/-39
    • View Profile
    • My website
Re: [Lua] Rope Physics
« Reply #2 on: January 07, 2013, 03:17:05 pm »
Now try this on calc and cry =(
« Last Edit: January 07, 2013, 03:17:09 pm by Levak »
I do not get mad at people, I just want them to learn the way I learnt.
My website - TI-Planet - iNspired-Lua

Offline ElementCoder

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 611
  • Rating: +42/-2
    • View Profile
Re: [Lua] Rope Physics
« Reply #3 on: January 07, 2013, 03:29:14 pm »
Why make a physics engine if it performs poorly on the actual platform/hardware it should be running on :/

Some people need a high five in the face... with a chair.
~EC

Offline Levak

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +208/-39
    • View Profile
    • My website
Re: [Lua] Rope Physics
« Reply #4 on: January 07, 2013, 03:39:11 pm »
Why make a physics engine if it performs poorly on the actual platform/hardware it should be running on :/
TI's logic.
I do not get mad at people, I just want them to learn the way I learnt.
My website - TI-Planet - iNspired-Lua

Offline Nick

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1166
  • Rating: +161/-3
  • You just got omnom'd
    • View Profile
    • Nick Steen
Re: [Lua] Rope Physics
« Reply #5 on: January 07, 2013, 04:21:33 pm »
Now try this on calc and cry =(
Damn, i thought it would be faster, but no..you're right

Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
Re: [Lua] Rope Physics
« Reply #6 on: January 07, 2013, 05:19:30 pm »
Hm, it looks like that isn't true segmented rope physics though - each individual segment doesn't appear to affect the forces on the other segments (for example, when you yank the rope the ball doesn't fly upwards)
In-progress: Graviter (...)

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: [Lua] Rope Physics
« Reply #7 on: January 07, 2013, 05:24:53 pm »
It reminds me a bit some bosses in SUper Metroid for the Super Nintendo. Now if only Lua was faster...

Offline Nick

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1166
  • Rating: +161/-3
  • You just got omnom'd
    • View Profile
    • Nick Steen
Re: [Lua] Rope Physics
« Reply #8 on: January 07, 2013, 05:40:40 pm »
Hm, it looks like that isn't true segmented rope physics though - each individual segment doesn't appear to affect the forces on the other segments (for example, when you yank the rope the ball doesn't fly upwards)
that's what i meant with it seems to work at first sight, but it isn't really what it should be :)

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: [Lua] Rope Physics
« Reply #9 on: January 07, 2013, 06:27:23 pm »
Chipmunk's physics engine allow you to create such a thing, actually, it's just a matter of having joints.
Pretty much the same thing as : http://developer.coronalabs.com/content/chains (not the same eaxc syntax, but pivot/pin(?) joints on the bodies and boom there you go.

Now with the speed, it's still slow on the calc, but it's worth trying, just to test what rope physics give, with chipmunk.
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline Nick

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1166
  • Rating: +161/-3
  • You just got omnom'd
    • View Profile
    • Nick Steen
Re: [Lua] Rope Physics
« Reply #10 on: January 08, 2013, 02:13:26 am »
Chipmunk's physics engine allow you to create such a thing, actually, it's just a matter of having joints.
Pretty much the same thing as : http://developer.coronalabs.com/content/chains (not the same eaxc syntax, but pivot/pin(?) joints on the bodies and boom there you go.

Now with the speed, it's still slow on the calc, but it's worth trying, just to test what rope physics give, with chipmunk.
that's exactly what I did, there's no difference I guess

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: [Lua] Rope Physics
« Reply #11 on: January 08, 2013, 02:28:22 am »
Good :)

(I just tried your .tns -> it's so cool on TINCS that you will be making everyone lose time :x lol congratz)

We should try to make it with chipmunk too and see how it compares to your code, speed-wise, on TINCS it probably will be the same, on the device I don't know.
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline Nick

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1166
  • Rating: +161/-3
  • You just got omnom'd
    • View Profile
    • Nick Steen
Re: [Lua] Rope Physics
« Reply #12 on: January 08, 2013, 02:36:09 am »
(I just tried your .tns -> it's so cool on TINCS that you will be making everyone lose time :x lol congratz)
how do you mean lose time?

We should try to make it with chipmunk too and see how it compares to your code, speed-wise, on TINCS it probably will be the same, on the device I don't know.
It'll be way better, I'm sure of that, but I never tried chipmunk on calc (still 3.1)
« Last Edit: January 08, 2013, 02:36:19 am by Nick »

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: [Lua] Rope Physics
« Reply #13 on: January 08, 2013, 06:02:00 am »
(I just tried your .tns -> it's so cool on TINCS that you will be making everyone lose time :x lol congratz)
how do you mean lose time?
Because it's so fun I keep moving the rope around my screen and watch it unfold, instead of working. (Poor me :D)

We should try to make it with chipmunk too and see how it compares to your code, speed-wise, on TINCS it probably will be the same, on the device I don't know.
It'll be way better, I'm sure of that, but I never tried chipmunk on calc (still 3.1)
Jim can quickly code that and test, I'm sure. (/me runs ?)
« Last Edit: January 08, 2013, 06:02:35 am by adriweb »
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline ElementCoder

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 611
  • Rating: +42/-2
    • View Profile
Re: [Lua] Rope Physics
« Reply #14 on: January 08, 2013, 10:51:36 am »
It works a little bit nice when I reduced the timer to 0.04 instead of 0.01 and instead of drawing 500 segments with length 1, drawing 6 segments of length 25. But it still doesn't work as we all would like it to.

Some people need a high five in the face... with a chair.
~EC