Author Topic: Physics help  (Read 4438 times)

0 Members and 1 Guest are viewing this topic.

Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Physics help
« on: June 23, 2011, 09:18:10 am »
this question could really go anywhere dev-related, but since my game's being programmed in java i put it here.

Are there any equations which, given a constant horizontal speed, will give a gravitational constant and an acceleration constant (intial upward velocity for when the character jumps) given that the height and length of the jump must remain constant?

i.e., i've programmed my game using a speed of 3 pixels/frame and tweaked the upward velocity and gravity until i liked the height/length of the character's jump. now i want to be able to have a speed of say 6 pixels/frame and have an equation which calculates the upward velocity and gravity so that the height/length of the jump isn't changed from my 3 pixels/frame speed.

i know that x = x0 + v0t + .5at2, but i am unsure if that can be applied in this case, and if so how.

thanks for the help!


Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: Physics help
« Reply #1 on: June 23, 2011, 06:27:03 pm »
bump, anyone?


Offline ben_g

  • Hey cool I can set a custom title now :)
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +125/-4
  • Asm noob
    • View Profile
    • Our programmer's team: GameCommandoSquad
Re: Physics help
« Reply #2 on: June 23, 2011, 06:30:40 pm »
if you've doubled the walking speed, wont just doubelling the other speeds work?
My projects
 - The Lost Survivors (Unreal Engine) ACTIVE [GameCommandoSquad main project]
 - Oxo, with single-calc multiplayer and AI (axe) RELEASED (screenshot) (topic)
 - An android version of oxo (java)  ACTIVE
 - A 3D collision detection library (axe) RELEASED! (topic)(screenshot)(more recent screenshot)(screenshot of it being used in a tilemapper)
Spoiler For inactive:
- A first person shooter with a polygon-based 3d engine. (z80, will probably be recoded in axe using GLib) ON HOLD (screenshot)
 - A java MORPG. (pc) DEEP COMA(read more)(screenshot)
 - a minecraft game in axe DEAD (source code available)
 - a 3D racing game (axe) ON HOLD (outdated screenshot of asm version)

This signature was last updated on 20/04/2015 and may be outdated

Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: Physics help
« Reply #3 on: June 23, 2011, 09:30:44 pm »
if you've doubled the walking speed, wont just doubelling the other speeds work?

i tried that and it does not work. the height and length of the jump vary still


Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
Re: Physics help
« Reply #4 on: June 23, 2011, 09:32:44 pm »
Can you clarify your question? I thought y-movement is generally independent from x-movement, and since you said walking speed is constant, x = x0 + v0t + .5at2 wouldn't really make much sense.
In-progress: Graviter (...)

Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: Physics help
« Reply #5 on: June 23, 2011, 09:42:07 pm »
Can you clarify your question? I thought y-movement is generally independent from x-movement, and since you said walking speed is constant, x = x0 + v0t + .5at2 wouldn't really make much sense.

ok, so i have the variables x, y, and yVel. there's also the constants XVEL, GRAVITY, and JUMP_FORCE. XVEL is how many pixels the character moves right each frame. GRAVITY is how many pixels the character falls each frame (if it can fall). JUMP_FORCE is the initial upward velocity when the user presses space (makes the character jump). i tweaked my engine so that the character jumps at a desire length/height. but now i want to double XVEL, making the character move twice as fast. however, now i need to tweak GRAVITY so that the character falls faster, in order to make sure the length of the jump remains constant. but because i tweaked GRAVITY, now JUMP_FORCE needs to be modified so the height of the jump remains constant as well. however, i don't know how much to modify these constants. and it isn't as simple as doubling GRAVITY and JUMP_FORCE, i already tested that.


edit: alright, i think i've found an equation. if XVEL is multiplied by p, JUMP_FORCE is multiplied by p and GRAVITY is multiplied by p^2.

right now i'm trying to tweak my engine so i can get some data (e.g. what's GRAVITY and JUMP_FORCE when XVEL is multiplied by 2? multiplied by 3? etc...) and then use a regression to find an equation from that. but i was wondering if anyone knew how to figure out the equation mathematically.
« Last Edit: June 23, 2011, 09:54:05 pm by nemo »


Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Physics help
« Reply #6 on: June 24, 2011, 07:40:00 am »
I don't have an answer, if you don't get one here, I suggest Maths and Science forum :) Sorry :(