# Wardzr

Members

5

• Rank
Newbie
1. ## How to time frames to make it completely predictible and smooth on all framerates

Thanks Antriel, the article was very helpful as is the entire website, especially for someone just getting into it like me.
2. ## How to time frames to make it completely predictible and smooth on all framerates

I'm working on a personal project where a simple sprite makes its way down a path aided by a simple physics engine. I need the animation to be completely predictable so that I can set an end state (say, sprite.y > 2000) and given the same start state, the sprite will take the exact same path and reach the exact same end state every single time, regardless of frame rate or lag. This first part I've easily solved by just tying it to requestAnimationFrame and not using any delta in my calculations, thus, every frame is completely determined by the previous frame with no wiggle room and the system is completely deterministic. However as you might guess this means that if I run my animation at 30fps it will look like it's slowed down, and if I run it at 120, it looks like it's sped up. I can make it look smooth on all framerates by either imposing my own timer or actually using the delta in my movement calculations, but then the system stops being completely deterministic. What's the best way of making it look at least OK on all framerates while keeping it completely deterministic?
3. ## Garwin model in Pixijs?

Aparently there was a typo in the article I linked. In the angular speed function, the tangential speed (Rw1) should be multiplied by "a - ex" instead of "a(1 + ex)". Just in case someone else has the same issue. The new code becomes let alfa = 0.4, cor = { x: 0.8, y: 0.8 } cat.radius = 32; function enhancedBounce() { let vx = (((1 - (alfa * cor.x)) * cat.vx) + ((alfa * (1 + cor.x)) * cat.vr * cat.radius)) / (1 + alfa); let vr = ((1 + cor.x) * cat.vx + (alfa - cor.x) * cat.radius * (cat.vr)) / (cat.radius * (1 + alfa)); cat.vr = vr; cat.vx = vx; cat.vy = -cor.y * cat.vy ; }
4. ## Garwin model in Pixijs?

Yes please, move it. In the mean time I'll add a description for those velocities. And yeah, I realize I used pixi just to draw the scene.
5. ## Garwin model in Pixijs?

Hello, I've been trying to implement some simple physics simulation in pixi, involving a ball (circle) that bounces around and spins. I've managed to aproximate a pretty good model myself but the movement always becomes awkward when the ball begin to slow down so I tried to use the Garwin model I found here. However, something must be wrong with either the way I applied the functions or the MUs i'm using because as the ball settles to the floor it begins to accelerate exponentially. This is my bounce function: let alfa = 0.4, cor = { x: 0.8, y: 0.8 } cat.radius = 32; function enhancedBounce() { let vx = (((1 - (alfa * cor.x)) * cat.vx) + ((alfa * (1 + cor.x)) * cat.vr * cat.radius)) / (1 + alfa); let vr = ((1 + cor.x) * cat.vx + alfa * (1 + cor.x) * cat.radius * (cat.vr)) / (cat.radius * (1 + alfa)); cat.vr = vr; cat.vx = vx; cat.vy = -cor.y * cat.vy ; } Where cat.vx and cat.vy are velocity components and cat.vr is the angular velocity of the ball. Now I'm pretty bad at math but it seems that whatever I input into the functions as vx and vr, the output of both functions is greater than those values (vr' > vr and vx' > vr) which seems counterintuitive to me, however, since I'm not good enough at math I can't demonstrate that this is in fact the case. cat.vx and cat.vr are just added to cat.x and cat.y on every render function render() { if(cat.x >= sceneHeight - 32) { enhancedBounce(); } cat.x += cat.vx; cat.y += cat.vy; cat.rotate += cat.vr; } The function performs well when the ball is simply bouncing off the ground with the rotation and x-velocity looking nice but the moment the ball rests on the ground and enhancedBounce() is called every frame, it accelerates as stated before. Any idea what i'm doing wrong?