A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Enemy movement

Threaded View

  1. #1
    Flash Incompetent ChaseNYC's Avatar
    Join Date
    Jun 2002
    Location
    new york city
    Posts
    693

    Enemy movement

    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
    Code:
    this._y+=this.speedY+bgSpeed;
    this._x+=this.speedX;
    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:
    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;
    				
    		}
    anyways, thanks in advance...

    ChaseNYC
    Attached Images Attached Images
    mmm signature

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center