Platform_JumpThrow_Rotation

jonjons

Member
GM Version: Studio 2
Target Platform: Windows
Download OLD vers:
https://drive.google.com/open?id=1amUC6qLRbWY5WEO7OWf2c4sJksFUXwiY

Download NEW ver:


compiled exe

MarketPlace: https://marketplace.yoyogames.com/assets/7923/platformjumprotation

Links: N/A
Description:
It uses only one variable (wallWalk) to handle all collisions... it only checks for this variable, when bumping into a all

A simple place_metting(A) < place_metting(B) .



Obj_wall is set to parent all of other platforms.




Heres the full code:

Player:
CreateEvent:

Code:
/// @description Insert description here

grounded = 0; //---0-IDLE--1-AIR--2-DUCK-
ActorState = 0;
wallWalk = obj_wall_Parent;

walksp = 3; //--WALK-SPEED-
hsp = 0; //--HORIZONTAL-
vsp = 0; //--VERTICAL-
grv = 0.25; //--GRAVITY-ACCELARATION-

jumpSP = -7.4; //--JUMP-SPEED-
platGoTime = 0; //--GOING-THROW-PLATFORMS--

//-------------------//---------------

key_left = 0;
key_right = 0;
key_duck = 0;
key_atk1 = 0;
key_jump = 0;
key_jump2 = 0;
Player:
StepEvent:

Code:
//--Insert-on-top-of-all-moving-and-collision-check
//--Standing-on-Ground-( Blue Boxes - Red Boxes - Rotation Red Boxes )
#region
var check =    collision_circle(x, y+17, 3,  obj_Platform_Rotation, 0, 1);
var check2 = collision_rectangle(bbox_left, bbox_top, bbox_right, bbox_bottom-1, obj_Platform_Rotation, 0, 1)

if ( check != noone && check != check2 && platGoTime == 0 && vsp >= 0 )
{
    wallWalk = check;
}
else
{
    wallWalk = obj_wall_Parent;
}
#endregion

//-----------------------//----------//--------


key_left = keyboard_check(vk_left);
key_right = keyboard_check(vk_right);
key_duck = keyboard_check(vk_down);
key_atk1 = keyboard_check_pressed(ord("Z"));
key_jump = keyboard_check_pressed(ord("X"));
key_jump2 = keyboard_check_released(ord("X"));


//-----//---PLAYER-MOVEMENT--//----------
#region
//-----------//-----PLAYER-MOVE-ON-AIR-----------

repeat(abs(vsp))
{
    if (!place_meeting(x, y + sign(vsp), wallWalk))
    {
        y += sign(vsp);
    }
    else
    {
        vsp = 0;
        break;
    }
}

//-----------//-----PLAYER-MOVE-ON-GROUND-----------
if (grounded == 0 || grounded == 1)
{
    repeat(abs(hsp))
    {
        // Move up slope
        if (place_meeting(x + sign(hsp), y, wallWalk) && !place_meeting(x + sign(hsp), y -4, wallWalk))
        {    --y;    }
        // Move down slope
        if (!place_meeting(x + sign(hsp), y, wallWalk) && !place_meeting(x + sign(hsp), y + 1, wallWalk) && place_meeting(x + sign(hsp), y + 2, wallWalk))
        {    ++y;    }

        if (!place_meeting(x + sign(hsp), y, wallWalk))
        {
            x += sign(hsp);   
        }
        else
        {
            hsp = 0;
            break;
        }
    }
}
else
{
    hsp = 0;
}
#endregion




//----PLAYER-GROUNDED---
//-----0-IDLE-/-WALK----
//-----1-JUMP-----------
//-----2-DUCK-----------
#region

//-------//--CALC-GROUND-STATE--//--------------
if ( place_meeting ( x, y+1, wallWalk) && key_duck )
{
    grounded = 2; //--PLAYER-IS-DUCK-----------
    vsp = 0;
    image_index = 2;
}
else if ( place_meeting ( x, y+1, wallWalk) && vsp >= 0 )
{
    grounded = 0; //--PLAYER-IS-IDLE-----------
    vsp = 0;
        if ( hsp != 0 )
        {
            image_index = 1;
        }
        else
        {
            image_index = 0;
        }  
}
else
{
    grounded = 1;//--PLAYER-IS-ON-AIR-----------
    if ( vsp > 1.5 )
    {
        image_index = 3;
    }
    else if ( vsp < 0 )
    {
        image_index = 3;
    }  

}

