Package model.itemesAndRewards
Class ItemModel
java.lang.Object
model.itemesAndRewards.ItemModel
- Direct Known Subclasses:
BubbleRewardModel,PowerUpModel
Represents an abstract item in the game.
The `ItemModel` class serves as a base class for all items in the game. It provides common properties and methods for handling item behavior.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected booleanprotected booleanprotected intprotected Rectangle2D.Floatprotected Constants.Items.ItemTypeprotected final PlayingTimerprotected intprotected int -
Constructor Summary
ConstructorsConstructorDescriptionItemModel(int x, int y, Constants.Items.ItemType itemType) Constructs a new `ItemModel` with the specified position and item type. -
Method Summary
Modifier and TypeMethodDescriptionabstract voidAdds points to the player's score based on the item type.abstract voidApplies the effect of the item to the player.voidDeactivates the item.Returns the hitbox of the item.Returns the type of the item.protected voidInitializes the hitbox for the item.booleanisActive()Checks if the item is active.booleanChecks if the item is collected.booleanChecks if the item is despawning.voidsetCollected(boolean collected) Sets the collected state of the item.protected voidupdate()Updates the state of the item.
-
Field Details
-
timer
-
x
protected int x -
y
protected int y -
hitbox
-
itemType
-
deSpawnTimer
protected int deSpawnTimer -
deSpawning
protected boolean deSpawning -
active
protected boolean active -
collected
protected boolean collected
-
-
Constructor Details
-
ItemModel
Constructs a new `ItemModel` with the specified position and item type.- Parameters:
x- the x-coordinate of the itemy- the y-coordinate of the itemitemType- the type of the item
-
-
Method Details
-
addPoints
public abstract void addPoints()Adds points to the player's score based on the item type. -
applyEffect
public abstract void applyEffect()Applies the effect of the item to the player. -
update
protected void update()Updates the state of the item. -
initHitbox
protected void initHitbox()Initializes the hitbox for the item. -
getHitbox
Returns the hitbox of the item.- Returns:
- the hitbox of the item
-
isActive
public boolean isActive()Checks if the item is active.- Returns:
- true if the item is active, false otherwise
-
isDeSpawning
public boolean isDeSpawning()Checks if the item is despawning.- Returns:
- true if the item is despawning, false otherwise
-
deactivateItem
public void deactivateItem()Deactivates the item. -
setCollected
public void setCollected(boolean collected) Sets the collected state of the item.- Parameters:
collected- true if the item is collected, false otherwise
-
isCollected
public boolean isCollected()Checks if the item is collected.- Returns:
- true if the item is collected, false otherwise
-
getItemType
Returns the type of the item.- Returns:
- the type of the item
-