Page 1 of 1

mysterious bouncing umlauts

Posted: Sat Apr 25, 2009 12:51 am
by refill
Hello masses. Making a first post to (somewhat predictably) ask some noob physics questions.
First I should say I'm amazed at how easy love is to use. I'm someone who's failed gloriously on every attempt to learn a language more complex than javascript, and in less than 3 days poking around with love I have something recognizably game-like.Which I've attached. It has Gravity! It has Collisions! It has Umlauts! What more could you ask? Up, Left, and Right are the only inputs. Sadly the tutorials seem to end before physics so on to the noob questions:

You'll notice it bounces. This is on purpose. Mysteriously though it doesn't lose any energy doing so, and bounces forever. I don't fully understand the collision function yet but is there a way to make it react more realistically?

On a related note, if I drag the window up or down while it's bouncing, it occasionally either teleports the character into the air or superbounces it (it's hard to tell). Also mysterious.

Increasing my impulseModifier variable increases the speed, but only up to a point. Nothing I've been able to do will make the character move faster than he is now. Mass and Inertia also only affect it to a certain point. Made all the more frustrating by the fact that it's moving almost fast enough for my liking.

Also, if anyone feels like poking around the code (it's small!), could you tell me if anything is redundant/inefficient/ugly? It would be nice to not develop bad habits right away. Sorry about the question barrage :death: . Any help or links to help is appreciated :nyu: .

Re: mysterious bouncing umlauts

Posted: Sat Apr 25, 2009 5:48 am
by bartbes
refill wrote:On a related note, if I drag the window up or down while it's bouncing, it occasionally either teleports the character into the air or superbounces it (it's hard to tell). Also mysterious.
Most likely because you experience a huge framedrop while doing so, thus making it skip a few frames.
refill wrote: Increasing my impulseModifier variable increases the speed, but only up to a point. Nothing I've been able to do will make the character move faster than he is now. Mass and Inertia also only affect it to a certain point. Made all the more frustrating by the fact that it's moving almost fast enough for my liking.
Known bug: Movement is capped at 200 units/second, note I used units/second, not pixels/second, this is because Box2D isn't designed for use with pixels. Solution: Scale (CAMERA is nice for that purpose) or multiply the dt value that your physics update gets, if you multiply it by two, the entire physics go twice as fast.

Re: mysterious bouncing umlauts

Posted: Sat Apr 25, 2009 7:38 am
by refill
Thanks bartbes, dt = dt*2 worked like a charm, but it almost seems too easy. And the old version now looks hilariously slow in comparison.
The infinite bouncing problem was me setting Restitution > 1 while I was wrecking the physics trying to make it go faster. :megagrin: I am smrt. I can use much more reasonable values now and everything is running much nicer.
The superbouncing bug maybe I didn't explain very well, dragging the window would cause the FPS drop, yeah, but when I release it the ball is way higher that it would have been able to get using the forces available to it. If y is the max bounce height, the ball would be at y+50. Probably caused by the restitution thing too though, so I think that's the last I've seen of it.

Re: mysterious bouncing umlauts

Posted: Sat Apr 25, 2009 7:45 am
by bartbes
If it isn't it might still be that framedrop, where the code isn't slowing down fast enough. (so the ball already is too high before the code recognizes and applies the correct gravity setting) Don't know if it's the case, or if it's possible, but I thought it was worth saying.