Navigation

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

    Where can I put stuff?

    Beginners
    5
    9
    258
    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.
    • PickleCatStars
      PickleCatStars F last edited by

      I’m writing out big screen filling maps like this:
      [
      [0,0,1,2,2,2,1,1],
      [0,0,1,2,2,2,1,1],
      [0,0,1,2,2,2,1,1],
      [0,0,1,2,2,2,1,1],
      [0,0,1,2,2,2,1,1],
      [0,0,1,2,2,2,1,1],
      [0,0,1,2,2,2,1,1],
      [0,0,1,2,2,2,1,1]
      ]

      And I have a load of structs defined. It’s cluttering up my project. Can I just shove them down the bottom out of the way?

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

        Anything global has to be defined before it is used (obviously) but can otherwise be put anywhere in the program. I tend to put my main program at the end so it doesn't matter where the global stuff is. Use bookmarks to navigate

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

          I put my main program loop at the very start all my functions below then globals then data and I call my main loop on the last line. This was a great tip from minatsu (i think) but I can't find the post.

          1 Reply Last reply Reply Quote 1
          • PickleCatStars
            PickleCatStars F last edited by

            @xevdev You have your main loop as a function and then your last line is just

            mainloop() (or whatever)

            ?

            xevdev 1 Reply Last reply Reply Quote 1
            • PB____
              PB____ last edited by

              I think this might be the post (by sahara-min): https://fuzearena.com/forum/topic/645/any-way-to-hide-this-mess-of-initialisation-code/6

              I've used that pattern in my games as well, I think it's a good way to go.

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

                Just to elaborate a little on what @pianofire said above earlier, which is that globals need to be defined before being used in order to actually be globals.

                Beyond that, Fuze is an interpreted language and as such the engine will rattle through your program when it's run and create a list of everything it finds, meaning outside of globals stuff can be wherever you wish. BUT... while this is very typical of interpreted languages such as Basic it is certainly not as typical as your get into more complex languages. Languages such as C will complain if you have not declared anything before it is used.

                To that end, I'd highly recommend getting in the habit of having Globals, then Functions, then your main loop (or a call to your main loop if it's a function). And also try to get into the mindset of making sure functions are ordered by when they are called so if function A calls function B, function B is listed before function A. No reason whatsoever apart from developing good habits. And should the ability to export programs from Fuze ever come it might help you later down the line. That is an entirely throw-away comment incidentally, I'm not aware of any such plans.

                1 Reply Last reply Reply Quote 2
                • PB____
                  PB____ last edited by

                  That process of rattling through and creating a list to allow forward referencing, is also known as hoisting.

                  Other than that, I've already given my opinion :)

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

                    I believe I shall get into hoisting. I’ll also have a bit more of a read through of the forum now that I’ve been here a while.

                    1 Reply Last reply Reply Quote 1
                    • xevdev
                      xevdev F @PickleCatStars last edited by

                      @toxibunny yep but for what ever i go
                      Mainloop() // thanks min this is awesome

                      But it's Sahara min and that's who I meant and I think I put it at the end of every program because it is awesome.

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