Skip to content

Instantly share code, notes, and snippets.

@akashkgarg
akashkgarg / fixElapsedTime.m
Created September 16, 2012 15:44
Avoiding the Spiral of Death in Flick a' Fruit
- (void) step:(ccTime)elapsedTime
{
// Fix the time elapsed to avoid the spiral of death
if (elapsedTime > 0.2)
elapsedTime = 0.2
// Do physics time-stepping.
_dtAccumulator += elapsedTime;
while (_dtAccumulator >= _dt) {
@akashkgarg
akashkgarg / gist:3730592
Created September 16, 2012 00:46
Physics time-step function in Flick a' Fruit
- (void) step:(ccTime)elapsedTime
{
// Do physics time-stepping.
_dtAccumulator += elapsedTime;
while (_dtAccumulator >= _dt) {
// Take the actual physics step with step-size _dt
cpSpaceStep(_space, _dt);
_dtAccumulator -= _dt;
@akashkgarg
akashkgarg / fibs.hs
Created August 31, 2012 18:33
Computing the Fibonacci Sequence
fibs :: [Integer]
fibs = 1 : 1 : zipWith myadd fibs (tail fibs)
where myadd x y = trace (" Adding: " ++ show x ++ " & " ++ show y ++ "\n")
(x+y)