Skip to content

Player Double Jumping Functionality

default-jamc edited this page Sep 25, 2021 · 1 revision

Usage

While jumping, the player can hit SPACE at the apex of their jump to perform a double jump.

Implementation

The Double Jumping functionality is closely intertwined with the Player Jumping Functionality. The Double Jump makes use of the DoubleJumpComponent class to control the players' state, detect collisions and trigger the players' descent.

State-related functionality

The DoubleJumpComponent has an enum to store the players' JumpingState

public enum JumpingState {
 LANDED, JUMPING, DOUBLE_JUMPING
}

There are also an array of other variables to store jump-related information, including

  • JUMP_HEIGHT: the 'height' of the players jump. Changing this variable changes how strictly the player jumps upwards with respect to their current direction
  • jumpStartTime: the time the player started their jump.
  • isJumping: whether or not the player is jumping.
  • jumpState: the players' jumping state. (LANDED, JUMPING or DOUBLE_JUMPING)

Collision detection

To determine when the player has LANDED, physics collisions are used. In the DoubleJumpComponent's create function, a listener for collisionStart is added to the DoubleJumpComponent's onCollision function.

Upon collision, the player is set to LANDED if their collision was with something beneath them, otherwise they are still considered to be jumping.

Triggering the players' descent

The jumping mechanism is dictated by the DoubleJumpComponents JUMP_TIME variable. On every frame, if the total JUMP_TIME has elapsed, the KeyboardPlayerInputComponent handleFalling function is called to bring the player back down (Details can be found on the Player Jumping Functionality Wiki Page).

Table of Contents

Home

Introduction

Main Menu

Main Game Screen

Gameplay

Player Movement

Character Animations

Enemy Monster Design and Animations

Game basic functionalities

User Testing

GitHub Wiki Tutorial

Game Engine

Getting Started

Documentation

Entities and Components

Service Locator

Loading Resources

Logging

Unit Testing

Debug Terminal

Input Handling

UI

Animations

Audio

AI

Physics

Game Screens and Areas

Terrain

Concurrency & Threading

Settings

Troubleshooting

MacOS Setup Guide

Clone this wiki locally