From 36abc689d783774ce4f2d7b5a1bb621d8684be45 Mon Sep 17 00:00:00 2001 From: David Luevano Alvarado Date: Sat, 4 Jun 2022 23:00:58 -0600 Subject: added more ui for after gameplay, generalized basic food --- src/entities/actors/snake/scripts/head.gd | 13 +++++++++++++ src/entities/actors/snake/scripts/snake.gd | 2 ++ 2 files changed, 15 insertions(+) (limited to 'src/entities/actors/snake') 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 -- cgit v1.2.3-70-g09d2