turtle: option for direction turtle can spike

This commit is contained in:
Haze Weathers 2023-08-03 21:12:26 -04:00
parent 8ba46dc705
commit acf9628d4c

View file

@ -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: