How to make something random?

tonymcintosh777tonymcintosh777 Member Posts: 2
edited November -1 in Working with GS (Mac)
i was going to make a game with items flying past the object but how do i make the items come in at random parts of the screen?
Any help cheers

Comments

  • ORBZORBZ Member Posts: 1,304
    use the random function.

    Because computers do not have a piece of radioactive material in them they can not generate truly random data (although thermal sensors could work? maybe) The next best thing is to use a psudo-random number generator. Random number generators produce seemingly random output, but if you know the seed value you can always recreate the same sequence of random numbers. This can be a good or a bad thing depending on your needs.

    but be aware that GameSalad does not provide a way for you to seed the random function with the system clock. So every time you run it it will produce the same sequence of random numbers.

    If you want to ensure that the sequence is randomized every time you play the game you will need to call the random function every 1/100th of a second in a timer on your title screen until the screen is touched. The number of times it is called will be different for every user since every person will take a slightly different amount of time to touch the screen every time they play thus the random function will be called a random number of times before game start.

    This will cause the sequence to appear random.
Sign In or Register to comment.