Matchgame Coding question

jweaver911jweaver911 Member Posts: 439
edited November -1 in Working with GS (Mac)
Hey guys, I'm about to embark on a challenge. I have a kids game that is basically a match game. However the twist is the character announces what object to "match" out of a crowd of objects. So for example, the actor shows a hotdog, and you have to click the matching actor from amongst other actors.

Any ideas as to how to make this announcement of the preferred choice, random? I know without and array or some form of script this might be tough. I would prefer this to only occur for the remaining available choices which are on screen.

Thoughts?

Comments

  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    how many audio/actor combos are there total?
  • jweaver911jweaver911 Member Posts: 439
    well, I would anticipate that the max that the choice pool would consist of would be around 8-10. This is going to be for 3-5 year old children and mostly consist of shapes and colors. :) However, I'm having trouble wrapping my mind around how to approach this part.
    On the easier levels I would only have about 3-4 choices to begin with.
  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    you need a game boolean attribute for each choice. the correct attribute would be changed to true once an option is randomly selected.

    you would need an actor that makes the random choice and plays the audio. this actor needs an integer which you would initialize with a random number (1 through max choices). it also needs a boolean for each option(call them self.1used, self.2used..etc.). you then need a rule for each option that checks to see if they are a match to the random number. if one is and it hasn't already been used (check self.1used.), you change the the game level boolean corresponding with the choice to true, you change self.1used to true and you play the audio. if it does match the random value but it is already marked as used, you need to generate a new random number which would start the process over again. if it does not match the random value, do nothing.

    the objects the player will touch need a boolean attribute to track if they have already been used. when touched, you check to see if the corresponding game level boolean is true. if it is, you change it false, change self.used to true, and do something to tell the player they were correct.
  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    you may need to place the secondary random number generation logic in a timer (every .01 seconds). otherwise, it would get stuck if it happened to pick the same number again...
  • jweaver911jweaver911 Member Posts: 439
    Wow. That's a great help. I appreciate your time and energy spent working through that. :)
    I was kind of on the same path that you started with in the first and second paragraph. Just wanted to make sure there wasn't an easier way.
  • jweaver911jweaver911 Member Posts: 439
    Maybe I will just take an easier route and just have a predefined goal for each level and not randomize that. Hmmm. I'll have to play around with it,
    Can you randomize which scene is chosen?
  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    As far as I have thought it out, it works out to be the same logic bulk, but moved to the intro screen.
  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    as long as the selectable items never overlap in either X or Y (either ... not both), I have a solution...

    http://gamesalad.com/game/play/54660
  • jweaver911jweaver911 Member Posts: 439
    Sorry I got a little busy te last few days. My long distance family decided to hire me out for some Business cards lol. So i've Been a little busy and haven't had time to check out your example in my game to see how it may work. I still might have a different approach. I don't know. I know I need to get cracking though! Thanks for the effort too!
  • jweaver911jweaver911 Member Posts: 439
    Hey I'm back. I've decided to have 10 different actors spawn at random. I am running into difficulty getting them to spawn the correct number and stop. I am trying to get them all to spawn from the same spawning actor in about a second or two's time. For some reason my logic doesn't seem to work right.

    I have a lot of game attribs which include

    attrib spawncounter (integer) to count number of actors spawned
    attrib spawnactor (integer) determine specific actor to spawn(out of a pool of 10)

    Then I have game attribs for each actor1-10 that determine whether spawned or not (i.e. actor1spawned...etc.)

    so my rules currently look like this
    I have a click designate a changeattrib to create a random "Spawnactor" attrib (1,10)

    then I'm trying to use my spawnpoint actor with a rule like this...

    When Game.Spawncounter <or= 4 (Because I currently only want 4 random actors to pop up)
    Timer Every .2 sec
    When ALL Conditions Valid
    if attrib game.actor1spawned = false
    if attrib game.spawnactor = 1 (this is the number referring to this particular actor: out of 10)
    then change attrib actor1spawned to TRUE (for checking for dupes)
    then change attrib game.spawncounter to +1 (to add to the count, so that it will stop)
    SPAWN Actor1
    Otherwise
    Change attrib game.spawnactor random(1,10)

    And then I have this part repeated respectively for each of the ten different types of actors.

    So My hopes would be for it to stop when the count reaches the number I desire which for this example would be four. I'm also intending for it to check for no duplicates at the same time.

    But I'm having trouble getting the logic to work right, and I know I should have multiple spawn points but that was getting way too confusing and from what It seems, I don't really need it.

    Any further help would be much appreciated.

    ~ J-Dub
  • jweaver911jweaver911 Member Posts: 439
    Bump
  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    Can you post a generic sample exhibiting the issue?
  • jweaver911jweaver911 Member Posts: 439
    Hey! I got it. It turns out I didn't have my counting logic correct! Bah... Such a simple mistake, throws off the whole thing.

    Thanks!
Sign In or Register to comment.