Input States

public void updateobj()
{

//respond to the user input

if (isTouched && !wasTouched )
{
//first touch
//change the color
fColor = color(255,0,0);
//remember the velocity 
lastXVel = xVel;
lastYVel = yVel;

//stop the velocity
xVel = 0;
yVel = 0;

println("first touch");
}
else if ( isTouched && wasTouched )
{
//start dragging or something
//change the color
fColor = color(255,0,0);
xVel = 0;
yVel = 0;
println("continue to touch");

}
else if (!isTouched && wasTouched )
{
//change the color to green
fColor = color(0,255,0);

//apply normal velocity
xVel = lastXVel;
yVel = lastYVel;

println("first not touch after a touch");
}
else
{
//i haven't been interacted with in some time
//im bored, let me do something else

if(++ticks>tickThreshold)
{ //on some interval, change direction
ticks = 0;
randomVelocity();
}

println("not touched && wasnt touched");
}

//respond to the environment
 //bounce off the edge
//collide with something else

//update position based on velocity
xLoc += xVel;
yLoc += yVel;

}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s