Rocket Jumping Tutorial Project

Discussion in 'Tutorials' started by tagwolf, Aug 5, 2019.

  1. tagwolf

    tagwolf Member

    Joined:
    Aug 6, 2016
    Posts:
    59
    GM Version: GMS2.X
    Target Platform: ALL
    Download: https://host-a.net/f/226892-rjyyz
    Links: N/A

    Summary:
    Rocket jumping, perfect platformer controls, and custom particle effects!

    Tutorial:
    Here's a prototype I was working on. It uses my "True Perfect Platformer Movement Controls" from my other tutorial with !!!ROCKET JUMPING!!! added onto it. :)

    Controls are WASD and mouse. (alt controls too and easy to change)

    There's also some "bad ass" custom particle effects thrown in there too that might be of some help to someone out there.

    Make something awesome with it and as always...Enjoy!

    Most of the rocket jump logic happens in the player but is trigger by a rocket explosion. See the project to see how it all works together.

    upload_2019-8-4_16-42-12.png

    player jump snippet. Download full project.
    Code:
    // Perform a rocket jump
    if rocket_jump {
       rocket = instance_nearest(x, y, obj_Rocket)
       hspeed += lengthdir_x(rocket.rocket_power, explosion_direction);
       vspeed += lengthdir_y(rocket.rocket_power, explosion_direction);
       rocket_jump = false;
       with(rocket) {
           instance_destroy();
       }
    }
    
    rocket create and step
    Code:
    // Rocket Vars
    rocket_power = 8;
    rocket_radius = 32;
    rocket_range = 128; // Distance before exploding without collision
    rocket_speed = 10; // todo: add delay to engines and speed up to max
    
    // Guidance
    distance_travelled = 0;
    rocket_explosion = 0;
    target_x = mouse_x;
    target_y = mouse_y;
    direction = point_direction(x, y, target_x, target_y);
    image_angle = direction;
    speed = rocket_speed;
    
    // Propellant Particles
    flame_particle_rate = 1;
    alarm[0] = flame_particle_rate;
    

    Code:
    if (distance_travelled >= rocket_range) || place_meeting(x, y, obj_Block)
    {
       rocket_explosion = true;
       repeat(50)
       {
           instance_create_layer(x, y, layer, obj_Particle)
       }
    }
    distance_travelled++;
    
    if rocket_explosion
    {
       if collision_circle(x, y, rocket_radius, obj_Player, false, true)
       {
           obj_Player.explosion_direction = point_direction(x, y, obj_Player.x, obj_Player.y);
           obj_Player.rocket_jump = true;
    
       } else {
           // Since player won't destroy
           instance_destroy();
       }
    }
    

    https://host-a.net/f/226892-rjyyz
     
    Last edited: Aug 5, 2019

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