Skip to content

Player Actions

Krish edited this page Sep 3, 2026 · 2 revisions

Player actions deals with enacting the various actions of the player after an event is created for the relevant action. This involves changing the velocity of the player when movement occurs, enacting attacks, and implementing the dash feature.

Fields

  • DASH_SPEED_MULTIPLIER the multiplier enacted on movement speed while the player is dashing.
  • physicsComponent the player's physics component/body
  • combatStats the player's combat stats
  • walkDirection the direction in which the player is walking, when the player is walking
  • dashDirection the direction in which the player is dashing, when the player is dashing
  • facingDirection the direction in which the player is facing. Relevant at all times
  • moving a boolean value determining whether or not the player is currently moving. (i.e. the movement vector is not 0)
  • animation the current animation the player has running. ensures the player doesn't try to restart the already running animation
  • dashInit the time at which the dash action was most recently initiated
  • dashOn a boolean value determining whether or not the player is currently dashing
  • dashCooldown a boolean value determining whether or not the dash is currently on cooldown (cooldown currently is turned off after 500 milliseconds)
  • time the GameTime object for accessing the game's time feature.

Constructors

  • PlayerActions() used by PlayerFactory

Methods

  • create() retrieves all of the initial components this needs access too from the entity. Sets up all of the needed listeners within the entity for this class.
  • update() updates the players speed given if the player is dashing, moving, etc. Checks if the players animation needs to be changed.
  • updateSpeed() updates the velocity in the player's physicsComponent based on the directional speed vector obtained when the player moves.
  • walk(Vector2 direction) updates the player's walking direction and facing direction if the player is not dashing.
  • stopWalking() sets the player's current speed to 0 if the player is not dashing.
  • attack() creates an attack event within the entity. Instantiates the attack sound.
  • specialAttack() will create a special attack event within the entity once there is a relevant listener set up somewhere. Instantiates the special attack sound.
  • dash(Vector2 direction) updates the player's dashing direction and records the time at which the dash was instantiated. Sets the dash to on.

Events Triggered

  • update() may trigger a dashStop event if the dash finishes during the update.
  • attack() creates a weaponAttack event.

Testing

Tested using Team 2 testing plan page

Table of Contents

Home

Test Plan

Team 2

Features

Components
Player
Items and Inventory
Enemies
Interactable NPCs
Cutscenes and Dialogue
Music
Bosses
Rooms
Weapons
Abilities & Spells
Game Screens and Areas
Dungeons

Game Engine

Getting Started

Entities and Components

Service Locator

Loading Resources

Logging

Unit Testing

Debug Terminal

Input Handling

UI

Animations

Audio

AI

Physics

Terrain

Concurrency & Threading

Settings

Troubleshooting

MacOS Setup Guide

Clone this wiki locally