Changing to a Random Scene

sdparduesdpardue Member Posts: 110
edited November -1 in Working with GS (Mac)
Here's the issue:

I have 5 scenes with games/puzzles that I want to display in random order, displaying all 5 of the scenes, with no scene displayed twice.

Each scene has a boolean attribute (for example game.Scene1Played) that indicates whether it has been displayed. All 5 attributes are initially set to False.

To select the first scene, i generate a number that I store in an attribute game.NextScene using random(1,5). Then, if game.NextScene=1, I change scene to Scene1, if game.NextScene=2, change scene to Scene2… etc. It's easy to select the first one to display, since none of the 5 have yet been displayed.

Where I have the problem is in how to select the 2nd through 5th random scene.

Upon the user clicking an arrow button, I generate another random number with random(1,5) and if that scene hasn't been played, then i change scene to that scene. But if it HAS already been played, I need to keep generating random numbers until I find one that hasn't been played.

Without some sort of WHILE loop mechanism, I can't figure out how to keep generating random numbers until I find a non-played scene. (BTW, I first check to see if they've all been played and go to a "Finished" scene.)

Has anyone been able to figure out how to simulate some sort of looping structure for rules? Or maybe limit a group of non-continuous numbers from which I can randomly pick one? Or another way to do this? While it's just 5 scenes at this point, I can envision selecting random scenes from a larger number.

Thanks,

Steve

Comments

  • sdparduesdpardue Member Posts: 110
    Cool. Interesting solution.

    Thanks!
  • RockiesInOctoberRockiesInOctober Member Posts: 7
    I know this was all posted a long time ago, but I'm fairly new, and I need to change to random scenes for the app I'm creating. When I go to tshirtbooth's link, I see a button to download the project, but when I click on it, it just opens the game in a new window. Am I doing something wrong? Thanks for the help!
  • RockiesInOctoberRockiesInOctober Member Posts: 7
    Ok, does anybody know how to just do this? It's the biggest thing holding me back right now.
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    you are doing something wrong when you download the template, you need to rename the file you download to a .zip from the .game, then you will be able to extract it and open it in gamesalad
  • RockiesInOctoberRockiesInOctober Member Posts: 7
    Wow, thank you so much!
Sign In or Register to comment.