forked from team-sg/hero-mark-2
turtle: option for direction turtle can spike
This commit is contained in:
parent
8ba46dc705
commit
acf9628d4c
1 changed files with 8 additions and 2 deletions
|
@ -1,10 +1,14 @@
|
|||
tool
|
||||
extends "res://objects/enemy/enemy_move_sidesideupdown.gd"
|
||||
|
||||
enum SpikeDirection {BOTH, LEFT, RIGHT}
|
||||
|
||||
## positions along the path where spikes will trigger
|
||||
export (Array, float) var spike_positions: Array = []
|
||||
## time spikes stay active
|
||||
export var spike_time: float = 0.25
|
||||
## which direction the turtle should be able to spike
|
||||
export (SpikeDirection) var spike_direction: int = SpikeDirection.BOTH
|
||||
|
||||
# animates the spikes
|
||||
var can_spike: bool = true
|
||||
|
@ -57,6 +61,7 @@ func _physics_process(delta: float) -> void:
|
|||
if pos >= pos_start + spike_positions[current_spike_position]:
|
||||
# move on to next position
|
||||
current_spike_position += 1
|
||||
if spike_direction != SpikeDirection.LEFT:
|
||||
spike()
|
||||
-1.0:
|
||||
# make sure there are still positions left in this direction
|
||||
|
@ -65,6 +70,7 @@ func _physics_process(delta: float) -> void:
|
|||
if pos <= pos_start + spike_positions[current_spike_position - 1]:
|
||||
# move on to next (previous because backwards) position
|
||||
current_spike_position -= 1
|
||||
if spike_direction != SpikeDirection.RIGHT:
|
||||
spike()
|
||||
|
||||
## performs the spike animation
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue