The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.

Results 1 to 6 of 6

Thread: Shooter Game HELP

  1. #1

    Shooter Game HELP

    Ok, im makeing a side scroller shooter game where you point and click to shoot with your mouse. I wanted to make it so instead of actualy shooting a bullet movie clip out of your gun on mouseDown, just have a line apear for a split second between your gun and the enemy.

    To do this i used the pythagoron therom (a^2 + b^2 = c^2)
    in the code its:
    x = _root.hero._x - _xmouse
    y = _root.hero._y - _ymouse
    _root.hyp = Math.sqrt(x*x + y*y)

    Then i made a movie clip of a line and set its _xscale to c, and then set the lines _rotation to the same as the guns

    my only problem is when the line rotates around it becomes thicker and thiner, also at a point the line stops growing and there is a gap between the gun and the enemy. how can i fix this? id i do the pythagorian equation wrong or something?
    Last edited by lancerawks; April 27th, 2008 at 08:11 PM.

  2. #2
    Quote Originally Posted by lancerawks View Post
    Ok, im makeing a side scroller shooter game where you point and click to shoot with your mouse. I wanted to make it so instead of actualy shooting a bullet movie clip out of your gun on mouseDown, just have a line apear for a split second between your gun and the enemy.

    To do this i used the pythagoron therom (a^2 + b^2 = c^2)
    in the code its:
    x = _root.hero._x - _xmouse
    y = _root.hero._y - _ymouse
    _root.hyp = Math.sqrt(x*x + y*y)

    Then i made a movie clip of a line and set its _xscale to c, and then set the lines _rotation to the same as the guns

    my only problem is when the line rotates around it becomes thicker and thiner, also at a point the line stops growing and there is a gap between the gun and the enemy. how can i fix this? id i do the pythagorian equation wrong or something?
    ditch that approach and use the drawing api.

    as2:
    Code:
    // myMovieClip.lineStyle ( thickness, rgb, alpha )
    bullet.lineStyle ( 1, 0x000000, 100 );
    
    //myMovieClip.moveTo( x, y );
    bullet.moveTo ( startx, starty );
    
    // myMovieClip.lineTo ( x, y );
    bullet.lineTo ( targetx, targety );
    
    // then, whenever you want to clear it:
    bullet.clear ();
    as3 is nearly identical, but preface your drawing api commands with 'graphics'

    i.e.
    myMovieClip.graphics.lineStyle (1, 0x000000, 1);

    I hope that is enough info to help you. The drawing api is pretty straightforward to use, just experiment with it until you achieve your desired results.
    you = function(){
    setEnabled( true );
    live();
    setEnabled( false );
    }

  3. #3
    Thanks man, works like a charm

  4. #4
    Ah... That's useful for my laser too but I'd like to ask one question...

    I see you can set the thickness. When the line is thick and the line has plain colour, it looks dull. Is it possible to add gradient colour to the line drawn by AS?

  5. I think it is possible when you look at this: http://www.adobe.com/support/flash/a...ionary510.html

    Since the line you draw is just a normal movieclip you should be able to apply that to the line movieclip. I'll might test it out when get back from walking with my dog! xD
    Last edited by ArmoredSandwich; April 28th, 2008 at 08:08 AM.

  6. #6
    I'll take a look at that. Thank you for the hint.

    //edit:
    And... don't quite understand the purpose and usage of the "matrix" parameter...
    Last edited by fw2803; April 30th, 2008 at 10:29 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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 About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012