Shooting Bullets

Ok well I just started scripting little games in flash about
a month ago and now i feel like trying to create my own game
instead of constantly following tutorials. I'm trying to create a
game sort of like space shooter and i am only doing this just to
learn how to make objects shoot bullets and hit other objects. The
problem is, my coding is different than any of the other space
shooter games. I dont attach movies, rather i like to code on the
movie clip itself. Could someone please veiw my coding and tell me
how to make a new bullet fire everytime i press the space bar?
Thank you for your time.
-Timur

you really should place your codes on the timeline rather
than 'attaching' it to Object instances - this is a 'best practice'
and has been eliminated in AS3 for a variety of reasons. it makes
it much easier to debug and even 'find' your code, as well as
making path structure much simpler.
however, what you need is to add another conditional
statement for:
if(Key.isDown(Key.SPACE)) { ... }
then you will need to use attachMovie to place a 'bullet'
clip on the main stage. the clip will need to be passed a
trajectory angle, and then be moved by a loop either within the
clip or on the main timeline. Then additionally within the loop you
will want to run hitTest checks using a shapeflag parameter on the
bullet's current x/y position, against all other objects currently
within the viewing area. These instances should most likely be
contained within an Array that you can loop through for this
purpose, so each time a new 'enemy' is brought to the stage, you
should also add it to the Array.
This is only a bit of what you will need to do here, but it
should get you started.
PS. there is a basic example of these types of functions
HERE

