dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [F8] Throw Curve..

  1. #1
    Senior Member
    Join Date
    Nov 2004
    Location
    I'm a brumie, currently in London working for the man
    Posts
    147

    [F8] Throw Curve..

    Hi guys.. i'm coding up a throwing game and have run into a problem in regards to the curve .. ie the object (Jav) goes up and then comes back down... problem is this doesn't look smooth.. and i'm not sure it's the best way of writing the script.. but i'm stumped at what else to do.. here's my present code.
    Code:
            var angle:Number = 0;
    	var speed:Number = 0;
    	var gravity:Number = 8.9;
    	var deg2rad:Number = Math.PI/180;
    	var distance:Number = 0;
    	var dir:Boolean = false;
    
    function throwJavelin() {
    
    		var time = 2*speed*Math.sin(angle*deg2rad)/gravity;
                    distance = Math.cos(angle*deg2rad)*speed*time;
    
    		jav.onEnterFrame = throwMove;
    	}
    
    function throwMove() {
    
                    //Moves the Background
    		bg_clip._x -= 16;
    
                    //Text Out Put Visual
    		jav.angle.text = disY+1+" Metres ";
    		
                    //Distance Counter.
                    disY += 1;
    
                    //Not sure about this var, if it does what it's meant to.
    		var gforce = angle/gravity;
    		//
    
                   /* if Statement which controls the direction, it says once the jav gets to half of the calculated distance start decent... this is where it isn't very smooth */
    
    		if (disY>distance/1) {
    			dir = true;
    		}
    		
    		if (dir) {
    
    			trace("down");
    			
    			jav._rotation +=0.5;
    			thrower._x -= 15;
    		
    			this._y += 3;
    			
    			if(angle>=40){
    			
                            //Moves Movie Clips in scene.
    			thrower._y -= gforce;
    			bg_clip._y -= gforce-0.8;
    		
                   }else if (!dir) {
    
    			trace("up");
    			;
    			thrower._x -= 15;
    			
    			if(angle>=25){
    			this._y -= 2
    			thrower._y += gforce;
    			bg_clip._y += angle/gravity;
    	       }
    
                  if (this.hitTest(floor)) {
    				endThrow();
    			}
    
    	}
    Any help would be lovely.. as i'm stumped..

    Andy.

  2. #2
    Senior Member
    Join Date
    Nov 2004
    Location
    I'm a brumie, currently in London working for the man
    Posts
    147
    anyone?

  3. #3
    Senior Member
    Join Date
    Nov 2004
    Location
    I'm a brumie, currently in London working for the man
    Posts
    147

    Hi

    Ok I'm still slightly stuck..

    Could anyone point me at a resource that deals with this issue?

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