Code Advice needed, play random sounds, continuous loop needed

tsextrotsextro Member Posts: 25
edited November -1 in Working with GS (Mac)
I'd like to do the following in the most elegant way possible with the least amount of code. I'm wanting to do the following.

1. Random number from 1 to 75 chosen - (I can do this)
2. I have 75 different sounds. I'd like the simplest way to have it play one of the 75 sounds. I'm currently thinking that I would need 75 rules and conditions .... if it is 1, play sound 1 and so on. Is there an easier way?
3. I'd like to wait for four seconds after the first sound above is played so I have a variable that does something like set attribute for x to be x+4 . I would use the Timer After X to wait for four seconds later before playing a sound.
4. I want the equivalent of a Go To 1 basic language condition so that it would continue to pick a random number, play a sound 4 seconds after the last one and so on until someone taps the screen to stop it or possibly after 1 minute or two.

I appreciate your advice in advance.

Comments

  • tsextrotsextro Member Posts: 25
    I did solve the loop issue by using the Timer every x seconds.
  • tsextrotsextro Member Posts: 25
    I thought I'd post how I generate a fairly random number. I have a button on my main menu of my app that takes me to a game level screen. On that screen, a user taps a game level button.

    Create 3 integer variables - mainmenu, gamelevel, and gametimediff
    When they tap the first button on the main menu, set mainmenu=game.time
    When they tap the game level button, set gamelevel=game.time
    On the next screen where the game begins
    set gametimediff = gamelevel - mainmenu

    Since they are all 3 integers, it will most likely be a number between 1 and 5 as a person usually taps the submenu button within 5 seconds. If they wait longer, the gametimediff will increase.

    Random number (gametimediff,74)
    I happened to want a random number between somewhere around 1 and 74.

    I have another rule that checks to make sure that the gametimediff doesn't get too large and become too great to give a useful number.

    rule
    if gametimediff >30 then set gametimediff to 1
Sign In or Register to comment.