The 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 move(Vector2 direction): Moves the companion in a given direction.
void stopMoving(): Stops the companion from moving.
void update(): Updates the companion's movement and speed based on user input.
boolean isMovementKeyPressed(): Checks if any movement keys are pressed.
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 stopMoving() method halts the companion's movement, ensuring smooth and controlled navigation.
The movement/keyboard input is monitored because the companion is automatically drawn to the player whenever it is not being manually moved. So, there is an additional component - FollowEntity - which is being called every update and listening to if the companion is moving or not. https://github.com/UQcsse3200/2023-studio-2/wiki/FollowEntity
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.