Spawning Random Actor.

cbtcbt Member Posts: 644
edited November -1 in Working with GS (Mac)
Hi,

On my other topic, I've mentioned a problem I'm having while creating a "Quiz App".

I want to spawn a random actor selected from 100 actors I've prepared.
There is 50 questions I want to ask. Every actor is a question, if answer is true, it should spawn the next random question.

"Kamazar" said;

"Assign each scene a number. Something like this.

Create Random Number
If Random Number = 4
Go to Scene 4 "

I can use this for actors too, but if I use this, every actor will have 100+ rules;

*****
If Random Number = 1
Go to Scene 1

If Random Number = 2
Go to Scene 2
.
.
.
.
If Random Number = 87
Go to Scene 87
etc.
etc.
.
.
******

I don't think iPhone can handle this.
And the major problem is, it is spawning the previously answered question again and again. I want to spawn the question only one time until the game restarts.

Is there a proper way to do a "Quiz App"?
It really sounds easy to do an app like this, but I don't think it is possible..

Comments

  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    not 100% sure,

    as I know people have problems with random not being very random..

    Also do search the forum for quiz.

    But here's my rough attempt anyway for what its worth:

    Make:
    game attribute random_number (integer)
    game.current_scene (integer)
    game.new_scene_ready (integer)
    Then have a rule

    RULE:
    if 'game attribute random_number' = 'game.current_scene'
    change 'game.new_scene_ready' to 0
    Otherwise
    change 'game.new_scene_ready' to 1

    Rule
    If question is answered correctly (you can work that bit out)
    if game.new_scene_ready = 0

    Change Attribute
    game attribute random_number to random (0,100)
    -Rule
    If
    game.new_scene_ready = 1
    add a timer (to be safe)
    after 0.5 seconds
    Change Scene goto Scene(game attribute random_number)

    What should all that do?

    Hopefully it will go:

    Is question answerd correcty?
    yes,
    make a random number, is its the same as before, try again,
    Once a new random number is ready, wait 0.5 seconds then change to that scene.

    You should only have to make the rule once and the rest would flow nicely, having a Prototype that only needs editing at any one time.

    ...

    Also you mention spawning, try and steer clear of this if its not 100% needed, as it eats up processor power.
    Maybe have 100 questions as different png images, and change image instead of spawning and destroying actors. Or if you are going to spawn, make sure you destroy the old actor, or actually change scene...
  • cbtcbt Member Posts: 644
    All of it is OK, but, how should I do the;
    "Change Scene goto Scene(game attribute random_number)"?

    "Change Scene" behavior only have a dropdown list. Is there any other way I don't know?
  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    just seen the most current thread on the forum is about a quiz...might be useful...or might be you already...

    as for your answer....very true (thats dumb to restrict it to that)...will have a think...

    I guess change image, which changes the question....but then you'd have to change which answer is the correct one..

    Hmm...
Sign In or Register to comment.