Hello there.
I have started a FPS game with CS5.5.
So far i have done a background, the aim which moves with the mouse and the gun which also moves with the mouse but only on X axis.
But now i have no idea how to start with bullet going from the Gun to the Aim (mouse).
I know its some trigonometry involved though. I have tried something but only succeded in making the bullets going from the gun at some degrees up.
Can anyone help me on this?
This is the code so far :
import flash.events.KeyboardEvent;
import flash.events.Event;
import flash.display.MovieClip;
import flash.utils.Timer;
import flash.display.Sprite;
import fl.motion.DynamicMatrix;
import flashx.textLayout.accessibility.TextAccImpl;
import flash.display.Sprite;
import flash.display.Shape;
import flash.ui.Mouse;
import flash.events.MouseEvent;
stage.addEventListener(MouseEvent.MOUSE_MOVE, aiming);
Mouse.hide();
function aiming(event:MouseEvent):void
{
aim.x=mouseX;
aim.y=mouseY;
gun1.x=mouseX+225;
if(aim.x<0)
{
aim.x=0;
}
if(aim.x>800)
{
aim.x=800;
}
if(aim.y<0)
{
aim.y=0;
}
if(aim.y>600)
{
aim.y=600;
}
if(gun1.x>850)
{
gun1.x=850;
}
if(gun1.x<110)
{
gun1.x=110;
}
}
stage.addEventListener(MouseEvent.MOUSE_DOWN,pressShoot);
function pressShoot(event:Event)
{
trace("mouse is pressed");
gun1.gotoAndPlay(2);
}
Thanks in advance for any help.