diff options
Diffstat (limited to 'src/entities/actors')
-rw-r--r-- | src/entities/actors/snake/scripts/head.gd | 13 | ||||
-rw-r--r-- | src/entities/actors/snake/scripts/snake.gd | 2 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/entities/actors/snake/scripts/head.gd b/src/entities/actors/snake/scripts/head.gd index 32847f7..8747910 100644 --- a/src/entities/actors/snake/scripts/head.gd +++ b/src/entities/actors/snake/scripts/head.gd @@ -28,6 +28,19 @@ func _physics_process(delta: float) -> void: # not sure if needed, worked wonders when using a Node2D instead of KB2D velocity = move_and_slide(velocity) + + # slow down on collisions, so it isn't as unfair + if get_last_slide_collision(): + var speed: float = velocity.length() + Global.SNAKE_SPEED = speed + else: + Global.SNAKE_SPEED = Global.SNAKE_SPEED_BACKUP + + # handle slow speeds + if Global.SNAKE_SPEED <= Global.SNAKE_SPEED_BACKUP / 4.0: + Global.SNAKE_SPEED = Global.SNAKE_SPEED_BACKUP + Event.emit_signal("game_over") + _handle_time_elapsed(delta) diff --git a/src/entities/actors/snake/scripts/snake.gd b/src/entities/actors/snake/scripts/snake.gd index 91e4e39..bae6e83 100644 --- a/src/entities/actors/snake/scripts/snake.gd +++ b/src/entities/actors/snake/scripts/snake.gd @@ -6,6 +6,8 @@ export(PackedScene) var TAIL_SEGMENT_NP: PackedScene onready var path: Path2D = $Path +var stats: Stats = SaveData.get_stats() + var finished_adding_initial_segments: bool = false var current_body_segments: int = 0 var body_segment_stack: Array |