1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

Randomness in timelines

Discussion in 'Programming' started by Mapped, Jan 2, 2018.

  1. Mapped

    Mapped Member

    Joined:
    Oct 5, 2017
    Posts:
    7
    So I've been making some kind of randomized-Bullet-Hell type of game, and not too complex of course since it is my first time using code and GameMaker.
    I'm using a timeline to create all of the bullets and the instances, which work well, except for one detail: No many times how I restart my game, the randomness of numbers does not change.
    For example here, I used a code event to say spawn three warnings (which are going to transform into fireballs using the object):
    Code:
    instance_create(128+random(768),192+random(448),obj_fireball_warning);
    instance_create(128+random(768),192+random(448),obj_fireball_warning);
    instance_create(128+random(768),192+random(448),obj_fireball_warning);
    The problem is, they always spawn at the SAME EXACT PLACE. Same thing for very other instances. Is there any way I can fix this simply? Like without having to rewrite all of my code?
     
  2. Simon Gust

    Simon Gust Member

    Joined:
    Nov 15, 2016
    Posts:
    3,213
    randomize();
    in the create event called once at game start.
     
  3. Straight from Game maker:
    NOTE: This function will return the same value every time the game is run afresh due to the fact that GameMaker: Studio generates the same initial random seed every time to make debugging code a far easier task. To avoid this behaviour use randomize at the start of your game.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice