struct velocity,position,acceleration { //not sure if this type of declaration is valid
int x;
int y;
};
class ball {
public:
ball(position,velocity,accleration,friction); //constructor
velocity getVelocity() return vel; //returns the current velocity
velocity setVelocity(velocity); //sets the velocity returns the previous velocity
position getPosition() return pos; //returns the current position
position setPosistion(position); //sets the position returns the previous position
position update(); //updates the position returns the new position *****acceleration and friction not factored in***
/*
acceleration getAccleration() return acc; *******NOT IMPLEMENTED*********
acceleration setAcceleration(accleration); *******NOT IMPLEMENTED*********
int getFriction() return friction; *******NOT IMPLEMENTED*********
int setFriction(int); *******NOT IMPLEMENTED*********
*/
private:
velocity vel;
position pos;
acceleration acc;
int friction;
};
class paddle {
public:
paddle(position,velocity,width,height); //constructor
};
ball::ball(position p, velocity v,acceleration a,int f) {
pos.x = p.x;
pos.y = p.y;
vel.x = v.x;
vel.y = v.y;
acc.x = a.x;
acc.y = a.y;
friction = f;
}
velocity ball::setVelocity(velocity v) {
velocity temp;
temp.x = vel.x;
temp.y = vel.y;
vel.x = v.x;
vel.y = v.y;
return temp;
}
position ball::setPosition(position p) {
position temp;
temp.x = pos.x;
temp.y = pos.y;
pos.x = p.x;
pos.y = p.y;
return temp;
}
position ball::update() {
pos.x += vel.x; //add x velocity
pos.y += vel.y; //add y velocity
return pos; //return new velocity
}
Formerly known as Wachar <- Thrander <- Tazel