Similar Messages

  • Create object without instance name

    hi
    here is the problem , i have hero shoot bullets and because of that i cant give the objects an instance names and i wanna check if the object on the stage or not and that is easy when
    i do    var bullet:BULLET = new BULLET
    if (bullet.stage){
    addChild(bullet)
    but the problem that when i do like this
    addChild(new BULLET())
    i know that , flash give them a names but how can i check their names??
    if(???.stage)
    thank you

    Per Ned's suggestion you should use some structure. Because it seems you will use animations of large numbers of objects - Vector is the best because it is faster than Array.
    Here is an example in two iterations - first as timeline code (just paste it on timeline), and below - as document class - you can use it by placing it into the same directory as your fla and assign doc class to Shooter:
    import flash.display.Sprite;
    import flash.events.Event;
    var bullets:Vector.<BULLET>;
    init();
    function init():void
        makeBullets();
        placeBullets();
        shoot();
    function shoot():void
        addEventListener(Event.ENTER_FRAME, moveBullets);
    function moveBullets(e:Event):void
        for each (var b:BULLET in bullets)
            b.x += 10;
    function placeBullets():void
        var nextX:Number = 0;
        for each (var b:BULLET in bullets)
            addChild(b);
            b.y = stage.stageHeight * .5;
            b.x = nextX;
            nextX -= b.width * 2;
    function makeBullets():void
        var numBullets:int = 500;
        bullets = new Vector.<BULLET>();
        while (numBullets--)
            bullets.push(new BULLET());
    Class:
    package
        import flash.display.Sprite;
        import flash.events.Event;
        public class Shooter extends Sprite
            private var bullets:Vector.<BULLET>;
            public function Shooter()
                init();
            private function init():void
                makeBullets();
                placeBullets();
                shoot();
            private function shoot():void
                addEventListener(Event.ENTER_FRAME, moveBullets);
            private function moveBullets(e:Event):void
                for each(var b:BULLET in bullets) {
                    b.x += 10;
            private function placeBullets():void
                var nextX:Number = 0;
                for each(var b:BULLET in bullets) {
                    addChild(b);
                    b.y = stage.stageHeight * .5;
                    b.x = nextX;
                    nextX -= b.width * 2;
            private function makeBullets():void
                var numBullets:int = 500;
                bullets = new Vector.<BULLET>();
                while (numBullets--) {
                    bullets.push(new BULLET());

  • Help Making a SIMPLE JAVA GAME *TINY GLITCH*

    got a tinnnny glitch and ive tried everything to get it to work, but so far no luck.
    Heres what my program does:
    1. Aliens spawn at top left (top 4 rows) and move to the right and dissapear (DONE)
    2. Shooting rectangle at bottom middle (moves left and right) and shoots bullets (DONE)
    3. When bullets make contact with alien the alien dissapears (DONE)
    4. When you shoot 20 bullets game over (DONE)
    5. When all the aliens fly by the screen game over (DONE)
    GLITCH
    1. When an alien is killed any bullet that goes over the exact same spot of collision the bullet dissapears! +so does an alien going over same collision spot
    MISSING
    1. Score, every alien kill + 10 CANNOT get a working score funtion to +10 fo every alien successfully hit :(
    My SRC jus copy and paste and compile, any help appreciated
    http://www.geocities.com/porche_masi/Assignment3.txt
    //ignore spelling mistakes in comments and outputs lol
    ive spent way to many hours over these 2 stupid problems, hope new eyes can spot the problem

    I'm not going to look at your code, but it sounds like when you're killing things you're not removing them from your future calculations. So if an alien is killed, it should either be removed from the list of aliens, or a "dead" flag should be set on it which causes it to be ignored in future calculations.
    edit I did look at your code actually, and that is a really, really bad use of multithreading. You shouldn't just create a new thread every time a bullet is fired. You should maintain a list of bullets, have the main thread drive the UI, and have a secondary thread to update the game logic (recalculate collisions, etc).
    Edited by: endasil on Nov 21, 2007 3:16 PM

  • 1084: Syntax error: expecting rightbrace before end of program.

    So I'm doing this basic coding thing to make an object "shoot" bullets. It's from a tutorial video. My code matches his exactly unless I'm missing a tiny detail. Basically the code looks like this:
    package {
    import flash.display.Sprite;
    import flash.events.Event; 
    public class bullet extends Sprite {
    private var sw:Number;
    private var sh:Number;
    private const _SPEED:int=-10;
    private const _OFFSTAGE:int=-10; 
    public function bullet():void {
    addEventListener(Event.ADDED_TO_STAGE,onadd);
    private function onadd(e:Event):void {
    sw=stage.stageWidth;
    sh=stage.stageHeight;
    addEventListener(Event.ENTER_FRAME,loop);
    private function loop(e:Event):void {
    if (y<_OFFSTAGE) {
    removeEventListener(Event.ENTER_FRAME,loop);
    parent.removeChild(this);
    y-=_SPEED;
    }public function removeListeners():void {
    removeEventListener(Event.ENTER_FRAME,loop); 
    And the compiler error I'm getting says this:
    Location:bullet.as line 31 1084: Syntax error: expecting rightbrace before end of program. Source: }
    Location:bullet.as line 31 1084: Syntax error: expecting rightbrace before end of program. Source: }
    And yes it does say it twice. What's going on?
    The vid I'm learning from is this: http://autocad.spinelink.com/adobe-flash-cs4-game-tutorial-shooting.html

    You are missing two closing curly braces at the bottom of the package declaration. You need to close the package itself and the class declaration inside.
    package {
         import flash.display.Sprite;
         import flash.events.Event;
         public class bullet extends Sprite {
              private var sw:Number;
              private var sh:Number;
              private const _SPEED:int=-10;
              private const _OFFSTAGE:int=-10;
              public function bullet():void {
                   addEventListener(Event.ADDED_TO_STAGE,onadd);
              private function onadd(e:Event):void {
                   sw=stage.stageWidth;
                   sh=stage.stageHeight;
                   addEventListener(Event.ENTER_FRAME,loop);
              private function loop(e:Event):void {
                   if (y<_OFFSTAGE) {
                        removeEventListener(Event.ENTER_FRAME,loop);
                        parent.removeChild(this);
                   y-=_SPEED;
              public function removeListeners():void {
                   removeEventListener(Event.ENTER_FRAME,loop);

  • Help me with this spacecraft game please!

    I have to create a space craft game using Java.
    Right now, I'm just trying to get the rectangle (which I'm going to turn into a space craft later) to shoot the "bullet" when I press the mouse.
    When I run the program, it shoots the bullet fine. But the space craft stops moving until the bullet reaches the end of the screen.
    But I want the bullets and the space craft to move 'independently' without having to wait for the bullets to reach the end of the screen.
    HELP ME PLEASE
    import java.applet.Applet;
    import java.awt.*;
    import java.awt.event.*;
    public class Graphics4 extends Applet
    implements MouseListener, MouseMotionListener {
    int mx, my; // the mouse coordinates
    int s; //shooting control variable
    boolean isButtonPressed = false;
    public void init() {
    setBackground( Color.black ); //background of applet
    setSize(1024,768);
    mx =512; //mouse coordinate in the centre
    my = 384;//mouse coordinate in the centre
    addMouseListener( this );
    addMouseMotionListener( this );
    }//close initializer
    public void mouseEntered( MouseEvent e ) {
    // called when the pointer enters the applet's rectangular area
    public void mouseExited( MouseEvent e ) {
    // called when the pointer leaves the applet's rectangular area
    public void mouseClicked( MouseEvent e ) {
    // called after a press and release of a mouse button
    // with no motion in between
    // (If the user presses, drags, and then releases, there will be
    // no click event generated.)
    public void mousePressed( MouseEvent e ) {  // called after a button is pressed down
    isButtonPressed = true;
    mx = e.getX();
    my = e.getY();
    s=1;
    repaint();
    // "Consume" the event so it won't be processed in the
    // default manner by the source which generated it.
    e.consume();
    public void mouseReleased( MouseEvent e ) {  // called after a button is released
    isButtonPressed = false;
    setBackground( Color.black );
    repaint();
    e.consume();
    s=2;
    public void mouseMoved( MouseEvent e ) {  // called during motion when no buttons are down
    mx = e.getX();
    my = e.getY();
    repaint();
    e.consume();
    s=2;
    public void mouseDragged( MouseEvent e ) {  // called during motion with buttons down
    mx = e.getX();
    my = e.getY();
    repaint();
    e.consume();
    s=1;
    public void paint( Graphics g ) {
    g.setColor( Color.white );
    g.fillRect( mx-20, my-20, 40, 40 ); //draws a rectangle around the mouse
    if (s==1){
    for (int y=my;y>0;y--){ //shoots bullet if mouse is pressed
    g.setColor(Color.yellow);
    g.fillOval(mx-3, y-26, 6, 6);
    try{
    Thread.sleep(1);
    catch (Exception c){
    g.setColor(Color.black);
    g.fillOval(mx-3, y-26, 6, 6);
    }//for
    }//if
    }//Graphics g
    // TODO overwrite start(), stop() and destroy() methods
    }

    you're pausing the game in your paint method until the bullet reaches the top of the screen. a better way would be to create a list of bullets to draw each loop and move them across the screen. here's one way to do it:
    import java.util.ArrayList;
         /** a list of bullets to draw. */
         ArrayList<Point> bullets = new ArrayList<Point>();
         public void mousePressed( MouseEvent e ) { // called after a button is pressed down
              isButtonPressed = true;
              mx = e.getX();
              my = e.getY();
              // add a new bullet at this location
              bullets.add(new Point(mx - 3, my));
              s=1;
              repaint();
    //          "Consume" the event so it won't be processed in the
    //          default manner by the source which generated it.
              e.consume();
         public void mouseDragged( MouseEvent e ) { // called during motion with buttons down
              mx = e.getX();
              my = e.getY();
              repaint();
              e.consume();
              // add a new bullet at this location
              bullets.add(new Point(mx - 3, my));
              s=1;
         public void paint( Graphics g ) {
              // draw ship
              g.setColor( Color.white );
              g.fillRect( mx-20, my-20, 40, 40 ); //draws a rectangle around the mouse
              // draw bullets
              if (!bullets.isEmpty()) {
                   for (int i = 0; i < bullets.size(); i++) {
                        Point bullet = bullets.get(i);
                        bullet.y -= 26;
                        if (bullet.y <= 0) { // bullet reached top of the screen
                             bullets.remove(bullet);
                             i--;
                        } else {
                             g.setColor(Color.yellow);
                             g.fillOval(bullet.x, bullet.y, 6, 6);
                             try{
                                  Thread.sleep(1);
                             catch (Exception c){
                             g.setColor(Color.black);
                             g.fillOval(bullet.x, bullet.y, 6, 6);
              if (s==1){
                   for (int y=my;y>0;y--){ //shoots bullet if mouse is pressed
                        g.setColor(Color.yellow);
                        g.fillOval(mx-3, y-26, 6, 6);
                        try{
                             Thread.sleep(1);
                        catch (Exception c){
                        g.setColor(Color.black);
                        g.fillOval(mx-3, y-26, 6, 6);
                   }//for
              }//if
         }//Graphics gyou still have a problem with your animation, since the paint method isn't called reliably - it only gets called when you move or click the mouse. if you want to make this a game, you'll need to add your own Runnable that updates the game and calls repaint() regularly. check this site for more examples: [https://fivedots.coe.psu.ac.th/~ad/jg/]

  • Mouse tracking incorrect positions?

    Currently working on a 2D shooting game, that looks like the old Liero.
    I'v stumbeled up on a problem, the mouse positions i get seems to be wrong, or im missunderstanding something about it.
    Inside my MouseMoveListener:
       public void mouseMoved(MouseEvent e) {
          player.reportCurrentMousePosition(new Point((int)e.getPoint().getX(),(int)e.getPoint().getY()));
       }Inside the player object:
       public void reportCurrentMousePosition(Point poss) {
          this.currentMousePos = poss;
       }And the drawing in player:
    g.drawLine(locationX, locationY, (int)currentMousePos.getX(), (int)currentMousePos.getY());The line that im drawing, misses the cursor.. Anyone have any idea why?
    As i am also fiering bullets using the same position, it also seems to be out of position.
    Bullet path code:
       public void move() {
          double angle = Math.atan2(getDestinationY(), getDestinationX());
          double ySpeed = Math.sin(angle) * getSpeed();
          double xSpeed = Math.cos(angle) * getSpeed();
          this.setLocationX((int) (this.getLocationX() + xSpeed));
          this.setLocationY((int) (this.getLocationY() + ySpeed));
       }Where getDestinationX() and getDestinationY() is the mouse pointer position.
    Anyone have any clue whats wrong?

    Fixed the problem with the line.. I had to add the mousemovelistener to the panel instead of the JFrame..
    Stupid misstake..
    But still have the problem with the bullets.. Even when i add the mouselistener to the JPanel.
    The problem is that when i shoot bullets, it can hit the spot where the mouse is, but if i move the mouse a little, it still shoots at the old position..
    I have checked, and it is a different position that gets recorded.. But it seems like the bullets only shoot in some angle..
    So if i dragg the mouse even further away from the first working position, then it works again..
    [Picture example|http://www.aralll.net/javaHelp.png]
    Check the picture, and you'll see the red line, is where the mouse is, and it should be blue dots (bullets) in the middle there aswell..
    But as you can see, it only takes in 2 lines there, up, and a little to the side.. Never in the middle..

  • PathTransition Object Collision

    Hi,
    I am making a game where a space shooter shoots asteroids.
    I have a space shooter that shoots bullets which are simply small 3x3px rectangles. The bullets move due to a timeline keyframe calling an update function every 50ms which alters the coordinates of the bullets causing them to move across the screen.
    I also have asteroids. When each asteroid (a simple grey circle) is created so is a PathTransition which moves this asteroid along a specified path starting at the time the asteroid is created.
    I want to detect if a bullet has collided with an asteroid in my update function but I don't know how to tell the coordinates of my asteroid when it is moving along the path. I realise this is probably a REALLY stupid question but I just can't work it out.
    Please help

    Maybe you can use the Ellipse's intersects function. It should work well against a Rectangle bullet.
    To answer the generic question (eg. if you want to detect collision of more complex shapes), you can get the position of the shape with its boundsInLocal variable.

  • .hittest not finding target

    i have a game in which the character shoots bullets and kills enemies and whatnot. Now, i am trying to get the bullet to disappear when it collides with a wall. here is the concerned script:
    _root['B'+bulletID].onEnterFrame = function() {
      this._x += this.xvel;
      this._y += this.yvel;
      if (this._x<0 || this._y<0 || this._x>550 || this._y>400) {            when it goes out of bounds
       this.removeMovieClip(this);
      if(this.hitTest(_root.wall_mc)) {                                  when it hits the wall ( i am using a trace to test a collision)
      trace("HIT");
      if(this.hitTest(_root.BAD)) {                                 when it hits the enemy
       trace("HIT");
    when the bullet goes out of bounds, the bullet disappears, but when it hits the enemy or wall, it seems that the collision is not detected. I have checked each instance name and linkage, but have so far come up with nothing. any help is appreciated!

    here is the whole code i am working with (on an actions frame on the timeline)
    onMouseDown = function () {
    var bulletID:Number = Math.random();
    _root.attachMovie('B', 'B'+bulletID, _root.getNextHighestDepth());
    _root['B'+bulletID]._x = Hero_mc._x;
    _root['B'+bulletID]._y = Hero_mc._y;
    _root['B'+bulletID].xvel = 30*(_xmouse-Hero_mc._x)/(Math.abs(_xmouse-Hero_mc._x)+Math.abs(_ymouse-Hero_mc._y));
    _root['B'+bulletID].yvel = 30*(_ymouse-Hero_mc._y)/(Math.abs(_xmouse-Hero_mc._x)+Math.abs(_ymouse-Hero_mc._y));
    _root['B'+bulletID].onEnterFrame = function() {
      this._x += this.xvel;
      this._y += this.yvel;
      if (this._x<0 || this._y<0 || this._x>550 || this._y>400) {
       this.removeMovieClip();
      if(this.hitTest._root.wall_mc+" "+_root.wall_mc._width+" "+_root.wall_mc._height+" : "+_root.BAD+" "+_root.BAD._width+" "+_root.BAD._height+" "+this.xvel+" "+this.yvel);
         trace("HIT");                                             this is messing up
    if (this.hitTest(_root.wall_mc._width+" "+_root.wall_mc._height+" "+this.xvel+" "+this.yvel)) {
      this.removeMovieClip();
    if (this.hitTest(_root.BAD)) {
      this.removeMovieClip();
    }onMouseDown = function () {
    var bulletID:Number = Math.random();
    _root.attachMovie('B', 'B'+bulletID, _root.getNextHighestDepth());
    _root['B'+bulletID]._x = Hero_mc._x;
    _root['B'+bulletID]._y = Hero_mc._y;
    _root['B'+bulletID].xvel = 30*(_xmouse-Hero_mc._x)/(Math.abs(_xmouse-Hero_mc._x)+Math.abs(_ymouse-Hero_mc._y));
    _root['B'+bulletID].yvel = 30*(_ymouse-Hero_mc._y)/(Math.abs(_xmouse-Hero_mc._x)+Math.abs(_ymouse-Hero_mc._y));
    _root['B'+bulletID].onEnterFrame = function() {
      this._x += this.xvel;
      this._y += this.yvel;
      if (this._x<0 || this._y<0 || this._x>550 || this._y>400) {
       this.removeMovieClip();
      if(this.hitTest._root.wall_mc+" "+_root.wall_mc._width+" "+_root.wall_mc._height+" : "+_root.BAD+" "+_root.BAD._width+" "+_root.BAD._height+" "+this.xvel+" "+this.yvel);
         trace("HIT");
    if (this.hitTest(_root.wall_mc._width+" "+_root.wall_mc._height+" "+this.xvel+" "+this.yvel)) {
      this.removeMovieClip();
    if (this.hitTest(_root.BAD)) {
      this.removeMovieClip();
    };onMouseDown = function () {
    var bulletID:Number = Math.random();
    _root.attachMovie('B', 'B'+bulletID, _root.getNextHighestDepth());
    _root['B'+bulletID]._x = Hero_mc._x;
    _root['B'+bulletID]._y = Hero_mc._y;
    _root['B'+bulletID].xvel = 30*(_xmouse-Hero_mc._x)/(Math.abs(_xmouse-Hero_mc._x)+Math.abs(_ymouse-Hero_mc._y));
    _root['B'+bulletID].yvel = 30*(_ymouse-Hero_mc._y)/(Math.abs(_xmouse-Hero_mc._x)+Math.abs(_ymouse-Hero_mc._y));
    _root['B'+bulletID].onEnterFrame = function() {
      this._x += this.xvel;
      this._y += this.yvel;
      if (this._x<0 || this._y<0 || this._x>550 || this._y>400) {
       this.removeMovieClip();
      if(this.hitTest._root.wall_mc+" "+_root.wall_mc._width+" "+_root.wall_mc._height+" : "+_root.BAD+" "+_root.BAD._width+" "+_root.BAD._height+" "+this.xvel+" "+this.yvel);
         trace("HIT");
    if (this.hitTest(_root.wall_mc._width+" "+_root.wall_mc._height+" "+this.xvel+" "+this.yvel)) {
      this.removeMovieClip();
    if (this.hitTest(_root.BAD)) {
      this.removeMovieClip();
    };onMouseDown = function () {
    var bulletID:Number = Math.random();
    _root.attachMovie('B', 'B'+bulletID, _root.getNextHighestDepth());
    _root['B'+bulletID]._x = Hero_mc._x;
    _root['B'+bulletID]._y = Hero_mc._y;
    _root['B'+bulletID].xvel = 30*(_xmouse-Hero_mc._x)/(Math.abs(_xmouse-Hero_mc._x)+Math.abs(_ymouse-Hero_mc._y));
    _root['B'+bulletID].yvel = 30*(_ymouse-Hero_mc._y)/(Math.abs(_xmouse-Hero_mc._x)+Math.abs(_ymouse-Hero_mc._y));
    _root['B'+bulletID].onEnterFrame = function() {
      this._x += this.xvel;
      this._y += this.yvel;
      if (this._x<0 || this._y<0 || this._x>550 || this._y>400) {
       this.removeMovieClip();
      if(this.hitTest._root.wall_mc+" "+_root.wall_mc._width+" "+_root.wall_mc._height+" : "+_root.BAD+" "+_root.BAD._width+" "+_root.BAD._height+" "+this.xvel+" "+this.yvel);
         trace("HIT");
    if (this.hitTest(_root.wall_mc._width+" "+_root.wall_mc._height+" "+this.xvel+" "+this.yvel)) {
      this.removeMovieClip();
    if (this.hitTest(_root.BAD)) {
      this.removeMovieClip();
    };onMouseDown = function () {
    var bulletID:Number = Math.random();
    _root.attachMovie('B', 'B'+bulletID, _root.getNextHighestDepth());
    _root['B'+bulletID]._x = Hero_mc._x;
    _root['B'+bulletID]._y = Hero_mc._y;
    _root['B'+bulletID].xvel = 30*(_xmouse-Hero_mc._x)/(Math.abs(_xmouse-Hero_mc._x)+Math.abs(_ymouse-Hero_mc._y));
    _root['B'+bulletID].yvel = 30*(_ymouse-Hero_mc._y)/(Math.abs(_xmouse-Hero_mc._x)+Math.abs(_ymouse-Hero_mc._y));
    _root['B'+bulletID].onEnterFrame = function() {
      this._x += this.xvel;
      this._y += this.yvel;
      if (this._x<0 || this._y<0 || this._x>550 || this._y>400) {
       this.removeMovieClip();
      if(this.hitTest._root.wall_mc+" "+_root.wall_mc._width+" "+_root.wall_mc._height+" : "+_root.BAD+" "+_root.BAD._width+" "+_root.BAD._height+" "+this.xvel+" "+this.yvel);
         trace("HIT");
    if (this.hitTest(_root.wall_mc._width+" "+_root.wall_mc._height+" "+this.xvel+" "+this.yvel)) {
      this.removeMovieClip();
    if (this.hitTest(_root.BAD)) {
      this.removeMovieClip();
    };onMouseDown = function () {
    var bulletID:Number = Math.random();
    _root.attachMovie('B', 'B'+bulletID, _root.getNextHighestDepth());
    _root['B'+bulletID]._x = Hero_mc._x;
    _root['B'+bulletID]._y = Hero_mc._y;
    _root['B'+bulletID].xvel = 30*(_xmouse-Hero_mc._x)/(Math.abs(_xmouse-Hero_mc._x)+Math.abs(_ymouse-Hero_mc._y));
    _root['B'+bulletID].yvel = 30*(_ymouse-Hero_mc._y)/(Math.abs(_xmouse-Hero_mc._x)+Math.abs(_ymouse-Hero_mc._y));
    _root['B'+bulletID].onEnterFrame = function() {
      this._x += this.xvel;
      this._y += this.yvel;
      if (this._x<0 || this._y<0 || this._x>550 || this._y>400) {
       this.removeMovieClip();
      if(this.hitTest._root.wall_mc+" "+_root.wall_mc._width+" "+_root.wall_mc._height+" : "+_root.BAD+" "+_root.BAD._width+" "+_root.BAD._height+" "+this.xvel+" "+this.yvel);
         trace("HIT");
    if (this.hitTest(_root.wall_mc._width+" "+_root.wall_mc._height+" "+this.xvel+" "+this.yvel)) {
      this.removeMovieClip();
    if (this.hitTest(_root.BAD)) {
      this.removeMovieClip();
    };onMouseDown = function () {
    var bulletID:Number = Math.random();
    _root.attachMovie('B', 'B'+bulletID, _root.getNextHighestDepth());
    _root['B'+bulletID]._x = Hero_mc._x;
    _root['B'+bulletID]._y = Hero_mc._y;
    _root['B'+bulletID].xvel = 30*(_xmouse-Hero_mc._x)/(Math.abs(_xmouse-Hero_mc._x)+Math.abs(_ymouse-Hero_mc._y));
    _root['B'+bulletID].yvel = 30*(_ymouse-Hero_mc._y)/(Math.abs(_xmouse-Hero_mc._x)+Math.abs(_ymouse-Hero_mc._y));
    _root['B'+bulletID].onEnterFrame = function() {
      this._x += this.xvel;
      this._y += this.yvel;
      if (this._x<0 || this._y<0 || this._x>550 || this._y>400) {
       this.removeMovieClip();
      if(this.hitTest._root.wall_mc+" "+_root.wall_mc._width+" "+_root.wall_mc._height+" : "+_root.BAD+" "+_root.BAD._width+" "+_root.BAD._height+" "+this.xvel+" "+this.yvel);
         trace("HIT");
    if (this.hitTest(_root.wall_mc._width+" "+_root.wall_mc._height+" "+this.xvel+" "+this.yvel)) {
      this.removeMovieClip();
    if (this.hitTest(_root.BAD)) {
      this.removeMovieClip();
    };onMouseDown = function () {
    var bulletID:Number = Math.random();
    _root.attachMovie('B', 'B'+bulletID, _root.getNextHighestDepth());
    _root['B'+bulletID]._x = Hero_mc._x;
    _root['B'+bulletID]._y = Hero_mc._y;
    _root['B'+bulletID].xvel = 30*(_xmouse-Hero_mc._x)/(Math.abs(_xmouse-Hero_mc._x)+Math.abs(_ymouse-Hero_mc._y));
    _root['B'+bulletID].yvel = 30*(_ymouse-Hero_mc._y)/(Math.abs(_xmouse-Hero_mc._x)+Math.abs(_ymouse-Hero_mc._y));
    _root['B'+bulletID].onEnterFrame = function() {
      this._x += this.xvel;
      this._y += this.yvel;
      if (this._x<0 || this._y<0 || this._x>550 || this._y>400) {
       this.removeMovieClip();
      if(this.hitTest._root.wall_mc+" "+_root.wall_mc._width+" "+_root.wall_mc._height+" : "+_root.BAD+" "+_root.BAD._width+" "+_root.BAD._height+" "+this.xvel+" "+this.yvel);
         trace("HIT");
    if (this.hitTest(_root.wall_mc._width+" "+_root.wall_mc._height+" "+this.xvel+" "+this.yvel)) {
      this.removeMovieClip();
    if (this.hitTest(_root.BAD)) {
      this.removeMovieClip();
    };onMouseDown = function () {
    var bulletID:Number = Math.random();
    _root.attachMovie('B', 'B'+bulletID, _root.getNextHighestDepth());
    _root['B'+bulletID]._x = Hero_mc._x;
    _root['B'+bulletID]._y = Hero_mc._y;
    _root['B'+bulletID].xvel = 30*(_xmouse-Hero_mc._x)/(Math.abs(_xmouse-Hero_mc._x)+Math.abs(_ymouse-Hero_mc._y));
    _root['B'+bulletID].yvel = 30*(_ymouse-Hero_mc._y)/(Math.abs(_xmouse-Hero_mc._x)+Math.abs(_ymouse-Hero_mc._y));
    _root['B'+bulletID].onEnterFrame = function() {
      this._x += this.xvel;
      this._y += this.yvel;
      if (this._x<0 || this._y<0 || this._x>550 || this._y>400) {
       this.removeMovieClip();
      if(this.hitTest._root.wall_mc+" "+_root.wall_mc._width+" "+_root.wall_mc._height+" : "+_root.BAD+" "+_root.BAD._width+" "+_root.BAD._height+" "+this.xvel+" "+this.yvel);
         trace("HIT");
    if (this.hitTest(_root.wall_mc._width+" "+_root.wall_mc._height+" "+this.xvel+" "+this.yvel)) {
      this.removeMovieClip();
    if (this.hitTest(_root.BAD)) {
      this.removeMovieClip();
    };onMouseDown = function () {
    var bulletID:Number = Math.random();
    _root.attachMovie('B', 'B'+bulletID, _root.getNextHighestDepth());
    _root['B'+bulletID]._x = Hero_mc._x;
    _root['B'+bulletID]._y = Hero_mc._y;
    _root['B'+bulletID].xvel = 30*(_xmouse-Hero_mc._x)/(Math.abs(_xmouse-Hero_mc._x)+Math.abs(_ymouse-Hero_mc._y));
    _root['B'+bulletID].yvel = 30*(_ymouse-Hero_mc._y)/(Math.abs(_xmouse-Hero_mc._x)+Math.abs(_ymouse-Hero_mc._y));
    _root['B'+bulletID].onEnterFrame = function() {
      this._x += this.xvel;
      this._y += this.yvel;
      if (this._x<0 || this._y<0 || this._x>550 || this._y>400) {
       this.removeMovieClip();
      if(this.hitTest._root.wall_mc+" "+_root.wall_mc._width+" "+_root.wall_mc._height+" : "+_root.BAD+" "+_root.BAD._width+" "+_root.BAD._height+" "+this.xvel+" "+this.yvel);
         trace("HIT");
    if (this.hitTest(_root.wall_mc._width+" "+_root.wall_mc._height+" "+this.xvel+" "+this.yvel)) {
      this.removeMovieClip();
    if (this.hitTest(_root.BAD)) {
      this.removeMovieClip();
    };onMouseDown = function () {
    var bulletID:Number = Math.random();
    _root.attachMovie('B', 'B'+bulletID, _root.getNextHighestDepth());
    _root['B'+bulletID]._x = Hero_mc._x;
    _root['B'+bulletID]._y = Hero_mc._y;
    _root['B'+bulletID].xvel = 30*(_xmouse-Hero_mc._x)/(Math.abs(_xmouse-Hero_mc._x)+Math.abs(_ymouse-Hero_mc._y));
    _root['B'+bulletID].yvel = 30*(_ymouse-Hero_mc._y)/(Math.abs(_xmouse-Hero_mc._x)+Math.abs(_ymouse-Hero_mc._y));
    _root['B'+bulletID].onEnterFrame = function() {
      this._x += this.xvel;
      this._y += this.yvel;
      if (this._x<0 || this._y<0 || this._x>550 || this._y>400) {
       this.removeMovieClip();
      if(this.hitTest._root.wall_mc+" "+_root.wall_mc._width+" "+_root.wall_mc._height+" : "+_root.BAD+" "+_root.BAD._width+" "+_root.BAD._height+" "+this.xvel+" "+this.yvel);
         trace("HIT");
    if (this.hitTest(_root.wall_mc._width+" "+_root.wall_mc._height+" "+this.xvel+" "+this.yvel)) {                    Trying to get this to work
      this.removeMovieClip();
    if (this.hitTest(_root.BAD)) {                             and this
      this.removeMovieClip();
    For some reason, a "HIT" is now being detected no matter where i shoot the bullet. I need to limit that "HIT" area to the wall/enemy.

  • New AIR game - Saturate: A bullet-storm survival shooter

    Hi all,
    I've been working for over a year on game with a publisher (not this game!), and it is still many months away from release.  In the meantime I was anxious to get something released to the public in the short term, so two weeks ago I started Saturate: A bullet-storm survival shooter as a tribute game to one of my fav PC games, Mono by Binary Zoo.  Written in AIR 13 for iOS, Android and Facebook (iOS under review, and FB coming in a few days), with IAP for those who don't want to earn credits the hard way . I'll update the links as the other platform versions become available:
    Available for Android right now!
    Pixelthis website
    Pixelthis Facebook page
    Saturate is a Geometry Wars style two-stick single-screen bullet-storm survival shooter.  There are lots of control schemes to try (and more coming).  Keep in mind that this was a 2-week 'get it out there' marathon, so there are still plenty of features in the pipes (like highscore tables, sharing screenshots to FB and setting them as your wallpaper/bg, different game modes).
    The aim of the game is to saturate the screen with color.  Your score is the % of the screen that you fill when you die (and you will die).  The enemies are R, G and B, and they splat the screen with color when they explode.  There are some cool power-ups, and tons of weapons to collect. The sound track is pretty awesome too.
    Some background: Pixelthis just turned 10 years old a few days ago, so we've been around the block!  We started with Flash 4 and then Flash Lite 1.1 (way back when) on Nokia and Sony-Ericsson phones.  Saturate is developed using AIR, using our proprietary games platform.  The core of the system is a rasteriser that turns vector graphics to bitmap at runtime (including filters) so that we can run in GPU mode with very good performance, and a callback-based event and tweening system for very fast game loop, animations and messaging.  Saturate uses Milkmangames ANEs for StoreKit and Android IAB, and GoViral for social integration. 
    The biggest challenges in development were (1) counting pixels to determine % of screen filled so that it didn't impact negatively on performance, and (2) tracking down and elliminating memory allocations during the game loop.  There are still some optimisations to do, but I think it went pretty well!  Unfortunately it runs a bit too slow on iPad1 when teh action hots up, so that device has been elliminated.  A bug in Adobe AIR that has not been addresed yet also prevents facebook from working on iOS5.1.
    Enjoy!
    Peter

    Thanks lars. Appreciated.
    I can't post actual code of the libraries (because it is our 10yrs worth of IP and it's what allows us to make games that run well accross devcies etc) but i can share the basic principles etc!
    This is what some example code looks like for making a 'RasterSprite':
    // Import the assets from a swc library that contains graphics.
    // These are movieclips with a graphic on each frame
    import assets.CharacterAssets;
    import assets.UIAssets;
    // Initialise the rasteriser just once when the game is started, with a ref to stage
    Rasteriser.init( stage );
    // Rasterise the graphics (this technique is synchronous/blocking) but
    // there is another process that is for larger amounts of graphics.
    // First we set the 'scale'. This determines how big to rip the graphics so that they
    // are always the correct size for the screen/device they are running on.
    Rasteriser.scale = scaleOfGame;
    Rasteriser.rip( CharacterAssets );
    Rasteriser.rip( UIAssets );
    // At this point, each frame is 'ripped' to a bitmapData that is cached in a vector
    // When we need to create a RasterSprite, we use the following technique, which
    // grabs one from a static object pool within RasterSprite:
    var character : RasterSprite = RasterSprite.create( 'CharacterAssets', 12, 15 ); // frames 12 to 15
    character.gotoAndStop(3); // This would be frame 14 of the CharacterAssets clip
    addChild( character );
    var titleGraphic : RasterSprite = RasterSprite.create( 'UIAssets', 7 );
    addChild( title );
    // When we don't need them anymore:
    character.recycle(); // Removes from display list and places back in object pool
    character = null;
    title.recycle();
    title = null;
    The Rasteriser is a static class that handles ripping the graphics and caching them.
    The RasterSprite is a Sprite that contains a Bitmap.  The bitmapData is one from the Rasterisers cache.
    The Rasteriser rips any graphics to a bitmapData at any scale, including any transformations, color transforms, filters etc. Everything maintains the correct scale (e.g. if you rip a graphic at scale 5.3, then the filters are also scaled by 5.3).  This is the magic that both allows the games to run on any resolution screen, and also allows the game to use GPU mode while effectively maintaining filters.
    This is the basic process for ripping the vector-based graphics to bitmapData.
    here we assume that the clip (if it is a movieClip) is 'stopped' on the frame you want to rip:
    1) Step through each filter and scale it's properties to the desired scale
    2) Add the clip to a container sprite (We rip the container. This is what preserves the clips transformation, alpha etc.  If we rip the clip directly all that stuff is ignored).
    3) Find the 'bounds' of the graphics within the container INCLUDING filters.  This is important because if a graphics are 100px wide, the content is not always from x=0 to x=100. It may from x=-26 to x=74.
    4) Create a new BitmapData the correct size (of bounds)
    5) Create a matrix to offset the content so that it IS at 0,0
    6) Use BitmapData.drawWithQuality to draw the container to the BitmapData
    7) Create a bitmap with that bitmapData, and offset the bitmap to counter-act step 5 and place graphics back at correct spot
    8) Optionally, scale all teh filters back again so that the original clip is not affected
    9) Remove the clip from the temporary container
    Anything specific you'd like to know?

  • Shooting multiple bullets

    Hello everyone,
    I'm trying to make my platform game character shoot a gun, my
    character and gun are one movieclip and the bullet is another. The
    bullet mc starts on a blank frame with a stop() function, when I
    press the space bar the bullet mc plays from frame 2 which is a
    motion tween of the bullet quickly moving across the page. I've set
    the bullet's y and x values relative to the character mc so that
    the bullet always comes from the gun.
    My issue is that if I press the space bar a bullet will fly
    out of the gun (great!) but if I press the space bar again, the
    first bullet disappears and the bullet animation starts again. I
    want to be able to shoot a new bullet every time I press the space
    bar without effecting the bullets that have already been shot.
    if(event.keyCode == Keyboard.SPACE)
    bullet_right_mc.y = (ball_mc.y -38);
    bullet_right_mc.x = (ball_mc.x + 253);
    bullet_right_mc.gotoAndPlay("shoot");
    Thanks
    Ryan

    You need to create new instances of the bullt for every use
    of the spacebar. To do that you need to have the bullets called in
    dynamically from the library.
    First you need to designate the bullet mc in the library as
    an item that can be loaded dynamically. Right click on it in the
    library and select Linkage from the menu that appears. In the
    interface that appears, select Export for Actionscript. A Class
    name will automatically be assigned, which you can change as you
    like (lets just say you name it Bullet). This is the name you will
    use to call in the bullets.
    When you click OK to close that interface, it will come up
    with an indication saying it can't find the class so it will create
    one... click OK there to.
    Then, your code will become...
    if(event.keyCode == Keyboard.SPACE)
    var bullet:Bullet = new Bullet();
    bullet.y = (ball_mc.y -38);
    bullet.x = (ball_mc.x + 253);
    this.addChild(bullet);
    bullet.gotoAndPlay("shoot");
    That code was quick and dirty, so it probably has an error or
    two inherent, maybe the last line of it,
    so if that fails you could replace it with
    this.getChildAt(this.numChildren-1).gotoAndPlay("shoot");
    that might fly
    In any case, it will at least get you moving towards having
    mutliple bullets flying. You can post again if you have a new
    problem to solve.

  • I need help with shooting in my flash game for University

    Hi there
    Ive tried to make my tank in my game shoot, all the code that is there works but when i push space to shoot which is my shooting key it does not shoot I really need help with this and I would appriciate anyone that could help
    listed below should be the correct code
    //checking if the space bar is pressed and shooting is allowed
    if(evt.keyCode == 32 && shootAllow){
        //making it so the user can't shoot for a bit
        shootAllow = false;
        //declaring a variable to be a new Bullet
        var newBullet:Bullet = new Bullet();
        //changing the bullet's coordinates
        newBullet.y = tank_mc.y + tank_mc.width/2 - newBullet.width/2;
        newBullet.x = tank_mc.x;
        //then we add the bullet to stage
        addChild(newBullet);
    listed below is my entire code
    import flash.display.MovieClip;
        //declare varibles to create mines
    //how much time before allowed to shoot again
    var cTime:int = 0;
    //the time it has to reach in order to be allowed to shoot (in frames)
    var cLimit:int = 12;
    //whether or not the user is allowed to shoot
    var shootAllow:Boolean = true;
    var minesInGame:uint;
    var mineMaker:Timer;
    var cursor:MovieClip;
    var index:int=0;
    var tankMine_mc:MovieClip;
    var antiTankmine_mc:MovieClip;
    var maxHP:int = 100;
    var currentHP:int = maxHP;
    var percentHP:Number = currentHP / maxHP;
    function initialiseMine():void
        minesInGame = 15;
        //create a timer fires every second
        mineMaker = new Timer(6000, minesInGame);
        //tell timer to listen for Timer event
        mineMaker.addEventListener(TimerEvent.TIMER, createMine);
        //start the timer
        mineMaker.start();
    function createMine(event:TimerEvent):void
    //var tankMine_mc:MovieClip;
    //create a new instance of tankMine
    tankMine_mc = new Mine();
    //set the x and y axis
    tankMine_mc.y = 513;
    tankMine_mc.x = 1080;
    // adds mines to stage
    addChild(tankMine_mc);
    tankMine_mc.addEventListener(Event.ENTER_FRAME, moveHorizontal);
    function moveHorizontal(evt:Event):void{
        evt.target.x -= Math.random()*5;
        if (evt.target.x >= stage.stageWidth)
            evt.target.removeEventListener(Event.ENTER_FRAME, moveHorizontal);
            removeChild(DisplayObject(evt.target));
    initialiseMine();
        //declare varibles to create mines
    var atmInGame:uint;
    var atmMaker:Timer;
    function initialiseAtm():void
        atmInGame = 15;
        //create a timer fires every second
        atmMaker = new Timer(8000, minesInGame);
        //tell timer to listen for Timer event
        atmMaker.addEventListener(TimerEvent.TIMER, createAtm);
        //start the timer
        atmMaker.start();
    function createAtm(event:TimerEvent):void
    //var antiTankmine_mc
    //create a new instance of tankMine
    antiTankmine_mc = new Atm();
    //set the x and y axis
    antiTankmine_mc.y = 473;
    antiTankmine_mc.x = 1080;
    // adds mines to stage
    addChild(antiTankmine_mc);
    antiTankmine_mc.addEventListener(Event.ENTER_FRAME, moveHorizontal);
    function moveHorizontal_2(evt:Event):void{
        evt.target.x -= Math.random()*10;
        if (evt.target.x >= stage.stageWidth)
            evt.target.removeEventListener(Event.ENTER_FRAME, moveHorizontal);
            removeChild(DisplayObject(evt.target));
    initialiseAtm();
    function moveForward():void{
        bg_mc.x -=10;
    function moveBackward():void{
        bg_mc.x +=10;
    var tank_mc:Tank;
    // create a new Tank and put it into the variable
    // tank_mc
    tank_mc= new Tank;
    // set the location ( x and y) of tank_mc
    tank_mc.x=0;
    tank_mc.y=375;
    // show the tank_mc on the stage.
    addChild(tank_mc);
    stage.addEventListener(KeyboardEvent.KEY_DOWN, onMovementKeys);
    //creates the movement
    function onMovementKeys(evt:KeyboardEvent):void
        //makes the tank move by 10 pixels right
        if (evt.keyCode==Keyboard.D)
        tank_mc.x+=5;
    //makes the tank move by 10 pixels left
    if (evt.keyCode==Keyboard.A)
    tank_mc.x-=5
    //checking if the space bar is pressed and shooting is allowed
    if(evt.keyCode == 32 && shootAllow){
        //making it so the user can't shoot for a bit
        shootAllow = false;
        //declaring a variable to be a new Bullet
        var newBullet:Bullet = new Bullet();
        //changing the bullet's coordinates
        newBullet.y = tank_mc.y + tank_mc.width/2 - newBullet.width/2;
        newBullet.x = tank_mc.x;
        //then we add the bullet to stage
        addChild(newBullet);
    if (tank_mc.hitTestObject(antiTankmine_mc))
            //tank_mc.gotoAndPlay("hit");
            currentHP -= 10;
            // remove anti tank mine
            removeChild(antiTankmine_mc);
    if (tank_mc.hitTestObject(tankMine_mc))
            //tank_mc.gotoAndPlay("hit");
            currentHP -= 10;
            // remove anti tank mine
            removeChild(tankMine_mc);
        //var maxHP:int = 100;
    //var currentHP:int = maxHP;
    //var percentHP:Number = currentHP / maxHP;
        //Incrementing the cTime
    //checking if cTime has reached the limit yet
    if(cTime < cLimit){
        cTime ++;
    } else {
        //if it has, then allow the user to shoot
        shootAllow = true;
        //and reset cTime
        cTime = 0;
    function updateHealthBar():void
        percentHP = currentHP / maxHP;
        healthBar.barColor.scaleX = percentHP;
        if(currentHP <= 0)
            currentHP = 0;
            trace("Game Over");
        updateHealthBar();

    USe the trace function to analyze what happens and what fails to happen in the code you showed.  trace the conditional values to see if they are set up to allow a shot when you press the key

  • How do i remove an Object (aliens/ bullets) from my Space Invaders game??

    Creating Space Invaders game and im getting confused on removing objects from my game. How do you actually remove an object (i.e bullets and aliens).
    I know this isnt the right way to do it, but for the bullets i had an array of the Objects bullets[] and set the x and y coordinates off screen so u cant see then wen they are painted you cant see them, then wen the player fires them, the x and y coordinates change so they come from the players ship till it hits an alien or goes off screen, then i reset the coordinates so they are pasted off screen again. Im relatively new to this so i would appreciate any help. Im going to have to do the same with aliens wen a collision is detected. Is there a way of actually removing an object?
    Here is sum code incase you need to see it:
    public void checkCollision()
              Rectangle playerRec = new Rectangle(player1.getBoundingBox());
              for(int i=0; i<alienRow; i++)
                   for(int j=0; j<alienCol; j++){
                        if(playerRec.intersects(aliens[i][j].getBoundingBox()))
                             collisionDetected();
                        for(int k=0; k<bulletNum; k++){
                             Rectangle bulletRec = new Rectangle(bullets[k].getBoundingBox());
                             if(bulletRec.intersects(aliens[i][j].getBoundingBox()))
                                  removeBullet(bullets[k]);
                                  collisionDetected();
         public static void collisionDetected()
              System.out.println("COLLISION");
    private void removeBullet(Bullets bullet){
              bullet.fired=false;
              bullet.setX(-10);
              bullet.setY(-10);
         }Edited by: deathwings on Nov 25, 2009 8:20 AM

    deathwings wrote:
    I was thinking bout that arraylist angle before, but it makes sense now so i think that will work ok. Thx kevin.Not a problem.
    Taking the List idea one step further, you could have a parent Object/Interface that all of your game objects extend/implement. Let's call it GameObject.
    A GameObject would have a draw(Graphics g) function that you call from your paintComponent( ) method, and for example an act( ) function as well.
    You'd have a single List of GameObjects that you add everything in your game into. Now painting is simply a matter of looping over a single List. And in your game logic loop, you could do a similar thing with the act( ) function: your bullet's act( ) would simply move it forward and check for collisions and going off screen. An alien's act( ) function would move it around and maybe shoot a weapon every so often.
    Just an idea.

  • Anyone familiar with Magic Bullet software??

    If so, I have a question. With all the new cameras that have features such as "cine-gamma" and more detailed control over color and image, is it necessary to even purchase/use something like MB anymore? I was interested in it at some point in the past, seeing as how the filters could help you achieve the elusive "film look." But, it seems these new cameras have that issue covered by processing it for a "film look" as they record, instead of you trying to fix it in post with MB.
    Anyone had experience with MB and/or new cameras mentioned (Panasonic DVX100, for example)? I'd like to hear your thoughts. I'm beginning to look at new cameras; I've had my XL1 for nearly 6 years now, and although it's still a workhorse and still going, I'm liking what I'm seeing on the market.
    Thanks,
    Sean Kirkland

    I have the Magic Bullet Movie Looks plugins. I also use a Sony HVRZ1U (which does NOT have true 24P) and tonight, as a matter of fact, I'm doing a shoot using a DVX100.
    I'll say this: If you use the Magic Bullet plugins, prepare yourself for VERY LONG rendering times. Applying one of their plugins to even a small piece of footage almost quadruples rendering times. Unless you have a RAID 0 and lots of RAM or you're only doing a small piece...well, there it is.
    The piece I'm doing tonight is, in fact, going to only be about 7 minutes total when finished, and I may actually apply some Magic Bullet to this piece when it's all finished. It's a promotion for a cigar company, and I think a certain look coupled with the the DVX100 may be pretty cool. In a way, your post is actually what got me thinking about this, so thanks!
    I hope I've helped you in some way.
    Gman

  • Spawning multiple instances of a sprite (firing bullets).  Help needed.

    Hello there.  I'm currently trying to make a game in director 11.5 for a University project.  I've decided to make a scrolling space shooter but I've run into a problem.  Any tutorial I've found has created a limited 'bank' of bullets to fire, only allowing a certain number on the stage at any given time.  What I need to do is to leave a single bullet sprite off the boundaries of the page and essentially copy it and it's lingo behaviors to spawn another instance of the bullet on the stage when the player fires (using the left mouse button in this case).  I also need this copy to be deleted entirely when it collides with an enemy or leaves the boundaries of the stage, otherwise the game will just run slower and slower as more shots are fired.
    I have heard that this is possible using the puppetSprite() method but the API doesn't shine much light on the issue and neither has literally hours of google searches.  If anyone can let me know any method of doing this, I'd be very grateful.
    On a related issue, when fired the bullet will need to intsect the location of where the mouse cursor was when the bullet was fired and then continue on a linear path.  I've worked out a method of doing this but it isn't very effective or efficient (the speed of the bullets would be determined by how far away the mouse cursor is from the players ship and I think there's probably a less calculation intensive method for doing this) and as I can't spawn the bullets as of now, I really don't know if it will even work.  If anyone has any advice on how to better implement this mechanic, again I'd welcome your input.  Thanks in advance.

    You want to work with objects not numbers which means using Points for locs and Sprite references and not sprite numbers.
    I feel that using a object manager object would make programming this a lot easier, cleaner, and more efficient. Rather than give a lecture on OOP and OOD, I took some of Josh's ideas like using a timeout object and wrote some scripts in my style to give you something else to boggle your brain.
    I tested these scripts but not thoroughly and I left plenty for you to do.
    I separated out the creation and control of "bullets" from the movement of the bullets. So, there is a behavior that does nothing more than move the bullet sprites and the control object handles everything else using a single timeout object.
    I suggest creating a new project to play with these scripts. Throw a bunch of sprites on the stage and attach the "Hitable Sprite" behavior to them, make sure you have a sprite named "bullet", and a " go the frame" behavior to loop on and you should be good to go.
    Note that where I set the velocity of the bullet sprites, that I use "100.0" instead of 20.  20 would be a very fast speed.
    Here's the Parent script for the control:
    -- Bullet Control parent script
    property  pUpdateTimer  -- timeout object for doing updates
    property  pBullets  -- list of bullet sprites
    property  pGunLoc  -- location of the gun, ie the location where your bullets start at.
    property  pRightBounds  -- right edge of the stage
    property  pBottomBounds  -- bottom edge of the state
    property  pZeroRect  -- used for intersection hit detection
    on new me
      pUpdateTimer = timeout().new("BulletCntrl", 25, #update, me)  -- 25 milleseconds = 40 updates per second
      pBullets = []
      pGunLoc = point(300,550)  -- *** SET THIS to where you want your bullets to start at.
      pZeroRect = rect(0,0,0,0)
      -- store stage bounds for later use
      pRightBounds = _movie.stage.rect.width
      pBottomBounds = _movie.stage.rect.height
      return me
    end new
    on fire me
      NewBullet = script("Bullet behavior").new(pGunLoc)  -- create new bullet sprite
      if ilk(NewBullet, #sprite) then pBullets.add(NewBullet)  -- store sprite reference
    end fire
    on update me, timeob
      if pBullets.count = 0 then exit  -- no bullets to update
      -- update bullet positions
      call(#update, pBullets)
      -- get list of sprites to test for hits/collisions
      HitSprites = []
      sendAllSprites(#areHitable, HitSprites)  -- the list "HitSprites" is populated by each hitable sprite.
      BulletsToDelete = []  -- list of bullet sprites to delete
      -- check if any bullet has hit a hitable sprite
      repeat with Bullet in pBullets
        repeat with HitSprite in HitSprites
          if Bullet.rect.intersect(HitSprite.rect) <> pZeroRect then
            HitSprite.explode()
            BulletsToDelete.add(bullet)
            exit repeat  -- leave inner loop
          end if
        end repeat
      end repeat
      -- check if bullet is out of bounds
      repeat with Bullet in pBullets
        Die = false
        if Bullet.right < 0 then Die = true
        if Bullet.left > pRightBounds then Die = true
        if Bullet.top > pBottomBounds then Die = true
        if Bullet.bottom < 0 then Die = true
        if Die then BulletsToDelete.add(Bullet)
      end repeat
      -- remove any sprites that hit something or went off the screen
      repeat with Bullet in BulletsToDelete
        Bullet.die()
        pBullets.deleteOne(Bullet)  -- remove bullet from list of active bullets
      end repeat
    end update
    on stopMovie
      -- end of app cleanup
      if pUpdateTimer.objectP then
        pUpdateTimer.forget()
        pUpdateTimer = void
      end if
    end
    The behavior for the bullets is:
    -- Bullet behavior
    property  pMe
    property  pVelocity
    property  pCurLoc
    on new me, StartLoc
      -- get a sprite
      pMe = me.getSprite()
      if pMe.voidP then return void  -- if not a sprite then give up
      -- setup this bullet sprite
      pMe.puppet = true
      pMe.member = member("bullet")
      pMe.loc = StartLoc
      pMe.scriptInstanceList.add(me)  -- add this behavior to this sprite
      -- set velocity
      pVelocity = ( _mouse.mouseLoc - StartLoc) / 100.0  -- Note: magic number "20.0"
      updateStage()  -- need to update pMe.rect values
      pCurLoc = pMe.loc -- store current location
      return pMe  -- Note: returning "pMe" not "me"
    end new
    on getSprite me
      repeat with CurChannel = 1 to the lastchannel
        if sprite(CurChannel).member = (member 0 of castLib 0) AND sprite(CurChannel).puppet = false then
          return sprite(CurChannel)
        end if
      end repeat
      return void
    end getSprite
    on update me
      -- move bullet. 
      pCurLoc = pCurLoc + pVelocity  -- add velocity to pCurLoc to maintain floating point accuracy
      pMe.loc = pCurLoc 
    end update
    on die me
      pMe.scriptInstanceList = []  -- must manually clear this property
      pMe.puppet = false
    end
    We setup everything in a Movie script:
    -- Movie Script
    global gBulletCntrl
    on prepareMovie
      gBulletCntrl = script("Bullet Control").new()
      the mouseDownScript = "gBulletCntrl.fire()"  -- route mouseDown events to the global object gBulletCntrl.
    end prepareMovie
    on stopMovie
      the mouseDownScript = ""
    end stopMovie
    Finally since we are shooting at other sprites we need a script on them to interact with the bullets.
    --  Hitable Sprite Behavior
    property  pMe
    on beginSprite me
      pMe = sprite(me.spriteNum)
    end beginSprite
    on enterFrame me
      -- movie sprite
    end enterFrame
    on areHitable me, HitList
      HitList.add(pMe)
    end areHitable
    on explode me
      put "Boom"
    end explode

  • CODEC Support - Red Giant Bullet-Proof Understanding Ingest-Export Sequence Choices?

    I shoot with a Canon EOS C100 that records AVCHD internally. I also use a Ninja Blade to record DNxHD at 220 Mps. I find no built-in support for either of these formats in Bullet Proof and Premiere Pro. Is there a reason for that?
    I'm trying to understand why the default export is MJPEG. For some reason, I thought that was an old codec no longer used. And it takes forever for Bullet Proof to export it. I have a very fast computer with an X99 2011 v3 chipset and 64 GB RAM, an Areca 12G RAID controller with a 16TB RAID 5 attached. And SSD for backup storage.
    I don't mind editing MJPEG. I just don't know if it is the best I could do, or if it's better to edit the original AVCHD. In other words, If I ingest AVCHD footage, is it best to transcode it to MJPEG or another format for editing? Since there is no preset for AVCHD, what then should my edit settings be?
    I also still do not understand the reasoning for the complex folder structure coming off the C100. I have read that it is important to leave that structure intact, but I don't see the benefit. Premiere has no use for it, it seems.

    with the constant changes to adobe's software, its helpful to know which version we are talking about. alot of people ask questions here with older versions of the software... 
    if premiere doesn't get your footage right when making a new sequence, then choose one that matches the footage the best by resolution and fps. you can also click on the settings tab, when making a new sequence, to customize it exactly to your needs. you can even save this as a preset that will show in the first tab with the default presets, so if you plan on using these media alot, you wont have to remake the custom sequence each time.
    im not exactly sure what all you do in bulletproof, so i hinted at prelude since it does let you transcode to alot more codecs. prelude is an ingest program, you can trim clips (but only if transcoding), add metadata & markers, and have it export to multiple locations as the original and/or in different formats. prelude will only show presets when transcoding, so if you need a different one you will have to open adobe media encoder and make a new preset in there. then it will show in prelude. i like red giants software, but bulletproof export codecs seem rather limited. if the pass-through option just copies and doesn't re-encode then that might work for you.
    when exporting from premiere you can also choose a preset close to your media and then customize it to your needs. you can even save it as a preset to recall later. i would stick with dnxhd for export, especially if you plan on bringing it back into premiere. dnxhd is very high quality if choosing its high bitrate format. there are several options for dnxhd 220, one should match your Ninja Blade. these are found under the quicktime format and video codec as avid dnxhd. its also available in mxf format.
    adobe's presets try to cover a wide range of cameras and media but can only cover so many, new ones coming out all the time... in sequence settings and export you have full control to customize it to your media and needs.

Maybe you are looking for

  • Slice Selection in Save for Web dialog in 17.1

    Since upgrading to Illustrator 17.1 I can no longer select slices in the Save for Web dialog, nor can I select a slice on a different layer than the one it was created on. Anyone else seeing this issue?

  • How much RAM can my macBook handle?

    I have a MacBook (late 2008) unibody aluminum with Boot ROM Version: MB51.007D.B03.   Model Identifier: MacBook5,1   Processor Name: Intel Core 2 Duo   Processor Speed: 2 GHz   Number Of Processors: 1   Total Number Of Cores: 2   L2 Cache: 3 MB   Mem

  • How to remove my brother's  contacts from my iCloud and devices?

    So my brother a couple of weeks ago had an issue with his Iphone 4s so he did a factory restore from my macbook and some how all his contacts are now in my machine and devices. How do I go about correcting the issue and utimately get rid of them? Any

  • No push mail After update on iOS 4.1

    Hi, I have now updated to 4.1 on a 3gs and no longer receive push for my gmail accounts. I can manually fetch mail ok but push no longer comes through. My wife has also updated to 4.1 on a 3G with no data but still gets push on wifi ok on the same gm

  • How to check PSA data size for a particular datasource

    Hi All, Please let us know how to check the size of a PSA for a particular datasource in BI 7.0. But i am using DB02OLD transaction code to identify the size of the change log table or active table of a DSO.