Return to Snippet

Revision: 52887
at November 4, 2011 02:47 by parkerkrhoyt


Initial Code
function sample()
{
  vmax = latest.x + 0.25;			
  vmin = latest.x - 0.25;			
  vrange = 0.50;	
	
  hmax = latest.y + 0.25;			
  hmin = latest.y - 0.25;			
  hrange = 0.50;
}

function move()
{
  var hposition = 0;
  var vposition = 0;
	
  vposition = ( ( ( latest.x - vmin ) / vrange ) * BRICKS_SPACE ) + BRICKS_MAXIMUM;
  hposition = ( ( latest.y - hmin ) / hrange ) * LEGS_SPACE;		

  // Keep in bounds
  if( vposition > BRICKS_MAXIMUM )
  {
    vposition = BRICKS_MAXIMUM;
  } else if( vposition < BRICKS_MINIMUM ) {
    vposition = BRICKS_MINIMUM;
  } 
	
  if( hposition < LEGS_MINIMUM )
  {
    hposition = LEGS_MINIMUM;
  } else if( hposition > LEGS_MAXIMUM ) {
    hposition = LEGS_MAXIMUM;
  } 		
	
  $( '#background' ).css( 'top', vposition );	
  $( '#legs' ).css( 'left', hposition );		
}

Initial URL

                                

Initial Description

                                

Initial Title
Capturing Relative Accelerometer Tilt

Initial Tags
data

Initial Language
JavaScript