Navigation

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

    Classes in Fuze

    Advanced
    5
    8
    788
    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.
    • M
      Mechanical last edited by

      My Dad had a good look on the interpreter and he told me that he misses classes in Fuze. It would make programming much more complex.

      Im a newb so I don't really get what a class is, but I'm willing to learn about that if it can help to improve my coding.

      Could anyone help me out with that?

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

        So classes are a feature of object orientated languages like Python and C#. I found this which is a good summary of the difference between an object and a class https://medium.com/faun/object-oriented-programming-part-1-c5ad590892ca

        1 Reply Last reply Reply Quote 0
        • M
          Mechanical last edited by

          I will recap what I've learned:

          Classes are a way to define structures and methods into one layout that can be reused later on. For example class "player" is a class that holds structures for player variables and all the functions associated with them.

          I don't have equivalent experience to imagine a way to implement this into my coding, if classes are even possible in fuze

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

            The closest thing that Fuze has to classes is structs and they don't support methods

            1 Reply Last reply Reply Quote 0
            • M
              Mechanical last edited by

              Can I implement functions into structs?

              For example If I have a function that only one player can use I could assign it to that player struct only.

              I'm thinking of ways to program for objects like enemy's with different behavior. Having functions in struct would make it easier to address or execute like with arrays.

              My main goal would be to have a screen, where every Player spawns some entities by button press. These entities are supposed to fight each other by themselves and are not to be controlled

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

                When I build a struct I put in it flags that I call style and type and where my shared function are I do
                An if statement like so
                Red_one = 1 blue_one = 2 etc
                Dumb = 1 smart = 2 etc
                If enemy [count] . type == red_one then ....
                If enemy [count] . Style == smart then ...
                Your code for smart red enemy
                Endif endif

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

                  There is an awful lot more to classes than just being able to string a bunch of common things together including variables and methods. The most obvious is that of inheritance which is one of the biggest things that classes are known for. I'll use the classic example of animals. Exact details differ by implementation / language.

                  This will be very high level.

                  So, let's say that we have 4 legged animals. We know they have 4 legs and they can walk (we'll assume they can anyway). Therefore we might have the "Animal" class:

                  public class Animal {
                      public int legs = 4;
                      public void walk();
                  }
                  

                  Now we want a dog. We know that it has 4 legs and it can walk. We could implement that again but with Classes and objects we don't need to, we can say something like:

                  public class Dog extends Animal {
                      public void bark();
                  }
                  

                  Now our dog can bark. But it can also walk and it also has 4 legs but we didn't need to explicitly write those things because it extended the animal. And in this fictional world, all animals have 4 legs and can walk.

                  This barely even starts to scratch the surface of Classes and Object Orientated coding. There is a tonne of stuff it can do. But no, none of it can be done directly in Fuze.

                  You cannot put functions into structs in Fuze.

                  1 Reply Last reply Reply Quote 0
                  • P
                    petermeisenstein F last edited by

                    Yeah a long time ago i think it could work this way but it was wrong

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