I am working with the example 9-7 ball from the book "Programming Interactivity". When I run the example code I get an unexpected token type error. Now I am very new to Processing and C. This being the case my debuging ability is very limited. Any suggestions?
class Ball { PVector location; PVector velocity; PVector acceleration; float mass = 20; // how heavy are we float maximum_velocity = 20; // use this to make sure things dont get to fast float bounce = 1.0; // how bouncy? higer gains speed, lower loses speed
Ball(){ acceleration = new PVector (0.0, 0.0, 0.0); location = new PVector (0.0, 0.0, 0.0); velocity = new PVector (1.0, 0.0, 0.0);
} //Modified from original per errata notes on book void addForce(PVector force) { //Original: void addForce(Vector3D force){ force.div(mass); // make sure the force is modified by the mass acceleration.add(force); // the acceleration is affected by the force }
void update(){ velocity.add(acceleration); //add acceleration to velocity velocity.limit(maximum_velocity); location.add(velocity); // the acceleration all comes from the forces on the Ball which are reset // each frame so we need to reset the acceleration to keep things within // bounds correctly acceleration.set(0,0f, 0.0f, 0.0f);