Individual Movement with Rotational Component Feature - UQcsse3200/2023-studio-2 GitHub Wiki
Description
The Individual Movement with Rotational Component feature empowers the companion entity with unique and individualized movement patterns using a rotational component. By incorporating this feature into the CompanionActions component, the companion gains the ability to move freely across the game world, allowing for enhanced exploration and engagement with the player.
Usage
Constructor
CompanionActions companionActions = new CompanionActions();
Methods
void walk(Vector2 direction): Moves the companion in a given direction.
void stopWalking(): Stops the companion from walking.
void setPlayerEntity(Entity playerEntity): Sets the player entity reference for the companion.
void update(): Updates the companion's movement and speed based on user input.
boolean isMovementKeyPressed(): Checks if any movement keys are pressed.
void updateFollowPlayer(): Updates the companion's position to follow the player.
void updateSpeed(): Updates the companion's movement speed.
void create(): Initializes the companion's behavior and event listeners.
Dependencies
PhysicsComponent: Manages the physics simulation of the companion entity.
Entity: Represents the companion entity and facilitates interactions.
Vector2: Provides vector operations for position calculations.
ServiceLocator: Manages game resources and services.
Implementation Details
The Individual Movement with Rotational Component feature introduces a more advanced movement system for the companion entity. The walk() method allows the companion to move in a given direction, providing a greater degree of control over its movement. The stopWalking() method halts the companion's movement, ensuring smooth and controlled navigation. Additionally, the update() method continuously monitors user input to adjust the companion's speed and behavior. Updatefollowplayer() implements Companion’s own movements along with following the player.
By implementing these features, the Individual Movement with Rotational Component feature enhances the companion's interaction with the player, offering dynamic movement options and engaging gameplay.
UML Diagram
Included a UML class diagram that visualizes the relationships between classes and components involved in the Individual Movement with Rotational Component feature. This diagram provides an overview of how the rotational component, physics management, and user input contribute to the companion's individual movement behavior.