class Camera { final float CAMERA_VELOCITY = 1.0; final float CAMERA_EASING = 4.0; PVector rot; int[] run = { 1, 1, 1 }; Timer timer; Camera() { timer = new Timer( 4000 ); rot = new PVector(); } void Update( GameTime time ) { timer.Update( time.Delta ); //Update the camera axis with their change. rot.x -= (CAMERA_VELOCITY * time.DeltaF * run[0])/CAMERA_EASING; rot.y -= (CAMERA_VELOCITY * time.DeltaF * run[1])/CAMERA_EASING; rot.z -= (CAMERA_VELOCITY * time.DeltaF * run[2])/CAMERA_EASING; } void Kick() { //If we kick, change axis if ( timer.IsDone() ) { timer.Reset(); ToggleAxis( (int)random( run.length ) ); } } void Apply() { //translate(width/2, height/2, -800); rotateX(-rot.x); rotateY(-rot.y); rotateZ(-rot.z); } void Remove() { rotateZ(rot.z); rotateY(rot.y); rotateX(rot.x); } void ToggleAxis( int i ) { run[i] = ( run[i] != 0 ) ? 0 : floor( random( -1, 2 ) ); } }