GM:S 1.4 Volcano lava bomb path generator

Discussion in 'Programming' started by Axl Trauts, Jun 28, 2016.

  1. Axl Trauts

    Axl Trauts Member

    Joined:
    Jun 26, 2016
    Posts:
    28
    Hi,

    I am planning on creating a Volcano that shoots lava bombs. I know that the best way to do it is creating paths, and assign each bomb one. But I think that maybe I can create something more dynamic and which saves resources, such as a dynamic path. So, I am assuming that using path_change_point will work.
    Those randomized points though, should have a constraint, as I don't want to create illogical paths.

    I have this image as an example of the first path. My idea is that a generated lava bomb starts that path. Some moments later, a second lava bomb. is shot, following a slightly different path but keeping the general curved shape, falling down to the "sea".

    The simplest way is creating multiple paths and randomly assign new bombs to one of those, of course.

    Do you have any ideas?

    upload_2016-6-28_14-34-41.png
    * Disclaimer: the volcano sprite is just for testing purposes, I too the image from Internet. I do not intend to use it later.
     
    Last edited: Jun 28, 2016
  2. jackhigh24

    jackhigh24 Member

    Joined:
    Jun 21, 2016
    Posts:
    604
    i would do it random so all your doing is creating lave bombs and each will choose a random direction and fall under gravity, not sure why you want to have pre set paths as thats not going to look like a volcano chucking stuff out.
     
  3. Axl Trauts

    Axl Trauts Member

    Joined:
    Jun 26, 2016
    Posts:
    28
    Not that I like to have pre set paths, but as I donĀ“t know how to make constrained randomized paths, I was thinking of that option.

    Constrained because I'd like that the points in the path follow a certain logic, the first starts at the mouth of the volcano, following ballistic path that first goes up from the fixed origin, travels left and falls to the ground at the last point. Of course, randomly mirror the path to shoot bombs to the right.
     
  4. Axl Trauts

    Axl Trauts Member

    Joined:
    Jun 26, 2016
    Posts:
    28
    Well, as I solved it fastest than I thought, I'd like this thread to be useful to other people. I'd appreciate if you guys can help me with something that can be better.

    First I created one path with four points, as show in the above screen, called path_volcano_1

    Then, in obj_volcano_1, I made this:
    Code:
    CREATE EVENT:
    var_time=0;
    Code:
    STEP EVENT:
    if var_time<10
    {   var_time+=1;
    }
    if tiempo=10
    {   instance_create(320,272,obj_lava_bomb);
        var_time=0;
    }
    In obj_lava_bomb:
    Code:
    CREATE EVENT:
    /* Path original
    path_volcano_1
    punto 0: 320,272
    punto 1: 272,112
    punto 2: 160,128
    punto 3: 128,368
    */
    
    //New temporary path duplicated from the original path
    temp_path = path_add();
    path_assign(temp_path, path_volcano_1)
    
    //change path coordinated
    for (var i = 1; i < path_get_number(temp_path); i ++)
        {
        var px = path_get_point_x(temp_path, i) + 32 - random(64);
        var py = path_get_point_y(temp_path, i) + 32 - random(64);
        path_change_point(temp_path, i, px, py, 100);
        }
    
    if irandom(2)=2
    {   path_mirror(temp_path);
        path_shift(temp_path, 160, 0);
        path_start(temp_path,10,path_action_stop,1);
    }
    else path_start(temp_path,10,path_action_stop,1);
    Code:
    END OF PATH EVENT:
    instance_destroy();
    path_delete(temp_path);
    Here is the result. You can see the path is even mirrored randomly.
    upload_2016-6-28_16-35-9.png
     

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