Package model.projectiles
Class PlayerBubbleProjectileModel
java.lang.Object
model.entities.EntityModel
model.projectiles.ProjectileModel
model.projectiles.PlayerBubbleProjectileModel
Represents the logic of a player bubble projectile in the game.
-
Field Summary
Fields inherited from class model.projectiles.ProjectileModel
direction, state, timer, typeFields inherited from class model.entities.EntityModel
active, height, hitbox, immune, levelManagerModel, width, x, y -
Constructor Summary
ConstructorsConstructorDescriptionPlayerBubbleProjectileModel(float x, float y, Constants.Direction direction) Constructs a PlayerBubbleProjectileModel with the specified position and direction. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckEnemyHit(EnemyModel enemyModel, PlayerModel playerModel) Checks if the projectile hits an enemy.protected voidcheckPlayerHit(PlayerModel playerModel) Checks if the projectile hits the player.protected voidUpdates the position of the projectile.protected voidUpdates the active timer and transforms the projectile into a floating bubble if the timer reaches zero.Methods inherited from class model.projectiles.ProjectileModel
getDirection, getState, getType, updateMethods inherited from class model.entities.EntityModel
conpenetrationSafeUpdateXPos, deactivate, getHitbox, getTileX, getTileY, initHitbox, initLevelManager, isActive, isImmune, setActive, updateXPos
-
Constructor Details
-
PlayerBubbleProjectileModel
Constructs a PlayerBubbleProjectileModel with the specified position and direction.- Parameters:
x- the x-coordinate of the projectiley- the y-coordinate of the projectiledirection- the direction of the projectile
-
-
Method Details
-
updatePos
protected void updatePos()Updates the position of the projectile.Moves the projectile left or right based on its direction.
- Specified by:
updatePosin classProjectileModel
-
updateTimer
protected void updateTimer()Updates the active timer and transforms the projectile into a floating bubble if the timer reaches zero.- Overrides:
updateTimerin classProjectileModel
-
checkEnemyHit
Checks if the projectile hits an enemy.If the projectile hits an active and enemy, it captures the enemy in a bubble and deactivates the projectile.
- Specified by:
checkEnemyHitin classProjectileModel- Parameters:
enemyModel- the enemy model to check againstplayerModel- the player model to add score to if the enemy is killed (not used in this case)
-
checkPlayerHit
Checks if the projectile hits the player.This method is not used as player bubbles cannot hit players.
- Specified by:
checkPlayerHitin classProjectileModel- Parameters:
playerModel- the player model to check against
-