Pressing Buttons Combinations in a Specific Order in GS
thilanwij
Member Posts: 20
Hi everyone,
I am working on a runner game idea where if you get in a certain distance of an enemy, and once you are in that distance, a button combination will pop up on the screen. You have limited time to input this sort of combination (using available buttons) in order to pass that enemy successfully. If you mess up on the order of the button, it resets and you have to do it again. How would I able to pull this off in Gamesalad? If you need any more clearance, let me know!
Example:
an enemy appears. As soon as you are within 100 pixels of it, a combination of buttons will appear BIG on-screen, and you must input that same combination before you run into the enemy. If you did it, the enemy will disappear. If not, then you will run into it and game over.
I am working on a runner game idea where if you get in a certain distance of an enemy, and once you are in that distance, a button combination will pop up on the screen. You have limited time to input this sort of combination (using available buttons) in order to pass that enemy successfully. If you mess up on the order of the button, it resets and you have to do it again. How would I able to pull this off in Gamesalad? If you need any more clearance, let me know!
Example:
an enemy appears. As soon as you are within 100 pixels of it, a combination of buttons will appear BIG on-screen, and you must input that same combination before you run into the enemy. If you did it, the enemy will disappear. If not, then you will run into it and game over.
Comments
*Make sure the values are powers of 2 (2^0, 2^1, 2^2, 2^3, etc. = 1, 2, 4, 8, etc.).
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Thinking that tables are a good use for this?
Im also very interested to know how you get on with that.
I am a newbie(3months) to gamesalad so are limited to the tool. I am getting the idea of it now. i currently making a game where when the actor is in the air they can execute stunt by a series of commands.
how was the table method? im trying to work out where to start. lol
cheers
Don
Create game level integer call Button.total and to put a time frame on the button presses add a REAL game level attribute called ButtonTime
RULE (1st button in sequense)
when touch is pressed and game.buttontotal = 0
Change Attribute Game.ButtonTime to Self.Time
Change Attribute game.buttontotal to game.buttontotal+1
OTHERWISE
Timer after .2sec
Change Attribute game.button to 0
New RULE inside (1st Button actor not inside above rule)
When Attribute Game.Buttontotal (Doesn't = 3) and Self.time > Game.buttonTime+5
Change Attribute Game.Buttontotal to 0
RULE (2st button in sequense)
when touch is pressed and game.buttontotal = 1
Change Attribute game.buttontotal to game.buttontotal+1
OTHERWISE
Timer after .2sec
Change Attribute game.button to 0
RULE (3st button in sequense)
when touch is pressed and game.buttontotal = 2
Change Attribute game.buttontotal to game.buttontotal+1
OTHEZRWISE
Timer after .2sec
Change Attribute game.button to 0
Repeat to add more buttons. Easy beans!
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Make a game attribute that is a text attribute for input.
Make another attribute with the keyword.
Have a rule that checks if game.keyword begins with the game.input,
---When game.keyword is game.input pattern achieved.
Otherwise (This is if keyword doesn't start with input)
---Reset the game.input (Change Attribute game.input to )
When each button is pressed concatenate the key ID to the game.input
Change Attribute game.input = game.input..self.ID
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Am I doing something wrong?
Log(Actor: button): Correct combo entry… continue
Log(Actor: button): Correct combo entry… continue
Log(Actor: button): Wrong combo entry… STOP!
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Thanks a lot, its exactly how I want it.
Cheers
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
so my problem is,
I have 4 buttons and 4 combos.
the patterns are:
combo A: 1 2 3 4
combo B: 2 3 4 1
combo C: 3 4 1 2
combo 4 1 2 3
so executing the combo with the correct sequence works fine however, when I enter
1 1 1 1 Combo A also execute. I understand thats because theres a 1 in every col.
my code is basically same as yours but in the otherwise I have the same rules but searching row 2....then in that otherwise same rules but searching row 3 and same for 4.
this sounds quite a easy fix but I spent the last 3 hours on it and no luck.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
I have taken out the otherwise and has them as individual rules, but still no luck.
Im assuming I need it to read the first input and and see which combo matches and eliminate the one that doesn't.
will keep trying.
but every step is a learning curve. What would i do without this community. =D>
As being a newbie I must have misunderstood CodeMonkeys method. Thanks @CodeMonkey
Cheers
We all learn from each other. I always look very carefully at @Tatiang's and @CodeMonkey's suggestions. They are always spot on.
Here is my little mantra:
When in doubt -- let CodeMonkey spell it out!
I have a problem. In your rules for 'Display' you set a timer after 1sec to change input to ""
Well I added a display text to see the input and it works fine.
but on mine after 1sec the input display "" before I press any number. I changed the rules to 'change input to (*blank took out the "")' and it seem to work. Will that be a problem?