Navigation

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

    Title Screen/Game Over Screen

    Coding
    3
    13
    815
    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.
    • N
      NashiyamaHP last edited by

      Hey all!
      Loving FUZE! I’ve always wanted to get into programming as a hobby and Fuze on switch has made it really easy to get started.

      I’m working on customizing the asteroid type game from the sprite game tutorial. I’m wanting to add a title screen and game over screen. I’ve looked at a few example projects and I THINK that the best course of action is to create some custom functions that will print the screens. That’s simple enough I guess, but what do I then do with the main game loop? Can I jump from the title screen function to the main game loop? Or do I need to make a custom function that holds the main game loop in it. A little confused here.

      I’ve coded some title screens in basic before but that fairly simple because of GOTO and return.

      Thanks for the help.

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

        Your main loop can just call the relevant functions e.g.:

        screen = 0
        
        loop
          clear()
          c = controls(0)
          screen = c.a // Press the A key to change screen
          if screen == 0 then
            screen0()
          endif
          if screen == 1 then
           screen1()
          endif
          update()
        repeat
        
        function screen0()
          printat(twidth() / 2, theight() /2, "Screen 0")
        return void
         
        function screen1()
          printat(twidth() / 2, theight() /2, "Screen 1")
        return void
        
        1 Reply Last reply Reply Quote 5
        • waldron
          waldron F last edited by

          where would you put this code at the beginning or can you pop it anywhere?

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

            @waldron it's up to you really any code outside of the functions will be executed in turn. I prefer to have my main program loop at the top and the functions below but it is a matter of choice

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

              @pianofire thanks, so if i put it below my main game loop it would work

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

                @waldron The loop ... repeat in this example is the main game loop

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

                  @pianofire theight? Not thight? Right ?

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

                    @waldron Well spotted!

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

                      Ok iv put my code in, where do I put the functions,
                      Function screen0()
                      And
                      Function screen1()
                      Figure I need something in the brackets maybe?...

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

                        @waldron Sorry I don't understand the question. Can you send us a screenshot?

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

                          I'll send them later, but at the minute I'm
                          Running the game but gos to a black screen with screen0, then screen1 when I press A

                          Running it with the amuse gothicmania sample project

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

                            @waldron That's what it is supposed to do. It is only an example to show how you could to have multiple screens. You will probably want something more like this:

                            screen = 0
                            
                            loop
                              clear()
                              c = controls(0)
                            
                              if screen == 0 then
                                
                                titleScreen() 
                                // check for start button press and set screen = 1
                            
                              endif
                            
                              if screen == 1 then
                            
                                 gameScreen()
                                 // if game over set screen = 2
                                 
                              endif
                            
                              if screen == 2 then
                                
                               gameOverScreen()
                               // check for button press and set screen = 0
                            
                              endif
                              update()
                            repeat
                            
                            function titleScreen()
                              
                              // draw title screen here
                            
                            return void
                            
                            function gameScreen()
                              
                              // draw game screen here
                            
                            return void
                             
                            function gameOverScreen()
                              
                              // draw game over screen here
                            
                            return void
                            
                            waldron 1 Reply Last reply Reply Quote 1
                            • waldron
                              waldron F @pianofire last edited by

                              @pianofire perfect thanks

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