diff --git a/objects/enemy/turtle.gd b/objects/enemy/turtle.gd index 2ad9ce3..44a3493 100644 --- a/objects/enemy/turtle.gd +++ b/objects/enemy/turtle.gd @@ -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,7 +61,8 @@ func _physics_process(delta: float) -> void: if pos >= pos_start + spike_positions[current_spike_position]: # move on to next position current_spike_position += 1 - spike() + if spike_direction != SpikeDirection.LEFT: + spike() -1.0: # make sure there are still positions left in this direction if current_spike_position - 1 >= 0: @@ -65,7 +70,8 @@ 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 - spike() + if spike_direction != SpikeDirection.RIGHT: + spike() ## performs the spike animation func spike() -> void: