Welcome to Jume’s documentation!¶
This documentation describe the Godot project Jume, in order to make it easier to modify the code base if needed.
Jume is a side-project developped by myself. I really liked the Archero game on Android, so I decided to create a similar game !
Installation¶
Install Godot¶
Download and install Godot from their official website.
Clone this repository¶
Clone the repository locally :
git clone https://github.com/astariul/jume.git
Nodes¶
Entity¶
Abstract Node for common behavior between all entities.
Inherits : KinematicBody2D
Properties¶
Methods¶
Constants¶
- SELECT_CLOSEST = “closest”
- One of existing targetting method.This one will choose the closest ennemy to the player.
Signals¶
- running
- Signal emitted when the entity is moving.This signal should be emitted from the
_physics_process()
function of the child class (not handled in this class).Emitted by : Player._process() Received by : Shooter._on_running_timeout()
- immobile
- Signal emitted when the entity is not moving.This signal should be emitted from the
_physics_process()
function of the child class (not handled in this class).Emitted by : Player._process() Received by : Shooter._on_immobile_timeout()
Description¶
This is an Abstract Node, meaning it’s just a script (there is no scene associated to this script).
It is used to define common behavior between all entities to avoid code duplication.
Common behaviors handled by this Node are mainly :
- Common properties and associated methods
- Knockback
- Fire projectile
- Hit by projectile
Properties description¶
knockbacker_pos
¶
Type | Vector2 |
Default | null |
knockbacker_pow
¶
Type | int |
knockback_frame
¶
Type | int |
Default | 0 |
knockback_ratios
in order to create a smooth knockback animation.knockback_ratios
¶
Type | array of float |
Default | [9, 8, 6.5, 4.5, 2] |
damage
¶
Type | int |
Default | 10 |
Knockback damages inflicted by this entity to other knockbacked entities.
destination
¶
Type | Vector2 |
Default | null |
(0, 0)
and the destination is set to (1, 0)
, entity will move to the right.Methods description¶
set_destination(dest=null)
¶
Arguments
|
null
is given.reset_destination()
¶
Reset the current destination to null
.
get_base_velocity()
¶
Return Vector2 |
destination
using speed
.knockback_from(collider)
¶
Arguments
|
knockbacker_pos
and knockbacker_pow
.apply_knockback()
.apply_knockback(velocity)
¶
Return Vector2 |
Arguments
|
Compute the knockback velocity, based on :
knockbacker_pos
&knockbacker_pow
- current position
- given velocity
knockback_ratios
&knockback_frame
is_targetting()
¶
Return bool |
In order to know if the entity is targetting something or not, this method should be called.
select_target(group_name, selection_method="closest")
¶
Return float |
Arguments
|
null
.fire(projectile, atk_speed)
¶
Arguments
|
This method is used as a general method for firing a projectile. For specific behaviors, please refer to each Node.
This method does nothing if no target is selected.
interrupt_shooting()
¶
fire()
.hit_by(projectile)
¶
Arguments
|
This method does 2 things :
- Update the health bar of the entity based on the damage of the projectile.
- Knockback the entity from the projectile.
Player¶
Node representing the playable character.
Inherits : Entity
Description¶
This Node represent the playable character.
It’s an Entity, and simply modify some general behavior into more specific ones :
- Change a few characteristics
- Firing projectile is bow-specific
Methods description¶
_ready()
¶
Method starting animations, adding the Node to the players
group, and changing a few Entity characteristics.
_process()
¶
Arguments
|
This method is executed every frame and do several things :
- If the player don’t have a target anymore, select a new one.
- Get the input from user and set a new destination accordingly, as well as animation. It does not move the player, simply set the new destination.
- Emit right signal depending if the player is running or not.
Emitted signals |
_physics_process(delta)
¶
Arguments
|
This method takes care of the physics engine processing : it moves the player according to :
- The base velocity of the player (computed from the destination, set in
_process()
) - The knockback velocity, if any.
_on_HealthBar_dead()
¶
Free itself upon receiving the dead signal.
Receives signals
|
Ennemy¶
Node representing an ennemy, controlled by the computer.
Inherits : Entity
Description¶
This Node represent an ennemy, controlled by the computer (need to make IA yet).
It’s an Entity, and simply modify some general behavior into more specific ones :
- Change a few characteristics
Methods description¶
_ready()
¶
Method starting animations, adding the Node to the enemies
group, and changing a few Entity characteristics.
_physics_process(delta)
¶
Arguments
|
Projectile¶
Abstract Node for common behavior between all projectiles.
Inherits : KinematicBody2D
Properties¶
Description¶
This is an Abstract Node, meaning it’s just a script (there is no scene associated to this script).
It is used to define common behavior between all projectiles to avoid code duplication.
Common behaviors handled by this Node are mainly :
- Collision with Entities
- Bouncing (or not) on walls
- Projectile being stabbed into walls
Properties description¶
remain_time
¶
Type | float |
Default | 0 |
Number of seconds the projectile stay stabbed into a wall before being freed.
Methods description¶
init(s=1000, d=25, bn=0, rt=0, kp=10)
¶
Arguments
|
This method is used to initialize as we want a new projectile, instead of setting each property by hand.
physics_process()
¶
Arguments
|
Process the main physic of the projectile :
- Move according to current
velocity
- If a collision with an entity happen, free this projectile and hit the entity.
- If a collision with a wall happen, bounce, and later stay stabbed in the wall.
impact()
¶
remain_time
seconds, which call _on_timer_timeout()
when done._on_timer_timeout()
¶
remain_time
seconds.Receives signals
|
Arrow¶
Node representing an arrow from the player.
Inherits : Projectile
Methods¶
Description¶
This Node represent an arrow, which is a projectile fired by the player.
It’s a Projectile, and does not change any of the parent behavior. It is created only for easy understanding of which projectile is friendly and which one is not.
Bullet¶
Node representing a bullet from an ennemy.
Inherits : Projectile
Methods¶
Description¶
This Node represent a bullet, which is a projectile fired by the ennemies.
It’s a Projectile, and does not change any of the parent behavior. It is created only for easy understanding of which projectile is friendly and which one is not.
Bow¶
Node representing the player’s weapon : a bow.
Inherits : AnimatedSprite
Properties¶
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_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
|
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()
¶
idle
and fire the projectile !Receives signals
|
Shooter¶
Node creating a level of abstraction in order to fire projectiles.
Inherits : Node2D
Properties¶
Methods¶
Signals¶
- start_attack
Signal emitted when the entity can start attacking (after stop moving for example).
Emitted by :
set_can_shoot()
Received by :_on_start_attack_timeout()
- stop_attack
Signal emitted when the entity should stop attacking (when running for example).
Emitted by :
set_can_shoot()
Received by :_on_stop_attack_timeout()
Description¶
This Node acts as a layer. It’s a layer above the player, and his job is to instance the projectiles.
Such a trick is needed, because if we simply instancied the projectile in the player Node, projectiles would be childrens of the player, and whenever the player move, the projectiles would move also. We need the position of the player and the projectiles to be independant.
This Node also handle the timer for the attack speed.
Properties description¶
projectile
¶
Type | Projectile |
Default | null |
Non-Instancied Projectile to shoot. The Shooter will instanciate a new one every time it fires.
can_shoot
¶
Type | bool |
Default | true |
State of the Shooter : if it can shoot (not running for example), it is true
, else false
.
Methods description¶
init(shooting_entity, projectile_to_shoot, attck_spd=1, hit_run=false)
¶
Arguments
|
Method to initialize the object with the value needed.
_ready()
¶
This function simply call the set_can_shoot()
function at startup time, in order to send the signal.
set_can_shoot(cs)
¶
Arguments
|
can_shoot
property.Emitted signals
|
_on_start_attack_timeout(collider)
¶
start_attack
signal is emitted._on_Recharging_timeout()
and start the timer according to attack_speed
for the next projectile.Receives signals
|
_on_stop_attack_timeout()
¶
stop_attack
signal is emitted.Receives signals
|
_on_Recharging_timeout()
¶
Main timer, used for timing every time a projectile is fired, based on attack_speed
.
entity
exist, it instanciate a new projectile
and fire it.entity
does not exist anymore (may be killed), it does nothing until the last fired projectile is freed (because if we free before, the child projectile will also be freed).Receives signals
|
HealthBar¶
Node for generic health bar.
Inherits : Node2D
Signals¶
- dead
- Signal emitted when the health bar reach
0
.Emitted by :
damage()
Received by : Ennemy._on_HealthBar_dead(), Player._on_HealthBar_dead()
Description¶
This is a general-purpose Node, implementing a neat health bar.
It has really basic behavior for now, no regeneration or stuff like this.
Behaviors handled so far :
- Possible to set the color of the health bar (the shadow is always set to orange).
- Change the maximum number of HP.
- Take damages.
- Heal HP.
Methods description¶
init(max_health, color=Color(168, 0, 0))
¶
Arguments
|
Method used to setup the health bar, with a specific number of maximum HP and specific color for the health bar.
set_health(h)
¶
Arguments
|
set_max_health(h)
¶
Arguments
|
Set the maximum number of HP to a specific number.