Tip for recognising button combinations. Cooking game example.

HoneyTribeStudiosHoneyTribeStudios Member Posts: 1,792
edited November -1 in Working with GS (Mac)
I've been making new demos and playing with different game mechanics. Here's something that others may find useful. There would be many ways of making the below example workable, this is just one.

You can use prime numbers to recognise button combinations.

Example: You have 4 different buttons. You can combine them in different combinations to trigger events. So it could be a cooking game.

Button A = grain
Button B = sugar
Button C = eggs
Button D = yeast

You want to be able to recognise when different foods are created and the order isn't important i.e A+B or B+A are both ok.

Create an index attribute game.prime and set it to 0
Create an index attribute game.count and set it to 1
Create a real attribute game.pressButton and set it to 0
Create a real or index attribute game.resetCount and set it to your preferred amount of seconds. Lets say 2 for now.

Button rules
RULE
When Button A receives touch
change game.count to game.count*3
change game.pressButton to game.time

RULE
When Button B receives touch
change game.count to game.count*5
change game.pressButton to game.time

RULE
When Button C receives touch
change game.count to game.count*7
change game.pressButton to game.time

RULE
When Button D receives touch
change game.count to game.count*11
change game.pressButton to game.time

So if in the game we want to make beer (grain + sugar + yeast) we press button A+B+D
With the attributes we set up that makes the game.count 1*3*5*11
Which is 165.

Or cake would be (grain+sugar+eggs) A+B+C
Which is 1*3*5*7
Which is 105

So to recognise beer was made have a rule

When game.count = 165

… trigger your beer event.
And change game.count to 1

And for cake:

When game.count = 105

… trigger your cake event.
And change game.count to 1

You'll also want to reset the count back to 1 if no button are pressed after a few seconds, 2 in this example.

So put a rule somewhere

When game.resetCount = game.Time – game.pressButton
Change game.count to 1

-------
image
"Honey Tribe is not only a remarkably endearing little game, but it's also incredibly addictive." Pocket Gamer
"...a touch above the rest in the endless running genre" 148apps.com
Say hi on Twitter
Like us on Facebook
Sound design and music service available: http://tiny.cc/MusicService
www.HoneyTribeStudios.com

Comments

  • IsabelleKIsabelleK Member, Sous Chef Posts: 2,807
    Cool tip! Very useful :) Thank you!
  • HoneyTribeStudiosHoneyTribeStudios Member Posts: 1,792
    You're welcome :)

    Yeah I suppose the above technique could be useful for point and click games too. You could reuse the same numbers to trigger different events in different scenes. Life will be much easier for loads of things when GS gets tables and arrays though. What method do you currently use for item combinations?

    In another new demo I'm using a different method for recognising sequences - like a 4 (or more) digit security number.

    Shaz
    -----------
    image
    "...the resulting sonic effect is almost mesmerising." Pocket Gamer
    Sound design and music service available: http://tiny.cc/MusicService
    www.HoneyTribeStudios.com
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    That's neat, Shaz; thanks! :-)

    ----------------------------------------------
    http://www.davidgriffinapps.co.uk/

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • IsabelleKIsabelleK Member, Sous Chef Posts: 2,807
    HoneyTribeStudios said:
    You're welcome :)

    Yeah I suppose the above technique could be useful for point and click games too. You could reuse the same numbers to trigger different events in different scenes. Life will be much easier for loads of things when GS gets tables and arrays though. What method do you currently use for item combinations?

    In another new demo I'm using a different method for recognising sequences - like a 4 (or more) digit security number.

    Shaz

    I have one riddle with item combination in episode 01 - player have to touch&hold the item (ingredient) and drag it to the bowl. If the item touches the bowl, it is destroyed, and game attribute "Ingredient 1" changes to true. Then with next item, and next, etc :) Each item has his own game attribute.
  • HoneyTribeStudiosHoneyTribeStudios Member Posts: 1,792
    TheMoonwalls said:
    I have one riddle with item combination in episode 01 - player have to touch&hold the item (ingredient) and drag it to the bowl. If the item touches the bowl, it is destroyed, and game attribute "Ingredient 1" changes to true. Then with next item, and next, etc :) Each item has his own game attribute.

    Ah ok. From reading the forums I decided ages ago to never use spawn or destroy. I got paranoid that it would just give me RAM headaches as a game got further along in development.

    ------------
    image
    "...the resulting sonic effect is almost mesmerising." Pocket Gamer
    Sound design and music service available: http://tiny.cc/MusicService
    www.HoneyTribeStudios.com
Sign In or Register to comment.