User Tag List

Page 2 of 2 FirstFirst 1 2
Results 11 to 19 of 19

Thread: Any tutorials on writing maintainable code in Fusion?

  1. #11
    Clicker Install Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)Firefly 3D Module (Steam)
    defisym's Avatar
    Join Date
    Jun 2017
    Location
    Asia
    Posts
    513
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Darkhog View Post
    Yeah, I already know about the general principles, but don't know how to apply them in Fusion due to the nature of the click code. Plus, I don't know how to use Fusion-specific features (that aren't in regular programming languages) to make the code even more maintainable.
    Avoid loops and recursive as much as possible, as fusion’s flow control is not that strong (and possible performance lose due to the iterate of entire event page.). fusion will loop for each object in ACEs internally, it’s enough for most cases. If loop is inevitable, remember to put a example event of calling just above on loop events, just like function prototypes.
    Use qualifiers to abstract logic and simulate oop, for code reusability. One class only handles one thing.
    Even if you don’t need child events, also split actions into several child according to their type, for readability. E.g., one line for object A, one line for special action, etc, and collapse into groups.
    Use something like hungarian notation or camelcase. Add prefix to fastloop/group name to simulate namespace.
    Etc.

  2. #12
    Clicker Fusion 2.5 (Steam)
    Linky's Avatar
    Join Date
    Mar 2020
    Location
    Egypt
    Posts
    229
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I actually find loops to be very useful in a lot of ways (atleast in my opinion ), running a loop as a trigger can make things more manageable and doesn't make you worry about the event ordering that much
    For example: I run a loop as a trigger whenever I play a sound or music, this allows me to place the actual sound related events into there own group away from other stuff

    Btw I "recently" discovered that nested loops can mess up with events optimization when it comes to positioning objects, which makes them function in a wrong way, very weird bug, but only happens in specific scenarios and you can get around it anyways: Build 294.1 - Beta version - Page 2 (clickteam.com) (Post #69 oh god I can't believe I said that seriously :V )

  3. #13
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Volnaiskra's Avatar
    Join Date
    Jan 2014
    Location
    www.sprykegame.com
    Posts
    3,022
    Mentioned
    133 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Darkhog View Post
    Could you share your wisdom and how you organize your code? Because my current game has a likelihood of becoming such a mess.
    I'll share what I've learnt, though a lot of it isn't about specific coding techniques (actually, none of it is) but just about being disciplined and smart: stop and comment as you work, plan your work carefully, keep things tidy, avoid impulsively adding new ideas, etc.

    Some of what I suggest below is universally good advice, where a little bit of time spent now will likely save you a lot of time in the future. But depending on your situation, some things will be overkill. If you're a hobbyist who enjoys exploring and moving from project to project without really finishing many of them, then you probably shouldn't get too bogged down in the organisation stuff. Similarly, if you're in the situation that defisym describes where you don't fully know how your game will pan out yet, and big things are likely to still change, then you should probably spend more time thinking about the game before you spend lots of time locking down your code.

    In my case, I'm working on a massive project that's already consumed some 25k hours, with ~13k hours in Fusion alone, where I've had to learn virtually everything as I go. Spryke will be one of a handful of things I will ultimately judge my life by, so needs to be of a very high standard. It's probably the hardest thing I've ever attempted, and it'd be 10 times harder if I let it get sloppy, which is a cost that I can't afford. My vision for the game has been clear and locked down for years now, and the most complicated problem solving is now behind me, so there won't be any more large surprises or shifts in direction (I had many of them along the way, but they're all long ago now).




    Like I said, the main thing is to just keep asking yourself "will I understand how this works in 2 years' time?". And whenever the answer is "no", which it usually will be, make the effort to clean it up. A human being's working memory (the very short-term memory that you use for your current task) is very small. Most people can only hold 7 items comfortably in their working memory, which is why most phone numbers are fewer than 8 digits, and why the melodies of most hit songs are fewer than 8 notes. Every time you leave an unnamed Alterable Value A or an anonymous teal diamond in your MFA, you are forcing future-you to clog up one of those precious 7 slots, which leaves fewer slots for the actual problem solving. Which means you'll work slower, make more mistakes, and enjoy yourself less. So write comments, give your altVals helpful, explanatory names, and keep your frames and objects organised.

    Always keep a notepad and erasable pen in front of you as you work, and do as much of your problem solving as possible on paper. That way, you'll find and fix most of your mistakes and sloppy logic before they reach your code. An added benefit of this is that you can program while you're out of the house too - I often program while my daughters are playing at the playground, for example.

    Take advantage of one of Fusion's strengths, which is the ability to keep things visual. Keep your altVals grouped logically in separate objects so that you can more easily find the ones you need when you need them:




    Put small, square icons into the first frames of frequently used objects, so that they are less awkward in your Frame Editor and more readable in your Events:


    (better icons make the version on the right more readable)


    Now that we have the ability to reorder altVals, you can group them and use additional ones as labels:




    As your game grows, keep the objects themselves grouped logically,




    Keep your code in categorised, labelled groups:




    Use the Advanced Comment Object to put comments inside your events when needed:




    Sometimes there's code that is just definitely going to be unreadable. My particle system is comprised of about 300 events, many of which look like this:




    I've got no hope of ever understanding that. In fact, it looked like gibberish to me even just 1 week after writing it. So I made it so I don't have to understand it. I made it communicate with a simple INI file:




    By changing some simple parameters in this INI file, I can create different flying particle effects (eg. rain, leaves, dust, bubbles), without having to remember how it actually works:




    There are a few other steps of course, like importing the particle graphics into Fusion. So that I don't have to fumble around with these steps in the future, I've written clear instructions for myself in what I call my 'Spryke Bible', which is an Excel sheet that contains various references and legends to help me keep track of how everythingworks. As always, the goal is to minimise the amount of time and working memory I need to get things done, so that I can devote my brain to the creativity and problem solving itself, which is hard enough. Once I've done the hard work to construct something, I don't want to have to expend mental energy to deconstruct it in the future:



  4. #14
    Clicker Fusion 2.5 DeveloperHTML5 Export Module

    Join Date
    Jun 2006
    Posts
    1,505
    Mentioned
    10 Post(s)
    Tagged
    0 Thread(s)
    I think there are three ways depending on the size of the program. For a simple program with a few lines of code, then providing a simple set of instructions will do for the future programmer to follow.

    As the program complexity grows then "Structured Design" offers a better way to design and document a program. In this case you may need to get a book on "Structured Design". This will help a furture programmer to understand the concepts of functions and modules and what they do in your program.

    Last of all for large, complex programs, "Object Oriented Design" was created for these types of programs. Again, a good book is helpful.

    It's up to you to select a documentation approach which allows yourself or another to understand and maintain the program code in the future.

    Do not kid yourself in thinking you will "remember" how the programs works in the future. Documentation is well worth the time no matter which language you are using.

  5. #15
    Clicker Fusion 2.5Fusion 2.5 Mac
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    zip2kx's Avatar
    Join Date
    Jun 2015
    Posts
    895
    Mentioned
    18 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by defisym View Post
    That's why indie developers need decades to release their project, including me.
    haha true that. I find myself, especially by the end of projects, just forcing myself through the different tickets and to-dos just to get the game done. If not I spend too much time on admin which just kills the little motivation I have left to finish the game.
    Not to mention you also have to start marketing, setting up steam store, emailing influencers etc.

  6. #16
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export Module
    Outcast's Avatar
    Join Date
    Jan 2011
    Location
    Sweden
    Posts
    3,398
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Volnaiskra View Post
    I'll share what I've learnt, though a lot of it isn't about specific coding techniques (actually, none of it is) but just about being disciplined and smart: stop and comment as you work, plan your work carefully, keep things tidy, avoid impulsively adding new ideas, etc.

    Some of what I suggest below is universally good advice, where a little bit of time spent now will likely save you a lot of time in the future. But depending on your situation, some things will be overkill. If you're a hobbyist who enjoys exploring and moving from project to project without really finishing many of them, then you probably shouldn't get too bogged down in the organisation stuff. Similarly, if you're in the situation that defisym describes where you don't fully know how your game will pan out yet, and big things are likely to still change, then you should probably spend more time thinking about the game before you spend lots of time locking down your code.

    In my case, I'm working on a massive project that's already consumed some 25k hours, with ~13k hours in Fusion alone, where I've had to learn virtually everything as I go. Spryke will be one of a handful of things I will ultimately judge my life by, so needs to be of a very high standard. It's probably the hardest thing I've ever attempted, and it'd be 10 times harder if I let it get sloppy, which is a cost that I can't afford. My vision for the game has been clear and locked down for years now, and the most complicated problem solving is now behind me, so there won't be any more large surprises or shifts in direction (I had many of them along the way, but they're all long ago now).




    Like I said, the main thing is to just keep asking yourself "will I understand how this works in 2 years' time?". And whenever the answer is "no", which it usually will be, make the effort to clean it up. A human being's working memory (the very short-term memory that you use for your current task) is very small. Most people can only hold 7 items comfortably in their working memory, which is why most phone numbers are fewer than 8 digits, and why the melodies of most hit songs are fewer than 8 notes. Every time you leave an unnamed Alterable Value A or an anonymous teal diamond in your MFA, you are forcing future-you to clog up one of those precious 7 slots, which leaves fewer slots for the actual problem solving. Which means you'll work slower, make more mistakes, and enjoy yourself less. So write comments, give your altVals helpful, explanatory names, and keep your frames and objects organised.

    Always keep a notepad and erasable pen in front of you as you work, and do as much of your problem solving as possible on paper. That way, you'll find and fix most of your mistakes and sloppy logic before they reach your code. An added benefit of this is that you can program while you're out of the house too - I often program while my daughters are playing at the playground, for example.

    Take advantage of one of Fusion's strengths, which is the ability to keep things visual. Keep your altVals grouped logically in separate objects so that you can more easily find the ones you need when you need them:




    Put small, square icons into the first frames of frequently used objects, so that they are less awkward in your Frame Editor and more readable in your Events:


    (better icons make the version on the right more readable)


    Now that we have the ability to reorder altVals, you can group them and use additional ones as labels:




    As your game grows, keep the objects themselves grouped logically,




    Keep your code in categorised, labelled groups:




    Use the Advanced Comment Object to put comments inside your events when needed:




    Sometimes there's code that is just definitely going to be unreadable. My particle system is comprised of about 300 events, many of which look like this:




    I've got no hope of ever understanding that. In fact, it looked like gibberish to me even just 1 week after writing it. So I made it so I don't have to understand it. I made it communicate with a simple INI file:




    By changing some simple parameters in this INI file, I can create different flying particle effects (eg. rain, leaves, dust, bubbles), without having to remember how it actually works:




    There are a few other steps of course, like importing the particle graphics into Fusion. So that I don't have to fumble around with these steps in the future, I've written clear instructions for myself in what I call my 'Spryke Bible', which is an Excel sheet that contains various references and legends to help me keep track of how everythingworks. As always, the goal is to minimise the amount of time and working memory I need to get things done, so that I can devote my brain to the creativity and problem solving itself, which is hard enough. Once I've done the hard work to construct something, I don't want to have to expend mental energy to deconstruct it in the future:


    Super useful post! Will def read through this again when I start a new proper project (if you forgot any good practices please add them later )

    I am a super messy person when it comes to pretty much everything. It is strange though because I actually have extremely good dedication and strict routines and everything I set my mind to I do without fail so it is a very strange mix and not sure how that works exactly. But as a friend frequently describe it I am the sort of person who can stand with an item in my hand and then be done with it and instead of actually placing it back where it belongs I just drop it and leave. This makes everything around me messy, including the computer and the code.

    I have really tried to make things better and more organized in my code, even when prototyping and it really helps. It is really something that needs to be something you do from the very start through the very end. My current long project that has grown to about 14k "lines" in the editor and while it actually has some structure in place it is a mix of mess and structure.

    Also I think the later updates on Fusion really helps a lot (like being able to reorder alt values) and it is actually one of the areas I appreciate most now when there are updates for things that makes things more smooth to work and restructure. I still do some dumb stuff though because there is no really clean fast way to do it, like adding a bunch of letters at the end of altvalues like BLAAAAH to be able to find that item fast after in the search window. Also one of the biggest reason for mess in my items now is that there is no way (as far as I know) to just mark the objects you are currently working with so I have to constantly move all the objects I am currently working with all the way to the left of the event editor one by one in this akward movement where you grab it and then swing the mouse up and down to the left to increase the scroll speed.. If someone know a better way please let me know

    Btw also Volnaiskra I have a very vague memory I have asked about this before but why use the Advanced Comment Object when you can just insert regular comments? I looked at the example picture and would it not be possible to insert regular comments in that section above each event?

    Also happy to hear that you still work on Spryke and hope you will add it to Steam soon (and maybe other platforms?) I have released a few games on Steam now so if you would have any question about that procedure when the time comes don't hesitate to shoot a message.

  7. #17
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Volnaiskra's Avatar
    Join Date
    Jan 2014
    Location
    www.sprykegame.com
    Posts
    3,022
    Mentioned
    133 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Outcast View Post
    Also I think the later updates on Fusion really helps a lot (like being able to reorder alt values) and it is actually one of the areas I appreciate most now when there are updates for things that makes things more smooth to work and restructure.
    Yes, Fusion has been really great with this over the past few years. The software is a lot nicer to use than it was in 2014 when I started. They've fixed a lot of flaws and added a lot of good new features, including several "stuff I never realised I needed" type things.


    Also one of the biggest reason for mess in my items now is that there is no way (as far as I know) to just mark the objects you are currently working with so I have to constantly move all the objects I am currently working with all the way to the left of the event editor one by one in this akward movement where you grab it and then swing the mouse up and down to the left to increase the scroll speed.. If someone know a better way please let me know
    The only way I know is to use the Event List Editor. Back when I used the Event Editor I used to wrestle with keeping things in folders so I could open/close them as needed, to try and avoid having rows of ungrouped objects that stretched for kilometres. But juggling all those folders became a part-time job itself, and I never managed to keep up. But I've exclusively used the Event List Editor for years now, and it doesn't have this problem. You can start a new action without needing to have the relevant object visible onscreen - you just choose "insert action" then find the object you want in the search-as-you-type box.

    It's funny. When I first used Fusion, the Event Editor was the big attraction. I found the Event List Editor off-putting, and probably wouldn't have used Fusion at all if it only had the Event List Editor. But now, it's the opposite. I find the Event List Editor way easier to use, and I actually find the Event Editor confusing and stressful to use. I don't like how you can never see all of what's going on, but have to rely on checking and remembering what's inside tooltips.

    Btw also Volnaiskra I have a very vague memory I have asked about this before but why use the Advanced Comment Object when you can just insert regular comments? I looked at the example picture and would it not be possible to insert regular comments in that section above each event?

    The image below is of a single event. While I could put a regular comment before or after this event, the Advanced Comment Object lets me place comments inside the event, as 'actions' or 'conditions'. This lets me write notes directly next to the relevant actions, for enhanced clarity. I've changed the Advanced Comment Object's icon from its default blue color to a plain grey square, which makes it blend into the background and not steal focus from the real actions around it.





    The above is actually a fragment of a much larger event (which for a variety of reasons can't be broken up into smaller events but needs to remain a single event). It's a monster event, but it's pretty easy to understand because it's all annotated. If I could only use regular comments before/after this event, it'd be much harder for me to make sense of what's going on.


  8. #18
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export Module
    Outcast's Avatar
    Join Date
    Jan 2011
    Location
    Sweden
    Posts
    3,398
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    I have dipped my toes into the Event List Editor before but I have always returned to the normal editor. I am not sure I just need more time to adjust or what it is but for me the Event List Editor always looks so cluttered to me because unlike where in the regular editor you just see the conditions lined up in the Event List Editor you also get the expanded conditions so everything takes up so much more space (in the vertical plane).

    I can really see the benefit of being able to insert actions directly without having to find the item first but I sometimes do this by just double clicking on the condition in the event editor and then right click in the new window that opens (action editor)

  9. #19
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export Module
    Outcast's Avatar
    Join Date
    Jan 2011
    Location
    Sweden
    Posts
    3,398
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    Btw I really like the idea of putting in labels in the alt values and I hope clickteam could take a look at adding a real feature like this. Just being able to remove the 0 from these labels would make it look even more clean if that was possible. I currently have 353 global alt values so adding labels would really help with the overview

Page 2 of 2 FirstFirst 1 2

Similar Threads

  1. Looking for Tutorials for 3D in Fusion
    By tobydavis in forum Fusion 2.5
    Replies: 0
    Last Post: 15th March 2020, 05:43 PM
  2. OpenGL Tutorials for Fusion 2.5
    By Akshay in forum Fusion 2.5
    Replies: 5
    Last Post: 17th May 2017, 06:30 PM
  3. Writing a language interpreter in Fusion
    By Hydra in forum Fusion 2.5
    Replies: 5
    Last Post: 5th March 2015, 09:06 PM
  4. Seeking more code-centric beginner's tutorials...
    By Wolfsong73 in forum Fusion 2.5
    Replies: 4
    Last Post: 18th November 2014, 12:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •