|
1 | | -""" |
2 | | -The Player is a KinematicBody2D, in other words a physics-driven object. |
3 | | -It can move, collide with the world... |
4 | | -It HAS a state machine, but the body and the state machine are separate. |
5 | | -""" |
6 | 1 | extends KinematicBody2D |
| 2 | +# The Player is a KinematicBody2D, in other words a physics-driven object. |
| 3 | +# It can move, collide with the world, etc... |
| 4 | +# The player has a state machine, but the body and the state machine are separate. |
7 | 5 |
|
8 | 6 | signal direction_changed(new_direction) |
9 | 7 |
|
10 | | -var look_direction = Vector2(1, 0) setget set_look_direction |
| 8 | +var look_direction = Vector2.RIGHT setget set_look_direction |
11 | 9 |
|
12 | | -func take_damage(attacker, amount, effect=null): |
13 | | - if self.is_a_parent_of(attacker): |
| 10 | +func take_damage(attacker, amount, effect = null): |
| 11 | + if is_a_parent_of(attacker): |
14 | 12 | return |
15 | 13 | $States/Stagger.knockback_direction = (attacker.global_position - global_position).normalized() |
16 | 14 | $Health.take_damage(amount, effect) |
17 | 15 |
|
| 16 | + |
18 | 17 | func set_dead(value): |
19 | 18 | set_process_input(not value) |
20 | 19 | set_physics_process(not value) |
21 | 20 | $CollisionPolygon2D.disabled = value |
22 | 21 |
|
| 22 | + |
23 | 23 | func set_look_direction(value): |
24 | 24 | look_direction = value |
25 | 25 | emit_signal("direction_changed", value) |
0 commit comments