Package view.projectiles
Class ProjectileView
java.lang.Object
view.projectiles.ProjectileView
- Direct Known Subclasses:
LightingProjectileView,MaitaFireProjectileView,PlayerBubbleProjectileView
Abstract class representing the view of the
ProjectileModel class.
Handles the animation and rendering of projectiles.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected floatprotected final ProjectileManagerViewprotected ProjectileModel -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedProjectileView(ProjectileModel projectileModel) Constructs a ProjectileView with the specified ProjectileModel. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidDraws the projectile on the screen.protected static intgetAnimation(Constants.Projectiles.ProjectileState projectileState) Returns the animation index for the specified projectile state.protected static intgetSpriteAmount(Constants.Projectiles.ProjectileState projectileState, Constants.Projectiles.ProjectileType projectileType) Returns the number of sprites for the specified projectile state and type.protected booleanisActive()Checks if the projectile is active.protected abstract voidPlays the sound effect associated with the projectile.protected voidupdate()Updates the state of the projectile view, including its animation tick.protected voidUpdates the animation tick and index for the projectile.
-
Field Details
-
projectileModel
-
projectileManagerView
-
animationIndex
protected int animationIndex -
animationTick
protected float animationTick
-
-
Constructor Details
-
ProjectileView
Constructs a ProjectileView with the specified ProjectileModel. Initializes the projectile model and plays the sound effect.- Parameters:
projectileModel- the model of the projectile
-
-
Method Details
-
draw
Draws the projectile on the screen.- Parameters:
g- the Graphics object to draw the projectile
-
update
protected void update()Updates the state of the projectile view, including its animation tick. -
playSoundEffect
protected abstract void playSoundEffect()Plays the sound effect associated with the projectile. -
updateAnimationTick
protected void updateAnimationTick()Updates the animation tick and index for the projectile. -
isActive
protected boolean isActive()Checks if the projectile is active.Active projectiles views are active only if the projectile model is active.
- Returns:
- true if the projectile is active, false otherwise
-
getAnimation
Returns the animation index for the specified projectile state.- Parameters:
projectileState- the state of the projectile- Returns:
- the animation index
-
getSpriteAmount
protected static int getSpriteAmount(Constants.Projectiles.ProjectileState projectileState, Constants.Projectiles.ProjectileType projectileType) Returns the number of sprites for the specified projectile state and type.- Parameters:
projectileState- the state of the projectileprojectileType- the type of the projectile- Returns:
- the number of sprites
-