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:
Player:
StepEvent:
Player:
DrawEvent:
//------------------------//------//------------------
SettingUP
Target Platform: Windows
Download OLD vers:
https://drive.google.com/open?id=1amUC6qLRbWY5WEO7OWf2c4sJksFUXwiY
Download NEW ver:
Meet Google Drive – One place for all your files
Google Drive is a free way to keep your files backed up and easy to reach from any phone, tablet, or computer. Start with 15GB of Google storage – free.
drive.google.com
compiled exe
Meet Google Drive – One place for all your files
Google Drive is a free way to keep your files backed up and easy to reach from any phone, tablet, or computer. Start with 15GB of Google storage – free.
drive.google.com
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;
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
//-----------------------//----------//--------
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: