-
Notifications
You must be signed in to change notification settings - Fork 7
Hunger Component
Welcome to the documentation page for the HungerComponent.java file in our GitHub project! This component plays a crucial role in managing the hunger level of players in our game.
- Introduction
- Class Overview
- Attributes and Methods
- Usage
The HungerComponent.java class is a fundamental component within our game's player system. It is responsible for tracking and managing the hunger levels of players. As players navigate the game world and engage in various activities, this component ensures that their hunger is monitored and that appropriate actions are taken when hunger reaches critical levels.
The HungerComponent class is a fundamental component within our game's player system, designed to provide a realistic and immersive player experience. It is responsible for monitoring and managing the hunger levels of individual players, contributing to their overall well-being within the game world.
The HungerComponent includes the following attributes and methods:
-
private int hungerLevel:
Represents the current hunger level of the player. -
private void minuteUpdate() :
Updates the hungerLevel of a player every 20 game minutes. -
public boolean checkIfStarving() :
A method to check if a player is starving, returning true when the hunger level reaches 100. -
public int getHungerLevel() :
A method to retrieve the current hunger level. -
public void setHungerLevel(int ) :
A method to set the hunger level to a specific value. -
public void increaseHungerLevel(int ) :
A method to increment the hunger level by a specified value, with bounds to ensure it stays between 0 and 100.
For a complete list of methods and their descriptions, refer to the source code or javadoc of HungerComponent.java.
To incorporate the HungerComponent into our game's player system, follow these steps:
1. Import the necessary classes
import com.csse3200.game.components.player.HungerComponent;
2. Instantiate the HungerComponent for each player:
HungerComponent playerHunger = new HungerComponent(initialHungerLevel);
3. The HungerComponent is automatically updated through minute events in the game. It increases the hunger level every 20 in-game minutes.