class ballBehavior extends Sup.Behavior{
constructor(ball)
{
super(ball);
let ballActor = new Sup.Actor("Ball");
ballActor.setPosition(0, 0, 0);
let ballAngle = 0;
let ballPosition = new Sup.Math.Vector3;
let ballVelocity = 0;
ballActor.addBehavior(ballBehavior);
}
update(){
this.ballAngle += this.ballVelocity;
//Constrains the angle between 0 and 2pi
if(this.ballAngle > Math.PI * 2){
this.ballAngle = 0 + this.ballAngle - Math.PI * 2;
}else if (this.ballAngle < 0){
this.ballAngle = Math.PI - this.ballAngle + Math.PI * 2;
}
//Maybe a little spinback on the pointer?
this.ballPosition = new Sup.Math.Vector3(Math.cos(this.ballAngle) * wheelActor.getLocalScaleX() * 100 / 100,
Math.sin(this.ballAngle) * wheelActor.getLocalScaleX() * 100 / 100, 0);
if(Sup.Input.wasKeyJustPressed("LEFT")){
this.ballVelocity = 0.5;
}
}
}