Rules inside of rule? (super newbie question)

wirelesstkdwirelesstkd Member Posts: 75
edited February 2013 in Working with GS (Mac)
Hi guys, I've got another super newbie question. I'm still following along in the tutorial for the basic shoot em up game, and there's a rule for the boss ship taking damage and dieing. The manual puts the rule for dieing is inside the rule for taking damage. I'm wondering if it matters if that rule is inside another rule, or if it can exist as its own.

The one thing I've noticed is that the backstage gets cluttered quick, so I've been collapsing every rule as I create it, plus giving each rule a descriptive title.

If I put the rule to kill the boss inside the rule for the boss to take damage, it just seems that it might be harder for me to find later (maybe not with this game, but I'm thinking about more complex games down the line - I'd hate to develop a bad habit now that I have to break later).

On the flip side, I don't know if there are reasons that these two events (boss takes damage on collision with missile and boss dies when game.bosshealth is less than or equal to 0) should be married to each other.

Does either way work, or is there a definitive "best practices" here?

Thanks!

Comments

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    Rules can be inside of other rules.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    I'd say in that example it's best to have them separate so that the health=0 rule is easier to see. There's no reason to have to have one inside of anther. Obviously, if you want the health rule to only be checked when the boss takes damage, then you would cascade them.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • wirelesstkdwirelesstkd Member Posts: 75
    I'd say in that example it's best to have them separate so that the health=0 rule is easier to see. There's no reason to have to have one inside of anther. Obviously, if you want the health rule to only be checked when the boss takes damage, then you would cascade them.
    Hmm... so if the rule about the boss health being 0 is inside the rule where he takes damage, the computer is only checking his health when he takes damage... does this mean that if it is outside of that rule, the computer is always checking his health? Would this mean that if a game got big and resource heavy, these kind of things would be better kept inside of the rules that cause the value to change?

    Or am I unnecessarily over thinking it? ;-)
  • ChimoruChimoru Member, PRO Posts: 137
    I would put as many rules inside of rules as you can. Otherwise, the computer is constantly reading all the rules you have by themselves. If you have 5 rules inside one rule for example, those 5 rules are only scanned when the encompassing rule is valid. If you have them all seperate, the computer is constantly reading six rules, which impacts fps.
  • wirelesstkdwirelesstkd Member Posts: 75
    Aquadel, that makes sense and answers my question. It's a balance between my ability to swiftly sort through my rules versus how much of a drain the game will make on the system.

    Thanks!
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Aquadel, that makes sense and answers my question. It's a balance between my ability to swiftly sort through my rules versus how much of a drain the game will make on the system.
    It is. And I think that when you're starting out it makes sense to keep things as simple as possible (and naming rules and using Note behaviors is helpful, too). Personally, I made many inefficient choices the first time I designed an app, but it was all part of the learning process. I think it actually is good to not worry too much about performance and efficiency when you design your first app -- assuming you aren't expecting to make something amazing right off the bat.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.