This week's book giveaway is in the Agile and Other Processes forum. We're giving away four copies of Real-World Software Development: A Project-Driven Guide to Fundamentals in Java and have Dr. Raoul-Gabriel Urma & Richard Warburton on-line! See this thread for details.
I'm able to create a simple jump in a side scroller (rise and fall at the same rate), but I'm for some reason unable to get a nice "rise at a slower and slower rate, peak, fall at a faster and faster rate" smooth arc. Does anyone have any ideas that might point me in the right direction? So far I have this, which rises at a slower(ish) rate over time, peaks smoothly, but then falls at a pretty slow rate. When a jump is performed by pressing a key, yVel is set to -10 and increases until it reaches just under 10 which does cause the object to rise then fall, just not how I'm looking for.
EDIT: Jeez, I hate it when a solution is so simple it's the last thing you think of. I've got it working now, but if anyone wants to contribute your own ideas of one, feel free to go ahead.
well... i know nothing about physics, but wat i have come up with that will fit your needs perfectly is the set of code below:
basically, it calculates the new x coordinate by taking x and adding it to the x axis speed minus friction. It calculates the new y coordinate by adding the current y to gravity plus y axis speed plus equals to gravity minus friction. you shall get a nice upward spring that gradually will make the object follow a arc... an arc like a really ball or something like that would look. so its realistic. if you need each jump to be successively smaller, this doesnt account for that. it performs the same jump arc every time... so, for wat i think you need, this will work just fine. Also, dont set friction or grav to like 3... it needs to be like 0.25 or 1.11... try it, and, if it does what i think itll do, you know why not to do it. oh, the variables need to be doubles... and yspd MUST be limited to a value below 20... it would do the same thing as setting the gravity and\or the friction to a big number... . variables: Friction(fric), x axis speed(xspd), gravity(grav), y axis speed(yspd). oh, to make the object jump, you need to put in the keylistener this little piece of code: Y*=-1;
We've gotta get close enough to that helmet to pull the choke on it's engine and flood his mind! Or, we could just read this tiny ad: