In need of assistance: Working with Actors and the expression 'Random'

DigitalDianaDigitalDiana Member Posts: 34
edited December 2011 in Working with GS (Mac)
Hello everyone,

I am working on my first game and unfortunately, I seem to have come across an obstacle. I am trying to get 1 out of 8 actors be individually selected at random to move from one location to another to perform a few actions and then move to its final location where it will be out of sight and the remaining actors will follow suit.

Here is my situation:

- I have 8 actors (Actors A,B,C,D,E,F,G, and H).

- I have 3 locations (from left to right Location X, Y, and Z).

- All 8 of my actors are at Location Z (all are off to the right of the screen and stacked so they remain invisible until they are individually called forth).

-My Goal: I want to randomly call forth one of my 8 actors and have that actor moved to Location Y. Once the event I have planned for that actor is over, I want that actor to move to Location X so it will be off screen and the next actor can randomly be called forth from Location Z to Location Y and so on until all 8 actors are at Location X.

-My Problem: I managed to get each actor from Location Z to Location Y to do their performances, but they all come out at the same time. None of them acknowledge that I want them to randomly come out one at a time after each one has finished their actions. They come out all cluttered together and I am unable to get them to come out one at a time.

How can I go about doing this?

Any help would be greatly appreciated. ^-^

Comments

  • cbtcbt Member Posts: 644
    Are you trying to call them randomly too? I mean B completes the route, 3 seconds later E, 6 seconds later H etc.? Or is there a time interval between actions you want to put?
  • DigitalDianaDigitalDiana Member Posts: 34
    No, I'm not trying to call them randomly as per your example. There is no timer interval.

    For the next actor from Location Z to be "randomly called," the actor that is at Location Y HAS to be finished with its performance and on its way to Location Z.

    When an actor is at Location Y, the Player (ex. you or me) will touch a button (different actor) that will cause/trigger the actor at Location Y to perform and then after the actor performs, it automatically leaves Location Y to go to Location X (this part it does well with what I have, but all the actors come out all together at once instead of individually and randomly selected).

    AS the actor is "leaving Location Y to Location X," one new actor (from Location Z) is "randomly selected" and it alone moves to Location Y. Then the cycle repeats until all the remaining actors at Location Z have been moved to Location Y and from there to Location X. Once all 8 of the actors are at Location X, I am going to trigger the ending for the game (which I have yet to create since I am still in the process of finishing this part of the game).
  • DigitalDianaDigitalDiana Member Posts: 34
    I am not basing the random selection on time. Just on calling out one single random actor after the first random actor performs and moves from Location Y to Location X until there are no remaining actors at Location Z.
  • DigitalDianaDigitalDiana Member Posts: 34
    Does anyone know how this can be done?
  • hotMagichotMagic Member, PRO Posts: 266
    If Im reading you right, you need to "gate" it. So do the random timer or whatever on each one. The first guy to trigger that should flip your "gate" variable. So it can be IsSomethingMoving=0, and that guy flips it to 1. In the rule that starts their movement, make them all ALSO check that IsSomethingMoving=0. So that way, the first guy essentially closes the door. When he's done moving, have him switch the gate back to 0.

    Also, do a better random, so they actually differ. Like do something involving random(0, gameclock.millisecond)%5+1 to get a true random from 1-5.
    The easiest way to pick which dude is to make a variable in the actor called ID. and when you place them in the world, just change that to 1-8.

    Roll your random to randomly select 1-8, and say if randomnum = ID, then I go.

    Hope this helps.
  • cbtcbt Member Posts: 644
    edited December 2011
    Here ya go.. :D

    http://gamesalad.com/game/55248 (I think this one didn't upload properly)
    (2nd one didn't upload properly)
    http://gamesalad.com/game/55250 (Here is the same game, 3rd time)

    I'm trying to post this for about an hour now. I explained it on text also but it got lost in the proccess.. Forum kept saying my password was wrong.. But I could sign into gamesalad.com with the same password.. And the uploading was just...

    Nevermind, just ask any part you don't understand..
    :D
  • cbtcbt Member Posts: 644
    Anybody able to upload games? I mean I can upload game to GS Arcade but it has been "being optimized" for 10+ hours..
  • DigitalDianaDigitalDiana Member Posts: 34
    Thank you hotMagic and cbt for replying to me. I apologize for the late replies in the Forum, but it would not let me add a comment so I had to switch from Safari to Firefox to be able to post right now.

    @ hotMagic: I will attempt your suggestion. I'm still a bit shaky when using GameSalad since I'm still new, but I will see what I can do.

    @ cbt: I'm sorry to say that I'm unable to see the games on any of the links you posted for me. They all show up saying "This game is currently being optimized for the web, please come back in a few minutes." Therefore, I am unable to see the work you did. :( I'll continue to keep checking back at it and hopefully it will show up for me. I have been checking it since yesterday.
  • cbtcbt Member Posts: 644
    https://rapidshare.com/files/1576093289/forum_help.zip

    Here, a zip file with only including a "gameproj" file.

    Arcade is still down.. I hate when these kind of things happen.. I love GS but I also hate it sometimes..
  • DigitalDianaDigitalDiana Member Posts: 34
    @ cbt: Thank you for the demo. I was able to download it and look at it. I really liked your notes. They were easy to understand, but unfortunately only actor C moved across the screen. None of the other actors moved. Actor C was the only one that moved and none of the other actors followed. It moved from right to left and curved down toward the bottom left corner. Nothing random occurred. I did my best to implement what I learned from your demo. I managed to get one actor to go from Location Z to Location Y to Location X, but once it got to Location X, no random actor was selected from the remaining 7 actors. The arrival of the first actor to its destination (Location X) did not trigger a randomly selected actor from Location Z. What shall I do?
  • DigitalDianaDigitalDiana Member Posts: 34
    @ cbt: I tinkered with my game further, using the knowledge I acquired from your demo, and I somehow managed to get it to randomize. :) But even though it does the randomizing, I now have another obstacle to overcome. Once all 8 actors are at Location X, the last actor that approaches Location X comes back to Location Y and rolls/rotates between both locations -- while each actor is at Location Y, I have each actor rotate depending on the button the Player touches and if the correct one is touched, the actor rotates in place and goes to Location X (I think this has something to do with why it's going back and forth between Location Y and X). Do you have a suggestion on how I can stop the last actor that approaches Location X to stop rolling/rotating back and forth to and from Location Y?
  • DigitalDianaDigitalDiana Member Posts: 34
    I keep trying to get the last actor to stop rolling/rotating back and forth repeatedly, but it seems that it keeps happening to a few of my 8 actors. It doesn't happen every time or to any one particular actor. The rolling back and forth between Locations Y and X just happen at random. How do I fix this?

    Here is the situation more specifically:

    - 8 actors at Location Z (off-screen) are selected individually at random.

    - Random Actor A goes from Location Z to Location Y, does a spin when the correct button is touched, then Random Actor A goes to Location X where it is out of sight (the same should happen for the Random Actors B, C, D, E, F, G, and H at Location Z).

    - Sometimes when I preview my game, a few of the actors go from Location Y to Location X, touch Location X and then roll/roatate back to Location Y and go back and forth between both Locations until it either stops at Location X, or if it's the last of the actors, it just continues to go back and forth and not stop at Location X.

    I have yet to watch all 8 actors successfully make it from Location Y to Location X and I want to be able to end my game when all 8 actors end up at Location X. What do I need to do?
  • cbtcbt Member Posts: 644
    I haven't menaged to read all of your posts. I'm at class and on my phone.

    But you mentioned my demo didn't work for you. I highly recommend you reinstall gamesalad. Completely remove it and install again because it was forking for me. It appears something wrong with your GS. That may be the reason from the beginning :D
  • DigitalDianaDigitalDiana Member Posts: 34
    @ cbt: Thank you for getting back to me again. :) I did as you said and uninstalled GameSalad and then I reinstalled it, but unfortunately I still just saw the C actor move. None of the others moved. The good news though, is that I was able to incorporate a bit of what I learned from your demo and it works fairly well. I want the ending of my game to be triggered when all 8 actors are at Location X, but it's usually the last 2 actors that won't stay at Location X. They keep rolling back and forth between Locations Y and X. Sometimes it's another actor or two, but it's mainly the last 2 actors to reach Location X that I'm having trouble with. I think it's because the randomization code doesn't know to stop after each actor has made it to Location X. I attempted creating an invisible score so when it hits a score of 8, it would trigger the ending of my game, but because the last two actors keep rolling back and forth, they keep triggering the score and making it past 8. I'm at a loss of what to do.
  • DigitalDianaDigitalDiana Member Posts: 34
    How do I randomize my 8 actors so that they each only gets called once? I managed to get them to be randomly selected one at a time, but when it gets down to the last two or three actors, the actor goes from Location Y to Location X and then rolls back and forth for a bit before finally stopping at Location X. Sometimes it doesn't even stop rolling or stop at Location X and just keeps going back and forth. What do I do?
  • DigitalDianaDigitalDiana Member Posts: 34
    How do I get my game to stop randomizing the actors after all 8 actors end up at Location X? I want my game to acknowledge that each of the 8 actors actors made it to Location X so that it will trigger the ending of my game, but it doesn't seem to know that each actor was used once and keeps the last actor or two rolling back and forth between Locations Y and X.
  • cbtcbt Member Posts: 644
    Just add actors a boolean attribute like "finished" and make it true if it reaches at Location X. And randomize only actors that has "finished=false" so it won't randomize actors that reached the ending position.

    I wish Arcade was working and you could have seen my demo. I still don't understand why it is not working for you.
  • DigitalDianaDigitalDiana Member Posts: 34
    Okay. I'll give that a try. How would I create the code to randomize the remaining actors that have not reached the ending point though? I understand what you mean, but I'm a bit confused as to how to create that part of the code (my random is set up as random(1,8) presently) and would the "finished" boolean attribute be the game attribute or actor attribute? Sorry for all the questions. >.<;
  • DigitalDianaDigitalDiana Member Posts: 34
    I can't seem to get it. I'm still trying though.
  • tutysestutyses Member Posts: 134
    is there any chance you can upload your gameproj? Which version of gamesalad are you using?
Sign In or Register to comment.