Tip for recognising button combinations. Cooking game example.
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
-------

"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
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
-------

"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
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
-----------
"...the resulting sonic effect is almost mesmerising." Pocket Gamer
Sound design and music service available: http://tiny.cc/MusicService
www.HoneyTribeStudios.com
----------------------------------------------
http://www.davidgriffinapps.co.uk/
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
------------
"...the resulting sonic effect is almost mesmerising." Pocket Gamer
Sound design and music service available: http://tiny.cc/MusicService
www.HoneyTribeStudios.com