Hey there!
I am making a Knots and Crosses game, and I have finished the scripts for X and O placement... But, I now need to figure out how to detect that I have three thingymabobs in a row...
I have set a lot of invisible lines in the background, so when they get the que, they sense if they have three in a row.
THE PROBLEM: I need a simple script, as there are five Xs and four Os and I want to detect only three. Instead of saying ->
when gf clicked forever if (touching [sprite 1] and [sprite 2] and [sprite 3]) broadcast [I got 3 in a row] endThis scrpit only allows for detection of three of five of the sprites... SO, is there a script that is able to say... 'If touching three of possible Sprites one, two, three, four, five' instead of me listing all the possible combinations for me to write in a long script.
Offline
But is there a way to detect a group of three from a group of sprites?
Offline
YES, THERE IS A WAY TO DO THIS!
I have done this in one of my games, and here is how you do it:
First you make a list and put in it all of the sprites you wish to detect. Put the actual names of the sprites in the list. For example, if your sprite is named "Enemy1", type it exactly like that for the list, even with capital letters.
Okay so you've got your list, now do this:
make a variable and call it whatever.
when gf clicked set [Sprite v] to (0) Forever change [Sprite v] by (1) if <(Sprite) > (length of [list of sprites to detect v]) > set [Sprite v] to (0) endNow make another variable called "Temporary". It doesn't have to be called that, but you'll understand why I said to do so in a minute.
when gf clicked Forever if <touching (Sprite) ?> set [Temporary v] to (Sprite) //this way it doesn't lose focus Do whatever here, but make sure it's associated with toucing "Temporary"!Hope I helped! Good luck!
Offline
This is rather confusing, sorry, amatuer scripter is my name...
Is there a way to put sprites into a list??
Offline
CHOMPYCHEESE wrote:
This is rather confusing, sorry, amatuer scripter is my name...
Is there a way to put sprites into a list??
Okay try this:
with the repeating code of "Sprite constantly changing, you could do:
set [Temporary v] to (Join [Sprite](Sprite))Does THAT help any?
Offline
Name your crosses "c1", "c2", etc.
set [c v] to (0) set [j v] to (0) repeat (5) change [c v] by (1) if<touching(join [c](c))?> change [j v] by (1) end end if<(j) > (2)> broadcast [crosses win v] end
Last edited by MoreGamesNow (2012-06-28 18:40:20)
Offline