1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    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,199
    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