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 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/entities/actors/snake/scripts/head.gd') 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) -- cgit v1.2.3