-
Notifications
You must be signed in to change notification settings - Fork 9
FOV Component
Rowan Gray edited this page Sep 13, 2023
·
6 revisions
The FOV (Field of View) component is a critical part of the game engine, responsible for detecting enemies within a certain radius of a turret. This documentation provides an in-depth explanation of the FOV component, its purpose, and how to use it effectively in your game.
The FOV component is used to determine which enemies are within the field of view of a turret. It accomplishes this by checking the distance between the turret and potential enemy entities. When an enemy enters or exits the field of view, callback functions can be triggered to perform specific actions.
- Create an instance of the FOV component, specifying the radius and callback functions for entering and exiting the FOV.
FOVComponent fovComponent = new FOVComponent(radius, this::onEnterFOV, this::onExitFOV);
- Attach the FOV component to the turret entity.
turretEntity.addComponent(fovComponent);
fovComponent.update();
```### ##
## Example
```java
// Create an FOV component with a radius of 5 units
FOVComponent fovComponent = new FOVComponent(5.0f, this::onEnterFOV, this::onExitFOV);
// Attach the FOV component to a turret entity
turretEntity.addComponent(fovComponent);
// Update the FOV component within the game loop
while (gameIsRunning) {
fovComponent.update();
// Other game logic here
}
// Create a TurretTargetableComponent
TurretTargetableComponent turretTargetableComponent = new TargetableEntityComponent();
// Create entity to target
Entity targetingEntity = new Entity();
// Add component to entity
targetingEntity.addComponent(turretTargetableComponent);
Escape Earth Game
Interaction Controller and Interactable Components
Game and Entity Configuration Files
Loading Game Configuration Files