Navigation

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

    exit the game loop back to title screen

    Beginners
    2
    13
    713
    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.
    • pianofire
      pianofire Fuze Team last edited by pianofire

      So you could do something like this:

      screen = 0
      textSize(50)
      
      while screen < 3 loop
        if screen == 0 then
          titleScreen()
        endif
        if screen == 1 then
          gameScreen()
        endif
        if screen == 2 then
          endScreen()
        endif
      repeat
      
      function titleScreen()
        oldc = controls(0)
        while screen == 0 loop
          clear()
          c = controls(0)
          if c.a and c.a != oldc.a then      
            screen = 1
          endif
          oldc = c
          message = "Title Screen : Press A to continue"
          printAt((twidth() - len(message)) / 2, theight() / 2, message)
          update()
        repeat
      return void
      
      function gameScreen()
        oldc = controls(0)
        while screen == 1 loop
          clear()
          c = controls(0)
          if c.a and c.a != oldc.a then
            screen = 2
          endif
          oldc = c
          message = "Game Screen : Press A to continue"
          printAt((twidth() - len(message)) / 2, theight() / 2, message)
          update()
        repeat
      return void
      
      function endScreen()
        oldc = controls(0)
        while screen == 2 loop
          clear()
          c = controls(0)
          if c.a and c.a != oldc.a then 
            screen = 0
          endif
          if c.x then
            screen = 3
          endif
          oldc = c
          message = "End Screen : Press A to continue (X to eXit)"
          printAt((twidth() - len(message)) / 2, theight() / 2, message)
          update()
        repeat
      return void
      

      Here the game loop calls 3 different function each with it's own loop and swaps between them

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

        @pianofire cheers! how would it know if the player has fell ? i already have a title screen with press a to continue just need to loop back to the in my case " dointro()"
        just tired of seeing the player fall for eternity

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

          @waldron I guess that you could test if they were off the screen i.e. y position > gHeight() or you could add a collision box below the screen and test for collision with that?

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

            Yeah I can get the height pos when I want it to execute its just executing the action I'm clueless about lol

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

              If player pos height - 260 then
              Dointro()
              Endif

              My coding is terrible

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

                In my example above

                if playerPosHeight < 260 then
                  screen = 2
                endif
                

                The loop condition takes care of the rest

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

                  @pianofire thank you il try it now :)

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

                    @pianofire think il leave it, its not recognising PlrPosHeight once i enter the game loop

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

                      @waldron Is it a global variable (declared outside the functions)?

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

                        @pianofire i have no idea honestly im terrible at coding, it will probably click and il figure it eventually but for now il leave it

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

                          Ok no problem

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

                            @pianofire thats not to say i haven't learnt and il come back to this when it does click
                            thanks man, about to submit my game jam entry....

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