Skip to content

Commit

Permalink
Merge pull request #8 from deanblackborough/player-activated-paltforms
Browse files Browse the repository at this point in the history
Player activated paltforms
  • Loading branch information
deanblackborough authored Dec 21, 2024
2 parents a4df0d5 + 89b71ea commit 78b9085
Show file tree
Hide file tree
Showing 17 changed files with 360 additions and 13 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Check the `player/scripts/playerInput` script file, the controls should be what
- Max jumps setting
- Jump through platforms
- Moving jump through platforms, move in x and/or y, set speed a target
- Player activated jump through platforms
- Player collision with ground
- Player collision with jump through platforms
- Player collision with moving jump through platforms
Expand Down
Binary file modified current-progress.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions gm-platformer.yyp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions objects/oPlayer/Create_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ activeJumpThroughPlatformInstance = noone;
movingJumpThroughPlatformInstance = noone;
activeMovingJumpThroughPlatformInstance = noone;

// Player activated jump through platform
playerActivatedJumpThroughPlatformInstance = noone;
activePlayerActivatedJumpThroughPlatformInstance = noone;

// Quality options
snapToColliders = true;

Expand Down
59 changes: 58 additions & 1 deletion objects/oPlayer/Step_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,14 @@ if (
inputJumpKeyPressed && inputDownKey &&
(
jumpThroughPlatformInstance != noone ||
movingJumpThroughPlatformInstance != noone
movingJumpThroughPlatformInstance != noone ||
playerActivatedJumpThroughPlatformInstance != noone
)
)
{
activeJumpThroughPlatformInstance = jumpThroughPlatformInstance;
activeMovingJumpThroughPlatformInstance = movingJumpThroughPlatformInstance;
activePlayerActivatedJumpThroughPlatformInstance = playerActivatedJumpThroughPlatformInstance;

setPlayerOnGround(false);
}
Expand Down Expand Up @@ -215,6 +217,61 @@ if (jumpThroughPlatformInstance != noone)
setPlayerOnGround(true);
}

/*****************************************
*
* Collision with player activated jump through platforms
*
*****************************************/

if (instance_exists(playerActivatedJumpThroughPlatformInstance))
{
playerActivatedJumpThroughPlatformInstance.sprite_index = playerActivatedJumpThroughPlatformInstance.initialSprite;
}


var resetNumberOfPlayerActivatedJumpThroughPlatforms = instance_number(oPlayerActivatedJumpThroughPlatform);

for (var i = 0; i < resetNumberOfPlayerActivatedJumpThroughPlatforms; i++)
{
var localPlayerActivatedJumpThroughPlatformInstance = instance_find(oPlayerActivatedJumpThroughPlatform, i);
localPlayerActivatedJumpThroughPlatformInstance.sprite_index = localPlayerActivatedJumpThroughPlatformInstance.initialSprite;
}

playerActivatedJumpThroughPlatformInstance = noone;

var numberOfPlayerActivatedJumpThroughPlatforms = instance_number(oPlayerActivatedJumpThroughPlatform);

for (var i = 0; i < numberOfPlayerActivatedJumpThroughPlatforms; i++)
{
var localPlayerActivatedJumpThroughPlatformInstance = instance_find(oPlayerActivatedJumpThroughPlatform, i);

if (
place_meeting(x, y + playerSpeedY, localPlayerActivatedJumpThroughPlatformInstance) &&
floor(y) <= localPlayerActivatedJumpThroughPlatformInstance.bbox_top &&
activePlayerActivatedJumpThroughPlatformInstance != localPlayerActivatedJumpThroughPlatformInstance
)
{
playerActivatedJumpThroughPlatformInstance = localPlayerActivatedJumpThroughPlatformInstance;

if (instance_exists(localPlayerActivatedJumpThroughPlatformInstance))
{
localPlayerActivatedJumpThroughPlatformInstance.sprite_index = localPlayerActivatedJumpThroughPlatformInstance.activeSprite;
}
}
}

if (playerActivatedJumpThroughPlatformInstance != noone)
{
if (snapToColliders)
{
snapToColliderOnY(playerSpeedY, playerActivatedJumpThroughPlatformInstance);
}

playerSpeedY = 0;

setPlayerOnGround(true);
}

/*****************************************
*
* Collision with moving jump through platforms
Expand Down
3 changes: 3 additions & 0 deletions objects/oPlayerActivatedJumpThroughPlatform/Create_0.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

initialSprite = sPlayerActivatedJumpThroughPlatform;
activeSprite = sPlayerActivatedJumpThroughPlatformActive;

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 78b9085

Please sign in to comment.