Bow

Node representing the player’s weapon : a bow.

Inherits : AnimatedSprite

Constants

BASE_FPS = 10
Minimum number of FPS for the bow animation.
The animation can be played faster (if the attack speed increase for example), but never slower.
NB_FRAME = 5
Number of frames for the bow attack animation.
BASE_ANGLE = -PI / 4
Angle of the bow when the player just hold it (not targetting anything).
BACKWARD_SPEED = 2.5
Speed of the projectile when drawing a bow.
It’s basically just for smooth animation.
BASE_POS_X = 25
X-Position of the projectile to put it in the right place (the bow).
Originally, the projectile is placed on the center of the entity holding it. We need to change this position, to place the projectile on the bow.
BASE_POS_Y = -2
Y-Position of the projectile to put it in the right place (the bow).
Originally, the projectile is placed on the center of the entity holding it. We need to change this position, to place the projectile on the bow.

Description

This Node represent a bow, the player’s weapon.

The code mainly handle smooth animation of firing arrow : going backward a bit, aiming at the right place, and finally firing the arrow !

Properties description

curr_projectile

Type :doc:`arrow`

Current projectile handled and animated by the bow.

curr_angle

Type float

Current targetting angle. At the end of animation, the arrow will be fired in this direction.

Methods description

_ready()

Simply start the animation.

fire(angle, projectile, attack_speed)

Arguments

angle
Aimed angle. Arrow should be fired at this angle.
projectile
Instancied projectile to fire.
attack_speed
Attack speed to use to fire.

This method compute the right FPS (based on the attack speed) and animate the bow as well as the projectile for a smooth animation.

interrupt_animation()

This method interrupt the animation, resetting it and freeing the projectile.

_on_Bow_animation_finished()

This method is executed when the bow animation ends.
It set the current animation back to idle and fire the projectile !

Receives signals

animation_finished
This signal is emitted when the animation being played ends.