I am making a baseball game and I'm having trouble with making the ball go to a random x and y position. I can make the ball be hit, but I want it to be random power. Like sometimes it goes far and sometimes it stays in the infield. But right now it only goes far. Here's the code:
ActionScript Code:
onClipEvent (load) {
i = 15;
k = -Math.PI+Math.random()*Math.PI;
this._xscale = this._yscale=50+Math.random()*100;
this._alpha = 75+Math.random()*100;
}
onClipEvent (enterFrame) {
rad += (k/180)*Math.PI;
this._x -= Math.cos(rad);
this._y -= i;
if ((this._x>=movieWidth) || (this._x<=0)) {
}
}
onClipEvent (enterFrame) {
if (_root.hitball.hitTest(_root.leftfouline)) {
trace("FOUL!");
}
}
Any help is appreciated. Thanks.