A Flash Developer Resource Site

# Thread: [F8] Throw Curve..

1. ## [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;

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. anyone?

3. ## 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
•

 » Home » Movies » Tutorials » Submissions » Board » Links » Reviews » Feedback » Gallery » Fonts » The Lounge » Sound Loops » Sound FX » About FK » Sitemap

Click Here to Expand Forum to Full Width