|
-
[Help]/[Problem] Help with Archery Sim
Hi, I have been looking around all over the web to find useful hints and code that can help me accomplish what I am trying to do.
I want to create a archery game. Yes I know, its been done too many times, right? But I got interested in doing one as my first game. Now I just started reading up on ActionScript 2.0 and I am using Flash 8 Pro for this game. I am at the point where I want to simulate the flight of an arrow, like it would fly in the real world. So right now, I want to shoot a arrow (at a constant speed and angle, for now) and I want it to fly across the screen as it would in real life.
The archery game environment is from left to right, meaning you start off from the left and enemies com from the right. And you shoot to the right (but can also shoot to the left, up down, and any other direction) you can also move around freely to a certain point.
I really suck at this trig stuff you have to use to simulate the flight of a arrow but right now, this is what I have for code. NOTE: this code is placed onto the first frame on a layer called "actions" the actual arrow (which is a movie clip) is on another layer called "arrow" with a instance name of arrow1 and movie clip name of arrow. Also the registration point on the arrow MC is in the middle, and I drew the arrow facing to the right so like this: ---->
Code:
var angle = 45;
var rAngle = angle - 90;
arrow1.onEnterFrame = function(){
var speed = 5;
this._x += speed * Math.sin( angle * Math.PI / 180 );
this._y += speed * Math.cos( angle * Math.PI / 180 );
this._rotation = rAngle;
angle -= 1;
rAngle += 1;
};
function rotation(dx:Number, dy:Number):Number {
return Math.atan2(dy, dx) * 180/Math.PI;
}
So any help that anyone can give me will be greatly appreaciated. I have tried other forums but they never respond or have no information on what I am trying to do exactly.
Last edited by gouf08; 08-07-2007 at 05:39 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|