Navigation

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

    2 player setup?

    Beginners
    5
    9
    481
    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

      is there a global command for second player controls
      how would the controls work for the second player player1/c.a player2/ c.a1 ??

      pianofire 1 Reply Last reply Reply Quote 0
      • pianofire
        pianofire Fuze Team @waldron last edited by

        @waldron The first controller is index 0 so c0 = controls(0) the second one is index 1 so c1 = controls(1) and so on (up to 3)

        https://fuzearena.com/help/view/controls

        waldron 1 Reply Last reply Reply Quote 2
        • B
          Bl4ckM4ch1n3 last edited by Bl4ckM4ch1n3

          Just use the controls-function with another index.
          Currently you're doing something similar to this:

          c = controls(0)
          if c.a then
          do stuff regarding player one
          endif
          

          If you want to include a second player it should work like this:

          c1 = controls(0)
          c2 = controls(1)
          if c1.a then
          do stuff regarding player one
          endif
          
          if c2.a then
          do stuff regarding player two
          endif
          

          This works with up to four players controls(0-3)

          *€dit: Okay, @pianofire was a little bit faster :-)

          1 Reply Last reply Reply Quote 4
          • waldron
            waldron F @pianofire last edited by

            @pianofire awesome thanks

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

              so while on the subject of controls i played around with (if) and (then)
              with the controls so when i pressed certain buttons it would print on the screen what i wanted i thought fantastic so now i can add sounds ect or img but do i have to load full loop code vol. pan ect just to play a sound effect on a button press?

              Dave 1 Reply Last reply Reply Quote 0
              • Dave
                Dave Fuze Team @waldron last edited by

                @waldron The problem arises when using something like:

                if j.a then
                    playAudio( blah, blah, blah )
                endif
                

                If you are just checking if j.a, then this command will trigger every frame the button is held. To stop this, you need to stop the if statement from happening again, once it's been triggered. You could do this with a simple "press" variable:

                press = false
                
                if j.a and !press then
                    playAudio( blah, blah, blah )
                    press = true // Setting this variable to true means we can't get back into this if until it's false again.
                endif
                
                if !j.a then
                    press = false
                endif
                

                That method will work just fine, but you might end up needing a separate "press" variable for every button you want to use. I now use this really handy method of storing the previous state of the whole controls structure into one variable, then checking each property when I need it:

                // global
                j = controls(0)
                oldj = j
                
                loop
                    clear()  
                 
                    if j.a and !oldj.a then // if a is pressed but was not being pressed on the previous frame
                         // stuff to only trigger once
                    endif
                
                    oldj = j // before the end of the main loop, update the old controls state variable
                
                    update()
                repeat
                

                Just means we don't end up with:

                p1aPress = false
                p1bPress = false
                p1xPress = false
                p1yPress = false
                p2aPress = false
                

                etc etc.

                waldron M 2 Replies Last reply Reply Quote 3
                • waldron
                  waldron F @Dave last edited by

                  @Dave that's great cheers dave iv been reading through the tutorials now i understand them better, iv messed with the audio and got some strange effects bugs but with this method it will work so many thanks man .
                  now i'm starting to assign scoring for my tricks(+=playercoins = 1) so as of now if i hold a button the score just shoots up but if i apply the same method so it triggers once and even apply (if) velocity such and such il have that working too

                  Dave 1 Reply Last reply Reply Quote 1
                  • Dave
                    Dave Fuze Team @waldron last edited by

                    @waldron Fantastic :) You're seeing lots more applications straight away!

                    1 Reply Last reply Reply Quote 0
                    • M
                      MikeDX @Dave last edited by

                      @Dave said in 2 player setup?:

                      Just means we don't end up with:
                      p1aPress = false
                      p1bPress = false
                      p1xPress = false
                      p1yPress = false
                      p2aPress = false

                      etc etc.

                      this would make me want to scoop my own eyes out

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