Hi, I'm picking back up on a space shooter I was making a while ago, and I just can't seem to get this one part down... this is actually why i stopped, so hopefully someone can help. I have been working on enemy movement and I have a few different movement types down but I can't seem to get curved movement down. attached is a diagram of what I'm trying to achieve, roughly, I can't even draw a good curved line but I think you get the idea...
the one on the left is easy, just
with some if statements for when to change the x direction but i can't seem to get a seemless curve down... Any help, hints, ideas would be of great use. I tried the following code which is a complete flop but I'm including it so you know I've tried things and am not just lazily asking for someone to do it for me:Code:this._y+=this.speedY+bgSpeed;
this._x+=this.speedX;
anyways, thanks in advance...Code:if(this.moveType==3){
if(this._x>=this.startX){
this.dFrmStart=this._x-this.startX;
}else if(this.startX>this._x){
this.dFrmStart=this.startX-this._x;
}
if(this.dFrmStart>this.maxDist){
this.speedX=this.speedX*(-1);
}
if(this.dFrmStart==0){
this.dFrmStart=.01;
}
this.speedMod = (this.dFrmStart/this.maxDist);
this.speedMod = 1 - this.speedMod;
if(this.speedMod<0.1){
this.speedMod=0.1;
}
if(this.speedMod==0){
this.speedMod=1;
}
this._y+=(this.speed)+bgSpeed;
this._x+=this.speedX*this.speedMod;
}
ChaseNYC
