Most efficient way to give bonus for kills in a time period?

TomCoffeeTomCoffee Member, PRO Posts: 175
Hi... working on my first "game" and I'd like to award a bonus if 3 or more bad guys are killed in a 1 second period.

What's the most efficient way to do something like this? All 3 bad guys would be different actors... Thought about something like this:

Have 3 attributes recording the millisecond that a guy is killed (Kill1, Kill2, Kill3).
Have 1 attribute as a Counter (1, 2, or 3).

When a guy is killed it pops the millisecond in Kill1 and increments the counter.
When another guy is killed it fills in Kill2 and increments counter.
Same with 3rd kill.

Then have a check which runs and says: "If Kill3-Kill1 < 1 then BONUS!"

Or is that too fast/too inefficient for GameSalad?

Thanks!

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited April 2013
    In your main player actor or a control actor:
    Timer every 1 second
    .....Change Attribute game.killStreak to 0

    When game.killStreak ≥ 3
    .....[award bonus]

    And in your enemy actor:
    When [condition for dying; e.g. collides with bullet actor]
    .....Change Attribute game.killStreak to game.killStreak+1

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

  • TomCoffeeTomCoffee Member, PRO Posts: 175
    Wow... Sweet... that seems like a MUCH better way... Thanks a lot!

    So you would use a timer? Definitely easier than fiddling with device microseconds. I've read so much about "optimizing" GameSalad that I think I've gotten a little paranoid about optimization... Thanks!
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    I tend to use Timers when I'm initially building an app. Then if I feel the need, I'll go back and replace them. I supposed it's a bit lazy but I like to know that the rules are going to be visually simple and that they work before I start optimizing.

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

Sign In or Register to comment.