new Clout()
Represents a single cloud in the game's background, extending the MovableObject class.
The cloud moves from right to left at a constant rate.
- Source:
Extends
Members
acceleration :number
Acceleration used for gravity effects.
Type:
- number
- Inherited From:
- Source:
animationInterval :number
Interval ID for the cloud's animation.
Type:
- number
- Source:
currentImage :number
Index of the current image in the animation cycle.
Type:
- number
- Inherited From:
- Source:
enemyIsDead :boolean
Indicates if the enemy is dead. Not used for characters.
Type:
- boolean
- Inherited From:
- Source:
energy :number
The energy level of the object.
Type:
- number
- Inherited From:
- Source:
height :number
The height of the cloud.
Type:
- number
- Source:
lastHit :number
Timestamp of the last time the object was hit.
Type:
- number
- Inherited From:
- Source:
moveInterval :number|undefined
Interval ID for movement-related loops.
Type:
- number | undefined
- Inherited From:
- Source:
speed :number
Horizontal speed of the object.
Type:
- number
- Inherited From:
- Source:
speedY :number
Vertical speed of the object.
Type:
- number
- Inherited From:
- Source:
width :number
The width of the cloud.
Type:
- number
- Source:
y :number
The y-coordinate of the cloud.
Type:
- number
- Source:
Methods
animate()
Starts or restarts the animation interval that continuously moves the cloud to the left.
- Source:
applyGravity()
Applies gravity to the object by updating its vertical position.
The object's vertical speed is decreased by its acceleration at regular intervals.
- Inherited From:
- Source:
hit()
Reduces the object's energy when hit.
If the energy drops below zero, it is set to zero.
Otherwise, the last hit timestamp is updated.
- Inherited From:
- Source:
isAboveGround() → {boolean}
Determines if the object is currently above the ground.
Ground detection differs based on the type of object.
- Inherited From:
- Source:
Returns:
True if the object is above the ground, otherwise false.
- Type
- boolean
isColliding(obj) → {boolean}
Checks if this object is colliding with another movable object.
Collision detection accounts for offset values for more accurate boundaries.
Parameters:
| Name | Type | Description |
|---|---|---|
obj |
MovableObject | The other object to check collision against. |
- Inherited From:
- Source:
Returns:
True if a collision is detected, otherwise false.
- Type
- boolean
isDead() → {boolean}
Determines if the object is dead based on its energy level.
- Inherited From:
- Source:
Returns:
True if the object's energy is zero, otherwise false.
- Type
- boolean
isHurt() → {boolean}
Checks if the object is currently in a hurt state.
An object is considered hurt if it was hit within the last second.
- Inherited From:
- Source:
Returns:
True if the object is hurt, otherwise false.
- Type
- boolean
jump()
Initiates a jump by setting the vertical speed to a positive value.
- Inherited From:
- Source:
moveLeft()
Moves the object to the left by its horizontal speed.
- Inherited From:
- Source:
moveRight()
Moves the object to the right by its horizontal speed.
- Inherited From:
- Source:
playAnimation(images)
Animates the object by cycling through a set of images.
The displayed image is updated based on the current animation frame.
Parameters:
| Name | Type | Description |
|---|---|---|
images |
Array.<string> | An array of image paths used for the animation. |
- Inherited From:
- Source:
reset()
Resets the cloud by assigning it a new random x-position and restarting its movement animation.
- Source: