Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    2d platform game, how can i shoot ?

    Help
    4
    6
    254
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • waldron
      waldron F last edited by

      wanting my plyr sprite to fire bullets
      and another mechanic i would like is a grappling hook? to ambitious....

      Spacemario 1 Reply Last reply Reply Quote 0
      • Spacemario
        Spacemario F @waldron last edited by Spacemario

        @waldron I think @SteveZX81 had a game with firing bullets in it. I'd be interested in seeing the best way to do this too.

        Grappling hook would be fun! I bet the same methodology could be used to "spawn" the grappling hook, have it collide with your map, then do some physics math you have the player do an "arcing" movement.

        It's a little beyond me, but you could build up to it as you gain skill.

        waldron 1 Reply Last reply Reply Quote 0
        • waldron
          waldron F @Spacemario last edited by

          @Spacemario thanks man, yeah the grappling hook is gonna be tricky
          im wanting to eventually have it connect to a second player.

          1 Reply Last reply Reply Quote 0
          • SteveZX81
            SteveZX81 F last edited by

            Yes, I had a bit of a game with shooting but I never did find a method for shooting more than one bullet at a time. its something I need to revisit and work out.
            Sadly I've lost all my game code now, since I deleted my Fuze saved data in a wild attempt to fix the friends bug I have, so I don't have any code to paste here that might help.

            all I can suggest for now is to check out the built-in games like invaders etc and see how they did it, or perhaps some kind person like Dave, Martin, Mike or Pianofire will give you a hand. Sorry I can't help

            1 Reply Last reply Reply Quote 1
            • Martin
              Martin Fuze Team last edited by pianofire

              The bullets is easy enough. I've just added you as a friend and if you go into my shares you will see a game called "YASS". It's not a finished game but it's a shooter so there's code in there for shooting bullets. There are some complexities to the way I do it but see if you can work anything out from that first.

              In summary, I use sprites for bullets. I have an array called "shots" that has "maxBullets" items in it. On game start each "shot" is assigned to a sprite called "nullSprite". There is no great significance to this sprite apart from the fact I don't actually load an image to it or ever use it. It's kind of like a placeholder.

              Whenever the users presses fire I call a function that rattles through the array and finds the first entry in the array that is free (is a "nullSprite") and if so I create the sprite and return it. The sprite then does normal sprite stuff travelling in the direction of fire until it hits something or has reached the limit of 100 pixels travel. If there were no available shot slots then the players fire press is just ignored. This limits the number of bullets you can fire at a time.

              Like I say, that part could be considered a little complex but you may not need that.

              A grappling hook would be a whole different story. Since it needs to extend out and leave a trail behind it I'm not so sure that sprites are appropriate for it? Certainly not an ideal first thing to try and implement* :)

              *Note, no idea how new you are to all this!

              NB: It's worth saying that right now I have a problem with the Friends section in Fuze. Should you find after interacting with my shares that the friend section no longer works for you please let us know.

              1 Reply Last reply Reply Quote 3
              • waldron
                waldron F last edited by

                Thankyou, yeah I played yass it's awesome and I can learn so much from it!

                I'm completely new to coding but slowly making progress.

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post