Author Topic: linear momentum  (Read 3532 times)

0 Members and 1 Guest are viewing this topic.

Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
linear momentum
« on: January 20, 2011, 02:35:27 am »
How would you go about programming linear momentum in the x axis? for instance starting slow then easing into fast and when you stop pressing the arrow keys it takes a while to stop.
In-progress: Graviter (...)

Offline Binder News

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 785
  • Rating: +46/-3
  • Zombie of Tomorrow
    • View Profile
Re: linear momentum
« Reply #1 on: January 20, 2011, 06:36:41 am »
I have an example of this.
It uses GDB1XS (I think) for the X speed. I used data for everything. Very few actual vars used.
Feel free to modify, but please give me credit.
« Last Edit: January 20, 2011, 06:40:01 am by Binder News »
Spoiler For userbars:







Hacker-in-training!   Z80 Assembly Programmer     Axe Programmer
C++ H4X0R             Java Coder                           I <3 Python!

Perdidisti ludum     Cerebrum non habes

"We are humans first, no matter what."
"Fame is a vapor, popularity an accident, and riches take wings. Only one thing endures, and that is character."
Spoiler For Test Results:





Offline squidgetx

  • Food.
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1881
  • Rating: +503/-17
  • rawr.
    • View Profile
Re: linear momentum
« Reply #2 on: January 20, 2011, 07:19:17 pm »
Basically you'd have a velocity and a change-in-velocity variable. Every frame velocity is increased by the change in velocity. Pressing keys would increase the change in velocity, and if no keys are pressed and the velocity is not 0, the velocity would decrease.

Or something like that (note: I didn't look at Binder News' program yet :P)
« Last Edit: January 20, 2011, 07:19:38 pm by squidgetx »

Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
Re: linear momentum
« Reply #3 on: January 20, 2011, 09:57:33 pm »
@Binder News could you document your code? I don't fully get what some of it means.
Or you could just explain what it means or something.
In-progress: Graviter (...)