//---//--GRAVITY--//----------------------------------------
if (vsp < 12 && grounded == 1)
{
    vsp += grv;
}

//---//--PLR-MOVE--//----------------------------------------
if ( grounded == 0 || grounded == 1)
{
    var move = key_right - key_left;
    hsp = move * walksp;
    if ( move != 0 )
    {
        image_xscale = sign(move);
    }
}
//---//--PLR-JUMP--//----------------------------------------
if ( key_jump && grounded == 0 )
{
    vsp = jumpSP;
}
if ( key_jump2 && vsp < 0 )
{
    vsp/=3;
}

#endregion





//--Insert-on-the-Bottom-of-all-moving-and-collision-check
//---platforms-GO-Down-throw--
#region

//------//--GOING-THORW-PLATFORMS--//--------------------------------
if ( grounded == 2 && key_jump && platGoTime == 0)
{
    platGoTime = 1;
}
if (platGoTime > 0)
{  
    platGoTime -= room_speed/1000;
    platGoTime = clamp(platGoTime, 0, 1);
}


#endregion

//-----------------------//----------//--------
Player:
DrawEvent:

Code:
draw_rectangle(bbox_left, bbox_top, bbox_right, bbox_bottom-1, 1);
draw_circle(x, y+17, 3, 1);


//------------------------//------//------------------

SettingUP
Code:
//--this-code-on-top-of-the-step-evebt
var check =    collision_circle(x, y+17, 3,  obj_Platform_Rotation, 0, 1);
var check2 = collision_rectangle(bbox_left, bbox_top, bbox_right, bbox_bottom-1, obj_Platform_Rotation, 0, 1)

if ( check != noone && check != check2 && platGoTime == 0 && vsp >= 0 )
{
    wallWalk = check;
}
else
{
    wallWalk = obj_wall_Parent;
}


//---this-code-on-bottom-of-the-step-event---
//------//--GOING-THORW-PLATFORMS--//--------------------------------
if ( grounded == 2 && key_jump && platGoTime == 0)
{
    platGoTime = 1;
}
if (platGoTime > 0)
{  
    platGoTime -= room_speed/1000;
    platGoTime = clamp(platGoTime, 0, 1);
}
 
Last edited:

jonjons

Member
Just updated the asset
now the player can jump throw the platforms in the room only by interacting with the platform is on.
This way it can achieve a chain ladder effect or street building ladder effect.

Also fixed the previous slope problem, the player image xscale was being set to 0
if the left and right keys were being pressed together, this would made him get stuck inside a wall.

 

xNYARLx

Member
Hello u can help me implement this to my no commercial game? I a begginer :( i make grame witch tutorial from youtube and now i dont know how implement u system to my game so as not to spoil what I did. I can send u my game and u can implement this? U can help me? I make game in DnD.
 

jonjons

Member
Hello u can help me implement this to my no commercial game? I a begginer :( i make grame witch tutorial from youtube and now i dont know how implement u system to my game so as not to spoil what I did. I can send u my game and u can implement this? U can help me? I make game in DnD.
I never Used DND but i will see if i can do it. I will posted here when iam done.
If then you still have trouble adding to your game, send me the game i will implement for you
 

xNYARLx

Member
ok where send? I write to u PM. DnD drag n drop in GameMaker Studio 2 u don use? i think u are advanced before when u use GMS2 :)
 
Last edited:

jonjons

Member
ok where send? I write to u PM. DnD drag n drop in GameMaker Studio 2 u don use? i think u are advanced before when u use GMS2 :)
there is just one problem i dont know if i can do it in DND... I can try but i cant promisse anything.
I can try to add bits and peices when i have some time, it can be a long process...
 
Top