A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Shooting Gun

  1. #1
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870

    Shooting Gun

    Does anyone know how to make a gun which rotates according to the angle of the mouse and shoots laser when the mouse clicks?(in the mouse direction)

    I made a basic platform game according to the tutorial. I was thinking of advancing it to a better sort.

    Regards,
    Tongxn
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  2. #2
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    Anything?
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  3. #3
    Knows where you live
    Join Date
    Oct 2004
    Posts
    944
    There is about 400 tutorials for this type of stuff. Pretty much you use atan2, cos and sin. I suggest you use google or search the tutorials on flashkit.

    By the way, your sig isnt correct syntax wise.
    The greatest pleasure in life is doing what people say you cannot do.
    - Walter Bagehot
    The height of cleverness is to be able to conceal it.
    - Francois de La Rochefoucauld

  4. #4
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    NO honisty i don't want a smart remark, I need a real solution. And anyway I have no idea how do you make a laser shoot towards the mouse position
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  5. #5
    Knows where you live
    Join Date
    Oct 2004
    Posts
    944
    That wasnt a smart remark, it was a true remark. Here are just an example of relevant tutorials on flashKit:
    http://www.flashkit.com/tutorials/Ga...u-81/index.php
    http://www.flashkit.com/tutorials/Ga...u-80/index.php
    http://www.flashkit.com/tutorials/Ga...u-79/index.php
    http://www.flashkit.com/tutorials/Ga...-598/index.php
    http://www.flashkit.com/tutorials/Ga...-611/index.php
    http://www.flashkit.com/tutorials/Ma...1014/index.php
    Here is a quick search on google for the math involved:
    http://abe.www.ecn.purdue.edu/~agen215/trig.html
    http://tutorial.math.lamar.edu/AllBr...aTrigIntro.asp
    If you are past grade 9 you should know what sin cos and tan do.
    None of the tutorials cover everything you want but if you read them you will be able to make it work.

    The only part that I will comment on is the "finding the angle of the mouse". Most of the tutorials are way overcomplicated and one solution even freezes the computer under certain circumstances so just use Math.atan2 (y distance from point to mouse, x distance from point to mouse).

    Just remember the Math functions output everything in radians and need all input values in radians.
    The greatest pleasure in life is doing what people say you cannot do.
    - Walter Bagehot
    The height of cleverness is to be able to conceal it.
    - Francois de La Rochefoucauld

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center